| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 | using System.Collections.Generic;using System.Threading.Tasks;using Common.Utility.CombatEvent;using Core.Utility;using Excel2Json;using Fort23.Core;using Fort23.UTool;using GameLogic.Bag;using GameLogic.Combat.CombatTool;using GameLogic.Combat.CombatType;using GameLogic.Hero;using UnityEngine;using Utility;namespace Fort23.Mono{    [UIBinding(prefab = "MainUIPanel")]    public partial class MainUIPanel : UIPanel    {        private CombatHeroEntity bossHeroEntity;        private void Init()        {            InitRes();            InitBattleHeroWidget();            LevelUpdate(null);        }        protected override void AddEvent()        {            CombatEventManager.Instance.AddEventListener(CombatEventType.CombatExpAlter, CombatExpAlter);            // EventManager.Instance.AddEventListener(CustomEventType.HeroPowerUp, OnHeroPowerUp);            EventManager.Instance.AddEventListener(CustomEventType.ItemUpdate, OnItemUpdate);            EventManager.Instance.AddEventListener(CustomEventType.ShowBossHp, ShowBossHp);            EventManager.Instance.AddEventListener(CustomEventType.LevelUpdate, LevelUpdate);            CombatEventManager.Instance.AddEventListener(CombatEventType.HeroHpUpdate, HeroHpUpdateEventData);            EventManager.Instance.AddEventListener(CustomEventType.ShowBattleExp, ShowBattleExp);            EventManager.Instance.AddEventListener(CustomEventType.StartBossBattle, StartBossBattle);            EventManager.Instance.AddEventListener(CustomEventType.ShowDialogue, ShowDialogue);            EventManager.Instance.AddEventListener(CustomEventType.AlterCombatHero, AlterCombatHero);            EventManager.Instance.AddEventListener(CustomEventType.PlayerUseSkill, PlayerUseSkill);        }        private void PlayerUseSkill(IEventData iEventData)        {            Button_huiQiu_tween.Play("show", false);        }        private void StartBossBattle(IEventData iEventData)        {            UIManager.Instance.LoadAndOpenPanel<StartBossPanel>(null, UILayer.Middle);        }        private void ShowDialogue(IEventData iEventData)        {            ShowDialogueEventData dialogueData = iEventData as ShowDialogueEventData;            string[] dialogueMessaga = dialogueData.dialogueMessaga;            string[] icon = dialogueData.icon;            System.Action finis = dialogueData.finish;            ShowDialogueEventData.MessageShowType messageShowTyp = dialogueData.messageShowType;            DialoguePanel.OpenDialoguePanel(dialogueMessaga, icon, messageShowTyp, finis);        }        private void ShowBattleExp(IEventData iEventData)        {            bossHp.SetActive(false);            Slider_Exp_Process.SetActive(true);            bossHeroEntity = null;        }        private void HeroHpUpdateEventData(IEventData iEventData)        {            HeroHpUpdateEventData heroHpUpdateEventData = iEventData as HeroHpUpdateEventData;            if (heroHpUpdateEventData.combatHeroEntity == bossHeroEntity)            {                UpdateBossHp();            }        }        protected override void DelEvent()        {            CombatEventManager.Instance.RemoveEventListener(CombatEventType.CombatExpAlter, CombatExpAlter);            // EventManager.Instance.RemoveEventListener(CustomEventType.HeroPowerUp, OnHeroPowerUp);            EventManager.Instance.RemoveEventListener(CustomEventType.ItemUpdate, OnItemUpdate);            EventManager.Instance.RemoveEventListener(CustomEventType.ShowBossHp, ShowBossHp);            EventManager.Instance.RemoveEventListener(CustomEventType.LevelUpdate, LevelUpdate);            CombatEventManager.Instance.RemoveEventListener(CombatEventType.HeroHpUpdate, HeroHpUpdateEventData);            EventManager.Instance.RemoveEventListener(CustomEventType.ShowBattleExp, ShowBattleExp);            EventManager.Instance.RemoveEventListener(CustomEventType.ShowDialogue, ShowDialogue);            EventManager.Instance.RemoveEventListener(CustomEventType.AlterCombatHero, AlterCombatHero);        }        public override void AddButtonEvent()        {            btnHeroBag.onClick.AddListener(OnClickHeroBag);            Button_battleBoss.onClick.AddListener(OnClickButtonBattleBoss);            box.onClick.AddListener(OnOpenBox);            Button_huiQiu.onClick.AddListener(OnClickPlayerSkill);            Icon_HeroExp_button.onClick.AddListener(OnClickIcon_HeroExp_button);            Icon_Coin_button.onClick.AddListener(OnClickIcon_Coin_button);            Icon_Diamon_button.onClick.AddListener(OnClickIcon_Diamon_button);        }        private void OnClickIcon_HeroExp_button()        {            TipMessagePanel.OpenTipMessagePanel("英雄经验,可用于升级英雄等级<color=#ff0000>(每杀死一个小怪能获得经验,击杀boss能获得大量经验)</color>",                new Vector2(Icon_HeroExp_button.transform.position.x, Icon_HeroExp_button.transform.position.y - 0.5f));        }        private void OnClickIcon_Coin_button()        {            TipMessagePanel.OpenTipMessagePanel("金币,用于抽取英雄宝箱<color=#ff0000>(每杀死一个小怪有几率获得金币,击杀boss能获得大量金币)</color>",                new Vector2(Icon_Coin_button.transform.position.x, Icon_Coin_button.transform.position.y - 0.5f));        }        private void OnClickIcon_Diamon_button()        {            TipMessagePanel.OpenTipMessagePanel("紫砖(敬请期待)",                new Vector2(Icon_Diamon_button.transform.position.x, Icon_Diamon_button.transform.position.y - 0.5f));        }        private void OnOpenBox()        {            BoxPanel.OpenBoxPanel();        }        private async void OnClickButtonBattleBoss()        {            if (AccountFileInfo.Instance.playerData.isAllHeroDie)            {                LevelBattleCombatType levelBattleCombatType =                    CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;                levelBattleCombatType.StartBossCombat();                Button_battleBoss.gameObject.SetActive(false);            }        }        private async void OnClickPlayerSkill()        {            Debug.Log("显示描述");            RectTransform huoQiu = Button_huiQiu.GetComponent<RectTransform>();            TipMessagePanel.OpenTipMessagePanel("点击屏幕空白处从天空中召唤一个陨石,对怪物造成1点伤害,并有<color=#ff0000>30%</color>概率获得1枚金币(boss怪<color=#ff0000>40%</color>掉落,金币数量<color=#ff0000>+2</color>)",                new Vector2(huoQiu.position.x, huoQiu.position.y + 0.5f));        }        private async void OnClickHeroBag()        {            HeroBagPanel heroBagPanel = await UIManager.Instance.LoadAndOpenPanel<HeroBagPanel>(null, isFullUI: true);            heroBagPanel.InitPanel();        }        private void AlterCombatHero(IEventData e)        {            InitHeroWidget();        }        private void OnItemUpdate(IEventData e)        {            ItemUpdateData data = e as ItemUpdateData;            if (data.ItemInfo.itemID == GlobalParam.Item_Coin_ID)            {                txtCoin.text = BagController.Instance.GetItemInfo(GlobalParam.Item_Coin_ID).count.Value.ToStringEx();            }            else if (data.ItemInfo.itemID == GlobalParam.Item_Diamond_ID)            {                txtDiamond.text = BagController.Instance.GetItemInfo(GlobalParam.Item_Diamond_ID).count.Value                    .ToStringEx();            }            else if (data.ItemInfo.itemID == GlobalParam.Item_HeroExp_ID)            {                txtHeroExp.text = BagController.Instance.GetItemInfo(GlobalParam.Item_HeroExp_ID).count.Value                    .ToStringEx();            }        }        private void LevelUpdate(IEventData eventData)        {            int levelBattle = AccountFileInfo.Instance.playerData.levelBattle;            LevelBattleConfig levelBattleConfig = ConfigComponent.Instance.Get<LevelBattleConfig>(levelBattle);            levelName.text = levelBattleConfig.levelName;        }        private void ShowBossHp(IEventData eventData)        {            ShowBossHpEventData showBossHpEventData = eventData as ShowBossHpEventData;            bossHeroEntity = showBossHpEventData.boss;            bossHp.SetActive(true);            Slider_Exp_Process.SetActive(false);            bossName.text = bossHeroEntity.CurrCombatHeroInfo.heroName;            UpdateBossHp();        }        protected void UpdateBossHp()        {            Slider_Hp_Boss.value = bossHeroEntity.CurrCombatHeroInfo.hp.Value * 1.0f /                                   bossHeroEntity.MaxCombatHeroInfo.hp.Value;        }        private void CombatExpAlter(IEventData eventData)        {            ExpAlter();        }        private void ExpAlter()        {            if (CombatController.currActiveCombat == null || CombatController.currActiveCombat.CombatTypeBasic == null)            {                return;            }            LevelBattleCombatType levelBattleCombatType =                CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;            float bl = (levelBattleCombatType.exp * 1.0f) / levelBattleCombatType.CurrMaxExp;            exp.value = bl;            TextExp.text = levelBattleCombatType.exp + "/" + levelBattleCombatType.CurrMaxExp;            if (levelBattleCombatType.exp >= levelBattleCombatType.CurrMaxExp) // 到达目标值,开始打boss            {                if (!levelBattleCombatType.isBossCombat && AccountFileInfo.Instance.playerData.isAllHeroDie)                {                    Button_battleBoss.gameObject.SetActive(true);                }            }            else            {                Button_battleBoss.gameObject.SetActive(false);            }        }        // private void OnHeroPowerUp(IEventData eventData)        // {        //     HeroPowerUpEventData data = eventData as HeroPowerUpEventData;        //     HeroInfo heroInfo = (HeroInfo)PlayerManager.Instance.heroController.GetHeroInfo(data.heroModelID);        //        //     foreach (WidgetHero widgetHero in widgetHeroes)        //     {        //         if (widgetHero.heroInfo.modelID == heroInfo.modelID)        //         {        //             widgetHero.UpdateWidgetUI(heroInfo);        //             break;        //         }        //     }        // }        public List<WidgetHero> widgetHeroes = new List<WidgetHero>();        /// <summary>        /// 把主界面的几个英雄UI归位        /// </summary>        /// <param name="wh"></param>        public void RestWidgetHeroPos(WidgetHero wh)        {            Vector3 v;            Vector3 origin;            foreach (WidgetHero w in widgetHeroes)            {                if (wh != null && w.Equals(wh))                {                    continue;                }                v = w.transform.parent.localPosition;                if (v.y > 0)                {                    origin = new Vector3(v.x, 0, v.z);                    w.transform.parent.localPosition = origin;                    w.SetMoreBtnActive(false);                }            }        }        private async void InitBattleHeroWidget()        {            Button_battleBoss.gameObject.SetActive(false);            InitHeroWidget();        }        private async void InitHeroWidget()        {            for (int j = 0; j < widgetHeroes.Count; j++)            {                UIManager.Instance.DormancyGComponent(widgetHeroes[j]);            }            widgetHeroes.Clear();            int i = 0;            foreach (KeyValuePair<int, HeroInfo> keyValuePair in PlayerManager.Instance.heroController.heroDicInLead)            {                RectTransform rectTransform = hero_battle[i] as RectTransform;                WidgetHero itemHero = await UIManager.Instance.CreateGComponent<WidgetHero>(null,                    poolName: "WidgetHero", root: rectTransform);                itemHero.InitHero(keyValuePair.Value);                itemHero.own.gameObject.name= "hero_battle"+i;                widgetHeroes.Add(itemHero);                i++;            }        }        private void InitRes()        {            txtDiamond.text = BagController.Instance.GetItemInfo(GlobalParam.Item_Diamond_ID).count.Value.ToStringEx();            txtCoin.text = BagController.Instance.GetItemInfo(GlobalParam.Item_Coin_ID).count.Value.ToStringEx();            txtHeroExp.text = BagController.Instance.GetItemInfo(GlobalParam.Item_HeroExp_ID).count.Value.ToStringEx();        }    }}
 |