123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- using System.Collections.Generic;
- using Core.Language;
- using Fort23.Core;
- using GameLogic.Hero;
- using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
- using Utility;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "SelectFaBaoPanel")]
- public partial class SelectFaBaoPanel : UIPanel
- {
- private void Init()
- {
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
- Btn_Change.onClick.AddListener(() =>
- {
- PlayerManager.Instance.FaBaoControl.ChangeUseFaBao(selectIndex, selectedFaBaoInfo);
- currentFaBaoInfo = selectedFaBaoInfo;
- selectedFaBaoInfo = null;
- CustomInit(selectIndex);
- });
- Btn_UpGrade.onClick.AddListener(() =>
- {
- if (selectedFaBaoInfo != null)
- {
- selectedFaBaoInfo.UpGrade();
- UpadaFabaoBag();
- UpdateUI(selectedFaBaoInfo);
- UpdataGradeUI(true);
- }
- });
- Btn_PeiYang.onClick.AddListener(() =>
- {
- BtnUpGradeRoot.SetActive(true);
- BtnChangeRoot.SetActive(false);
- UpdataGradeUI(true);
- });
- Btn_Cancel.onClick.AddListener(() =>
- {
- BtnUpGradeRoot.SetActive(false);
- BtnChangeRoot.SetActive(true);
- UpdataGradeUI(false);
- });
- }
- List<FaBaoAttributeWidget> faBaoAttributeWidgets = new List<FaBaoAttributeWidget>();
- List<FaBaoWidget> faBaoWidgets = new List<FaBaoWidget>();
- FaBaoWidget currentFaBaoWidget = null;
- FaBaoInfo currentFaBaoInfo;
- FaBaoInfo selectedFaBaoInfo;
- int selectIndex;
- public async override CTask<bool> AsyncInit(object[] uiData)
- {
- // await UpadaFabaoBag();
- return await base.AsyncInit(uiData);
- }
- private void UpdataGradeUI(bool isStartUpGrade)
- {
- if (isStartUpGrade)
- {
- AccountFileInfo.FaBaoData faBaoData = new AccountFileInfo.FaBaoData();
- faBaoData.id = selectedFaBaoInfo.FaBaoData.id;
- faBaoData.level = selectedFaBaoInfo.FaBaoData.level + 1;
- FaBaoInfo nextFabaoInfo = new FaBaoInfo(faBaoData);
- foreach (var faBaoAttributeWidget in faBaoAttributeWidgets)
- {
- faBaoAttributeWidget.StartUpGrad(nextFabaoInfo);
- }
- Text_NextLv.text = "+1";
- Text_NextPower.text = "+" + (nextFabaoInfo.qiangDu - selectedFaBaoInfo.qiangDu);
- Text_NextLv.gameObject.SetActive(true);
- Text_NextPower.gameObject.SetActive(true);
- }
- else
- {
- foreach (var faBaoAttributeWidget in faBaoAttributeWidgets)
- {
- faBaoAttributeWidget.EndUpGrade();
- }
- Text_NextLv.gameObject.SetActive(false);
- Text_NextPower.gameObject.SetActive(false);
- }
- }
- private async CTask UpadaFabaoBag()
- {
- foreach (var faBaoAttributeWidget in faBaoWidgets)
- {
- UIManager.Instance.DormancyGComponent(faBaoAttributeWidget);
- }
- faBaoWidgets.Clear();
- if (PlayerManager.Instance.FaBaoControl.myAllFaBao.Count > 0)
- {
- for (var i = 0; i < PlayerManager.Instance.FaBaoControl.myAllFaBao.Count; i++)
- {
- if (PlayerManager.Instance.FaBaoControl.myAllFaBao[i] == currentFaBaoInfo)
- {
- continue;
- }
- FaBaoWidget faBaoWidget = await UIManager.Instance.CreateGComponent<FaBaoWidget>(null, Content);
- faBaoWidget.CustomInit(PlayerManager.Instance.FaBaoControl.myAllFaBao[i]);
- faBaoWidget.onClick = OnClick;
- faBaoWidgets.Add(faBaoWidget);
- }
- NoFaBagRoot.gameObject.SetActive(false);
- }
- else
- {
- NoFaBagRoot.gameObject.SetActive(true);
- }
- }
- private void OnClick(ItemWidgetBasic obj)
- {
- FaBaoWidget faBao = obj as FaBaoWidget;
- selectedFaBaoInfo = faBao.faoInfo;
- Btn_Change.gameObject.SetActive(true);
- UpdateFaBaoUI(selectedFaBaoInfo);
- FaBaoInfoRoot.SetActive(true);
- Text_NoFabaoTips.gameObject.gameObject.SetActive(false);
- }
- public async void CustomInit(int selectIndex)
- {
- this.selectIndex = selectIndex;
- BtnUpGradeRoot.SetActive(false);
- BtnChangeRoot.SetActive(true);
- currentFaBaoInfo = PlayerManager.Instance.FaBaoControl.FightFaBao[selectIndex];
- selectedFaBaoInfo = currentFaBaoInfo;
- UpdateUI(selectedFaBaoInfo);
- UpadaFabaoBag();
- }
- private async void UpdateUI(FaBaoInfo faBaoInfo)
- {
- if (faBaoInfo != null)
- {
- if (currentFaBaoWidget == null)
- currentFaBaoWidget = await UIManager.Instance.CreateGComponent<FaBaoWidget>(null, CurrentFaBaoRoot);
- currentFaBaoWidget.onClick = OnClick;
- currentFaBaoWidget.CustomInit(faBaoInfo);
- UpdateFaBaoUI(faBaoInfo);
- FaBaoInfoRoot.SetActive(true);
- Text_NoFabaoTips.gameObject.gameObject.SetActive(false);
-
- equipTipsRoot.gameObject.SetActive(true);
- Btn_PeiYang.gameObject.SetActive(true);
- Btn_Change.gameObject.SetActive(true);
- }
- else
- {
- FaBaoInfoRoot.SetActive(false);
- Text_NoFabaoTips.gameObject.gameObject.SetActive(true);
- Btn_PeiYang.gameObject.SetActive(false);
- equipTipsRoot.gameObject.SetActive(false);
- Btn_Change.gameObject.SetActive(false);
- }
- }
- private async void UpdateFaBaoUI(FaBaoInfo faBaoInfo)
- {
- foreach (var faBaoAttributeWidget in faBaoAttributeWidgets)
- {
- UIManager.Instance.DormancyGComponent(faBaoAttributeWidget);
- }
- faBaoAttributeWidgets.Clear();
- Text_FaBaoName.text = LanguageManager.Instance.Text(faBaoInfo.FabaoConfig.name) + " Lv." +
- faBaoInfo.FabaoPowerupConfig.ID;
- Text_Power.text = $"强度:{faBaoInfo.qiangDu}";
- Text_Desc.text = UtilTools.GetString(LanguageManager.Instance.Text(faBaoInfo.SkillConfig.dec),
- faBaoInfo.effectValue);
- switch (faBaoInfo.FabaoConfig.magicAttribute)
- {
- case 1:
- Icon_Attribute.GetComponent<CustomStateController>().ChangeState(0);
- Text_Attribute.text = "金";
- break;
- case 2:
- Icon_Attribute.GetComponent<CustomStateController>().ChangeState(1);
- Text_Attribute.text = "木";
- break;
- case 4:
- Icon_Attribute.GetComponent<CustomStateController>().ChangeState(2);
- Text_Attribute.text = "水";
- break;
- case 8:
- Icon_Attribute.GetComponent<CustomStateController>().ChangeState(3);
- Text_Attribute.text = "火";
- break;
- case 16:
- Icon_Attribute.GetComponent<CustomStateController>().ChangeState(4);
- Text_Attribute.text = "土";
- break;
- }
- foreach (var keyValuePair in faBaoInfo.attriButedIC)
- {
- FaBaoAttributeWidget faBaoAttributeWidget =
- await UIManager.Instance.CreateGComponent<FaBaoAttributeWidget>(null, FaBaoAttributeWidgetRoot);
- faBaoAttributeWidget.CusomtInit(selectedFaBaoInfo, keyValuePair.Key);
- faBaoAttributeWidgets.Add(faBaoAttributeWidget);
- }
- }
- public async static CTask<SelectFaBaoPanel> OpenPanel(int selectIndex)
- {
- SelectFaBaoPanel selectFaBaoPanel = await UIManager.Instance.LoadAndOpenPanel<SelectFaBaoPanel>(null);
- selectFaBaoPanel.CustomInit(selectIndex);
- return selectFaBaoPanel;
- }
- public override void Close()
- {
- foreach (var faBaoAttributeWidget in faBaoAttributeWidgets)
- {
- UIManager.Instance.DormancyGComponent(faBaoAttributeWidget);
- }
- faBaoAttributeWidgets.Clear();
- foreach (var faBaoAttributeWidget in faBaoWidgets)
- {
- UIManager.Instance.DormancyGComponent(faBaoAttributeWidget);
- }
- faBaoWidgets.Clear();
- UIManager.Instance.DormancyGComponent(currentFaBaoWidget);
- currentFaBaoWidget = null;
- BtnUpGradeRoot.SetActive(false);
- BtnChangeRoot.SetActive(true);
- currentFaBaoInfo = null;
- selectedFaBaoInfo = null;
- base.Close();
- }
- }
- }
|