123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections.Generic;
- using Common.Utility.CombatEvent;
- using Core.Language;
- using Fort23.Core;
- using GameLogic.Hero;
- using UnityEngine;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "HeroBagPanel" )]
- public partial class HeroBagPanel : UIPanel
- {
- private void Init()
- {
- }
- protected override void AddEvent()
- {
- EventManager.Instance.AddEventListener(CustomEventType.MainLvUp, OnMainLvUp);
- EventManager.Instance.AddEventListener(CustomEventType.HeroEquip, CheckAlterRed);
- EventManager.Instance.AddEventListener(CustomEventType.Combat_EquipFall, CheckAlterRed);
- }
- protected override void DelEvent()
- {
- EventManager.Instance.RemoveEventListener(CustomEventType.MainLvUp, OnMainLvUp);
- EventManager.Instance.RemoveEventListener(CustomEventType.HeroEquip, CheckAlterRed);
- EventManager.Instance.RemoveEventListener(CustomEventType.Combat_EquipFall, CheckAlterRed);
- }
- public override void AddButtonEvent()
- {
- btnBack.onClick.AddListener(OnclickClose);
- btnEquip.onClick.AddListener(OnclickEquipment);
- }
- private async void OnclickEquipment()
- {
- ProfessionEquipmentPanel professionEquipmentPanel = await UIManager.
- Instance.LoadAndOpenPanel<ProfessionEquipmentPanel>(null, isFullUI: true);
- professionEquipmentPanel.InitPanel();
- }
- private void OnMainLvUp(IEventData e)
- {
- // SimpleEventData data = e as SimpleEventData;
- UpdateMainLv();
- }
- private void OnclickClose()
- {
- UIManager.Instance.HideUIUIPanel(this);
- }
- private void UpdateMainLv()
- {
- txtMainLv.text = LanguageManager.Instance.Text(64, PlayerManager.Instance.heroController.mainLevel);
- }
- private void CheckAlterRed(IEventData e = null)
- {
- if (PlayerManager.Instance.eqController.atLeastOneBetterEq)
- {
- AlerRed.SetActive(true);
- }
- else
- {
- AlerRed.SetActive(false);
- }
- }
-
- public void InitPanel()
- {
- InitMainHeroWidget();
- UpdateMainLv();
- CheckAlterRed();
- }
- public List<WidgetHero> widgetHeroes = new List<WidgetHero>();
- private async void InitMainHeroWidget()
- {
- widgetHeroes.Clear();
- int i = 0;
- foreach (KeyValuePair<int,HeroInfo> keyValuePair in PlayerManager.Instance.heroController.heroDicInLead)
- {
- RectTransform rectTransform = mainHeroes[i] as RectTransform;
- WidgetHero itemHero = await UIManager.Instance.CreateGComponent<WidgetHero>(null,
- poolName: "WidgetHero", root: rectTransform);
- itemHero.InitHeroForBag(keyValuePair.Value);
-
- widgetHeroes.Add(itemHero);
- i++;
- }
- }
- }
- }
|