12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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);
- }
- protected override void DelEvent()
- {
- EventManager.Instance.AddEventListener(CustomEventType.MainLvUp, OnMainLvUp);
- }
- public override void AddButtonEvent()
- {
- btnBack.onClick.AddListener(OnclickClose);
- btnEquip.onClick.AddListener(OnclickEquipment);
- }
- private async void OnclickEquipment()
- {
- ProfessionEquipmentPanel professionEquipmentPanel = await UIManager.Instance.LoadAndOpenPanel<ProfessionEquipmentPanel>(null);
- 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);
- }
-
- public void InitPanel()
- {
- InitMainHeroWidget();
- UpdateMainLv();
- }
- 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++;
- }
- }
- }
- }
|