123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using Common.Utility.CombatEvent;
- using Core.Language;
- using Core.Utility;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Hero;
- using UnityEngine;
- using UnityEngine.UI;
- using Utility;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "HeroDetailPanel" )]
- public partial class HeroDetailPanel : UIPanel
- {
-
- private HeroInfo heroInfo;
-
- private void Init()
- {
- // InitHeroDetailPanel();
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- btnBack.onClick.AddListener(OnClickClose);
- btnUpgrade.onClick.AddListener(OnClickUpgrade);
- btnPromote.onClick.AddListener(OnClickPromote);
- }
- private void OnClickPromote()
- {
- if (PlayerManager.Instance.gameConstantConfig.maxStar <= heroInfo.star.Value)
- {
- LogTool.Log("已到达最高星级:" + PlayerManager.Instance.gameConstantConfig.maxStar);
- return;
- }
-
- // heroInfo.modelConfig.itemID
- if (BagController.Instance.DeductItem(heroInfo.modelConfig.itemID, heroInfo.promoteConfig.costCount))
- {
- heroInfo.Promote();
- UpdateAttributeUI();
- HeroUITools.SetStarShow(stars, heroInfo.star.Value);
- SendEvent(HeroUpType.Promote);
- }
-
- }
-
- private void OnClickUpgrade()
- {
- if (PlayerManager.Instance.gameConstantConfig.maxLv <= heroInfo.level.Value)
- {
- LogTool.Log("已到达最高等级:" + PlayerManager.Instance.gameConstantConfig.maxLv);
- return;
- }
-
- if (BagController.Instance.DuctHeroExp(heroInfo.powerUpConfig.levelUpExp))
- {
- heroInfo.Upgrade();
- UpdateAttributeUI();
- SendEvent(HeroUpType.Level);
- }
- }
- /// <summary>
- /// 发送英雄提升的事件
- /// </summary>
- /// <param name="upType">提升类型:升级、升星等.</param>
- private void SendEvent(HeroUpType upType)
- {
- HeroPowerUpEventData data = new HeroPowerUpEventData();
- data.heroModelID = heroInfo.modelID;
- data.upType = upType;
-
- PlayerManager.Instance.lastHeroInfo = heroInfo;
- EventManager.Instance.Dispatch(CustomEventType.HeroPowerUp, data);
- if (upType == HeroUpType.Level)
- {
- EventManager.Instance.Dispatch(CustomEventType.HeroLvUp, data);
- }
- else if (upType == HeroUpType.Promote)
- {
- EventManager.Instance.Dispatch(CustomEventType.HeroPromote, data);
- }
-
- }
-
- private void OnClickClose()
- {
- UIManager.Instance.HideUIUIPanel(this);
- }
- public void InitHeroDetailPanel(HeroInfo heroInfo)
- {
- this.heroInfo = heroInfo;
- iconZhiYe.icon_name = heroInfo.iconZhiYe;
- heroName.text = LanguageManager.Instance.Text(heroInfo.modelConfig.name);
- HeroUITools.SetStarShow(stars, heroInfo.star.Value);
- switch (heroInfo.modelConfig.rarity)
- {
- case 1:
- heroRarity.text = LanguageManager.Instance.Text(32);
- break;
- case 2:
- heroRarity.text = LanguageManager.Instance.Text(31);
- break;
- case 3:
- heroRarity.text = LanguageManager.Instance.Text(30);
- break;
- default:
- LogTool.Error("找不到hero的稀有度:" + heroInfo.modelConfig.ID);
- break;
- }
- UpdateAttributeUI();
- }
- public void UpdateAttributeUI()
- {
- txtHP.text = heroInfo.hp.Value.ToStringEx();
- txtATK.text = heroInfo.attack.Value.ToStringEx();
- txtDEF.text = heroInfo.defense.Value.ToStringEx();
- txtSHANBI.text = heroInfo.shanbi.Value.ToStringEx();
- txtLv.text = heroInfo.level.Value.ToStringEx();
- txtExpGain.text = heroInfo.expGain.Value.ToStringEx();
- string redColorStar = "";
- string redColorEnd = "";
-
- long curExp = BagController.Instance.GetItemInfo(GlobalParam.Item_HeroExp_ID).count.Value;
- long costExp = heroInfo.powerUpConfig.levelUpExp;
-
- if (costExp > curExp)
- {
- redColorStar = "<color=#FF4C4C>";
- redColorEnd = "</color>";
- }
- else
- {
- redColorStar = "";
- redColorEnd = "";
- }
- txtUpgrade.text = redColorStar + curExp + redColorEnd + "/" + costExp;
-
-
- long curHeroCount = BagController.Instance.GetItemInfo(heroInfo.modelConfig.itemID).count.Value;
- long costHeroCount = heroInfo.promoteConfig.costCount;
-
- if (costHeroCount > curHeroCount)
- {
- redColorStar = "<color=#FF4C4C>";
- redColorEnd = "</color>";
- }
- else
- {
- redColorStar = "";
- redColorEnd = "";
- }
-
- txtPromote.text = redColorStar + curHeroCount + redColorEnd + "/" + costHeroCount;
- }
- }
- }
|