| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- using System.Collections.Generic;
- using System.Linq;
- using Animancer;
- using Animancer.TransitionLibraries;
- using Core.Language;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Hero;
- using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
- using UnityEngine;
- using UnityEngine.UI.Extensions;
- using Utility;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "MainHeroPanel")]
- public partial class MainHeroPanel : UIPanel
- {
- List<BtnFaBaoWidget> btnFaBaoWidgets = new List<BtnFaBaoWidget>();
- private GameObjectPool modelObj;
- private void Init()
- {
- isAddStack = true;
- IsShowAppBar = true;
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override CTask GetFocus()
- {
- TitlePanel.OpenPanel(new List<int>() { 1001, 1002 });
- AppBarPanel.OpenPanel(this);
- return base.GetFocus();
- }
- public override CTask LoseFocus()
- {
- // TitlePanel.ClosePanel();
- // AppBarPanel.ClosePanel();
- return base.LoseFocus();
- }
- private HeroInfo heroInfo;
- private List<HeroAttributeWidget> HeroAttributeWidgets = new List<HeroAttributeWidget>();
- public override void AddButtonEvent()
- {
- Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
- Btn_Sentiment.onClick.AddListener(() => { SentimentPanel.OpenPanel(); });
- reorderableList.OnElementRemoved.AddListener(GetReorderableDataBegin);
- reorderableList.OnElementDropped.AddListener(GetReorderableData);
- }
- public int FromIndex;
- public int ToIndex;
- private async void GetReorderableDataBegin(ReorderableList.ReorderableListEventStruct arg0)
- {
- FromIndex = arg0.FromIndex;
- }
- private async void GetReorderableData(ReorderableList.ReorderableListEventStruct arg0)
- {
- ToIndex = arg0.ToIndex;
- //一样直接不交换
- if (ToIndex == FromIndex)
- {
- return;
- }
- if (ToIndex > PlayerManager.Instance.myHero.powerUpConfig.MaxFabaoNum - 1)
- {
- return;
- }
- FaBaoInfo faBaoInfo = PlayerManager.Instance.FaBaoControl.FightFaBao[FromIndex];
- List<FaBaoInfo> faBaoInfos = PlayerManager.Instance.FaBaoControl.FightFaBao.ToList();
- faBaoInfos.RemoveAt(FromIndex);
- faBaoInfos.Insert(ToIndex,faBaoInfo);
- for (var i = 0; i < faBaoInfos.Count; i++)
- {
- PlayerManager.Instance.FaBaoControl.ChangeUseFaBao(i, faBaoInfos[i]);
- }
- BtnFaBaoWidget btnFaBaoWidget = btnFaBaoWidgets[FromIndex];
-
- btnFaBaoWidgets.RemoveAt(FromIndex);
- btnFaBaoWidgets.Insert(ToIndex,btnFaBaoWidget);
- for (var i = 0; i < btnFaBaoWidgets.Count; i++)
- {
- btnFaBaoWidgets[i].CustomInit(i);
- }
-
- }
- public async override CTask<bool> AsyncInit(object[] uiData)
- {
- await CustomInit();
- base.AsyncInit(uiData);
- return true;
- }
- public async CTask CustomInit()
- {
- foreach (var btnFaBaoWidget in btnFaBaoWidgets)
- {
- UIManager.Instance.DormancyGComponent(btnFaBaoWidget);
- }
- btnFaBaoWidgets.Clear();
- for (int i = 0; i < 4; i++)
- {
- BtnFaBaoWidget btnFaBaoWidget =
- await UIManager.Instance.CreateGComponent<BtnFaBaoWidget>(null, FaBaoRoot);
- btnFaBaoWidget.CustomInit(i);
- btnFaBaoWidget.OnClick = OnClick;
- btnFaBaoWidgets.Add(btnFaBaoWidget);
- }
- heroInfo = PlayerManager.Instance.myHero;
- HeroAttributeWidget heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10712, new HeroAttributeData("生命", "",
- PlayerManager.Instance.myHero.hp.Value.ToStringEx()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10713, new HeroAttributeData("攻击", "",
- PlayerManager.Instance.myHero.attack.Value.ToStringEx()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10714, new HeroAttributeData("防御", "",
- PlayerManager.Instance.myHero.defense.Value.ToStringEx()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- // heroAttributeWidget =
- // await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- // Content, isInstance: true);
- // heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- // heroAttributeWidget.CustomInit1(10715, new HeroAttributeData("攻击速度", "",
- // PlayerManager.Instance.myHero.attSpeed.Value.ToString()));
- // HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10716, new HeroAttributeData("金灵根", "",
- PlayerManager.Instance.myHero.Metal.ToString()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10717, new HeroAttributeData("木灵根", "",
- PlayerManager.Instance.myHero.Wood.ToString()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10718, new HeroAttributeData("水灵根", "",
- PlayerManager.Instance.myHero.Water.ToString()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10719, new HeroAttributeData("火灵根", "",
- PlayerManager.Instance.myHero.Fire.ToString()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- heroAttributeWidget =
- await UIManager.Instance.CreateGComponentForObject<HeroAttributeWidget>(HeroAttributeWidgetGam, null,
- Content, isInstance: true);
- heroAttributeWidget.OnClick = heroAttributeWidgetOnClick;
- heroAttributeWidget.CustomInit1(10720, new HeroAttributeData("土灵根", "",
- PlayerManager.Instance.myHero.Earth.ToString()));
- HeroAttributeWidgets.Add(heroAttributeWidget);
- }
- private void heroAttributeWidgetOnClick(ItemWidgetBasic obj)
- {
- HeroAttributeWidget heroAttributeWidget = obj as HeroAttributeWidget;
- TipMessagePanel.OpenTipMessagePanel(heroAttributeWidget.lanID);
- }
- private async void OnClick(ItemWidgetBasic obj)
- {
- BtnFaBaoWidget btnFaBaoWidget = obj as BtnFaBaoWidget;
- if (btnFaBaoWidget.index > PlayerManager.Instance.myHero.powerUpConfig.MaxFabaoNum - 1)
- {
- HeroPowerUpConfig[] heroPowerUpConfigs = ConfigComponent.Instance.GetAll<HeroPowerUpConfig>();
- foreach (var heroPowerUpConfig in heroPowerUpConfigs)
- {
- if (heroPowerUpConfig.MaxFabaoNum > btnFaBaoWidget.index)
- {
- TipMessagePanel.OpenTipMessagePanel(LanguageManager.Instance.Text(10331,
- LanguageManager.Instance.Text(heroPowerUpConfig.jingjieLanIDs[0]) +
- LanguageManager.Instance.Text(heroPowerUpConfig.jingjieLanIDs[1]) +
- LanguageManager.Instance.Text(heroPowerUpConfig.jingjieLanIDs[2])));
- return;
- }
- }
- TipMessagePanel.OpenTipMessagePanel("当前位置未解锁");
- return;
- }
- int redDotID = 9;
- AccountFileInfo.RedDot redDot = RedDotManager.Instance.GetRedDot(redDotID);
- if (redDot == null)
- {
- redDot = new AccountFileInfo.RedDot();
- redDot.id = redDotID;
- }
- if (!redDot.Params.Contains(btnFaBaoWidget.index.ToString()))
- {
- redDot.Params.Add(btnFaBaoWidget.index.ToString());
- RedDotManager.Instance.AddRedDot(redDot);
- RedDotManager.Instance.ChangeStateRedDot(redDotID, 0);
- }
- SelectFaBaoPanel selectFaBaoPanel = await SelectFaBaoPanel.OpenPanel(btnFaBaoWidget.index);
- await selectFaBaoPanel.UIClosed();
- foreach (var b in btnFaBaoWidgets)
- {
- b.CustomInit(b.index);
- }
- }
- public async static CTask<MainHeroPanel> OpenPanel()
- {
- MainHeroPanel mainHeroPanel =
- await UIManager.Instance.LoadAndOpenPanel<MainHeroPanel>(null, isFullUI: true);
- return mainHeroPanel;
- }
- public async override CTask Close()
- {
- UIManager.Instance.DormancyGComponent(modelObj);
- modelObj = null;
- foreach (var btnFaBaoWidget in btnFaBaoWidgets)
- {
- UIManager.Instance.DormancyGComponent(btnFaBaoWidget);
- }
- btnFaBaoWidgets.Clear();
- foreach (var heroAttributeWidget in HeroAttributeWidgets)
- {
- UIManager.Instance.DormancyGComponent(heroAttributeWidget);
- }
- HeroAttributeWidgets.Clear();
- await base.Close();
- }
- }
- }
|