| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 | using System.Collections.Generic;using System.Linq;using Core.Language;using Excel2Json;using Fort23.Core;using Fort23.UTool;using UnityEngine.UI;using Utility;namespace Fort23.Mono{    [UIBinding(prefab = "SentimentInfoPanel")]    public partial class SentimentInfoPanel : UIPanel    {        AccountFileInfo.SentimentProperty curretnSentimentProperty;        // private EnergyWidget energyWidget;        private AccountFileInfo.SentimentData sentimentData;        List<SentimentEffectWidget> sentimentEffectWidgets = new List<SentimentEffectWidget>();        private List<SentimentEffectConfig> _sentimentEffectConfigs;        private List<SentimentEffectConfig> currentGroupSentimentEffectConfigs;        public SentimentEffectWidget mainSentimentEffectWidget;        private SentimentEffectWidget currentSentimentEffectWidget;        private ItemWidgetType1 _itemWidgetType1;        TitlePanel _titlePanel;        private void Init()        {            isAddStack = true;        }        public async override CTask GetFocus()        {            AppBarPanel.OpenPanel(this);            await base.GetFocus();        }        protected override void AddEvent()        {        }        protected override void DelEvent()        {        }        public override void AddButtonEvent()        {            Btn_Rest.onClick.AddListener(() =>            {                foreach (var sentimentDataSentimentProperty in sentimentData.sentimentProperties)                {                    int count = 0;                    int itemid = 0;                    for (int i = 0; i < sentimentDataSentimentProperty.level; i++)                    {                        int level1 = sentimentData.sentimentProperties[0].level <= 0 ? 1 : sentimentData.sentimentProperties[0].level;                        int conFigId1 = sentimentData.sentimentProperties[0].groupId * 10 + level1;                        var sentimentEffectConfig1 = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId1);                        itemid = sentimentEffectConfig1.upConstItemId;                        count += sentimentEffectConfig1.upConstCount;                    }                    PlayerManager.Instance.BagController.AddItem(itemid, count);                    sentimentDataSentimentProperty.level = 0;                }                foreach (var sentimentEffectWidget in sentimentEffectWidgets)                {                    sentimentEffectWidget.CustomInit(sentimentEffectWidget.sentimentProperty);                }                AccountFileInfo.Instance.SavePlayerData();            });            Btn_LingWu.onClick.AddListener(() =>            {                if (curretnSentimentProperty == null)                {                    return;                }                if (currentSentimentEffectWidget.lastSentimentWidget != null && currentSentimentEffectWidget.lastSentimentWidget.sentimentProperty.level < currentSentimentEffectWidget.sentimentEffectConfig.unlockLevel)                {                    TipMessagePanel.OpenTipMessagePanel("前置节点没有解锁");                    return;                }                if (curretnSentimentProperty.level >= currentGroupSentimentEffectConfigs.Count)                {                    TipMessagePanel.OpenTipMessagePanel("已经达到最大等级");                    return;                }                int level = curretnSentimentProperty.level <= 0 ? 1 : curretnSentimentProperty.level;                int conFigId = curretnSentimentProperty.groupId * 100 + level + 1;                SentimentEffectConfig sentimentEffectConfig = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId);                if (PlayerManager.Instance.BagController.DeductItem(sentimentEffectConfig.upConstItemId, sentimentEffectConfig.upConstCount))                {                    TipMessagePanel.OpenTipMessagePanel("道具不足");                    return;                }                //扣除道具                // sentimentEffectConfig.upConstItemId.                // s                curretnSentimentProperty.level++;                AccountFileInfo.Instance.SavePlayerData();                foreach (var sentimentEffectWidget in sentimentEffectWidgets)                {                    sentimentEffectWidget.UpdateXian();                }                UpdateUi();                currentSentimentEffectWidget.CustomInit(curretnSentimentProperty);            });        }        public int MapNumber(int input)        {            if (input >= 1 && input <= 3)            {                return 0;            }            else if (input >= 4 && input <= 6)            {                return 1;            }            else if (input >= 7 && input <= 9)            {                return 2;            }            else            {                return -1;            }        }        public async override CTask<bool> AsyncInit(object[] uiData)        {            sentimentData = uiData[0] as AccountFileInfo.SentimentData;            _sentimentEffectConfigs = ConfigComponent.Instance.GetAll<SentimentEffectConfig>().ToList();            mainSentimentEffectWidget = await UIManager.Instance.CreateGComponentForObject<SentimentEffectWidget>(MainSentimentEffectWidget, null);            mainSentimentEffectWidget.CustomInit(sentimentData.mainSentiment);            mainSentimentEffectWidget.OnClick = OnClick;            int level1 = sentimentData.sentimentProperties[0].level <= 0 ? 1 : sentimentData.sentimentProperties[0].level;            int conFigId1 = sentimentData.sentimentProperties[0].groupId * 10 + level1;            var sentimentEffectConfig1 = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId1);            if (_titlePanel == null)            {                _titlePanel = await TitlePanel.OpenPanel(new List<int>() { sentimentEffectConfig1.upConstItemId });            }            else            {                _titlePanel.CustomInit(new List<int>() { sentimentEffectConfig1.upConstItemId });            }            return await base.AsyncInit(uiData);        }        public async override CTask Show()        {            await base.Show();            foreach (var sentimentEffectWidget in sentimentEffectWidgets)            {                UIManager.Instance.DormancyGComponent(sentimentEffectWidget);            }            sentimentEffectWidgets.Clear();            foreach (var sentimentDataSentimentProperty in sentimentData.sentimentProperties)            {                int level = sentimentDataSentimentProperty.level <= 0 ? 1 : sentimentDataSentimentProperty.level;                int conFigId = sentimentDataSentimentProperty.groupId * 10 + level;                var sentimentEffectConfig = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId);                int index = MapNumber(sentimentEffectConfig.pos);                SentimentEffectWidget sentimentEffectWidget1 = await UIManager.Instance.CreateGComponent<SentimentEffectWidget>(null, Root[index]);                sentimentEffectWidget1.CustomInit(sentimentDataSentimentProperty);                sentimentEffectWidget1.OnClick = OnClick;                sentimentEffectWidgets.Add(sentimentEffectWidget1);                if (currentSentimentEffectWidget == null)                {                    sentimentEffectWidget1.OnPointerClick();                }            }            foreach (var rectTransform in Root)            {                LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);            }            foreach (var sentimentEffectWidget in sentimentEffectWidgets)            {                int level = sentimentEffectWidget.sentimentProperty.level <= 0 ? 1 : sentimentEffectWidget.sentimentProperty.level;                int conFigId = sentimentEffectWidget.sentimentProperty.groupId * 10 + level;                var sentimentEffectConfig = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId);                SentimentEffectWidget sentimentEffectWidget1 = null;                if (sentimentEffectConfig.lastSentimentEffectId == -1)                {                    sentimentEffectWidget1 = mainSentimentEffectWidget;                }                else                {                    sentimentEffectWidget1 = sentimentEffectWidgets.FirstOrDefault(s => s.sentimentEffectConfig.groupId == sentimentEffectConfig.lastSentimentEffectId);                }                sentimentEffectWidget.CreatXian(XianRoot, sentimentEffectWidget1);            }        }        private async void UpdateUi()        {            int level = curretnSentimentProperty.level <= 0 ? 1 : curretnSentimentProperty.level;            int conFigId = curretnSentimentProperty.groupId * 10 + level;            SentimentEffectConfig sentimentEffectConfig = ConfigComponent.Instance.Get<SentimentEffectConfig>(conFigId);            currentGroupSentimentEffectConfigs = _sentimentEffectConfigs.Where(se => se.groupId == sentimentEffectConfig.groupId).ToList();            Text_Name.text = LanguageManager.Instance.Text(sentimentEffectConfig.name);            Text_Desc.text = UtilTools.GetString(LanguageManager.Instance.Text(sentimentEffectConfig.massge), sentimentEffectConfig.effectVale);            UIManager.Instance.DormancyGComponent(_itemWidgetType1);            _itemWidgetType1 = null;            _itemWidgetType1 = await UIManager.Instance.CreateGComponentForObject<ItemWidgetType1>(ItemWidgetType1Gam, null);            _itemWidgetType1.CustomInit(sentimentEffectConfig.upConstItemId, sentimentEffectConfig.upConstCount);            if (curretnSentimentProperty.level >= currentGroupSentimentEffectConfigs.Count)            {                Text_CurrentLevel.text = $"{curretnSentimentProperty.level}级 ";                Text_NextLevel.text = $"MAX级";            }            else            {                Text_CurrentLevel.text = $"{curretnSentimentProperty.level}级 ";                Text_NextLevel.text = $"{curretnSentimentProperty.level + 1}级";            }        }        private void OnClick(ItemWidgetBasic obj)        {            SentimentEffectWidget sentimentEffectWidget = obj as SentimentEffectWidget;            currentSentimentEffectWidget = sentimentEffectWidget;            curretnSentimentProperty = sentimentEffectWidget.sentimentProperty;            Text_EffectName.text = LanguageManager.Instance.Text(sentimentEffectWidget.sentimentEffectConfig.name);            UpdateUi();        }        public static async CTask OpenPanel(AccountFileInfo.SentimentData sentimentData)        {            await UIManager.Instance.LoadAndOpenPanel<SentimentInfoPanel>(null, uiData: new object[] { sentimentData });        }        public async override CTask Close()        {            foreach (var sentimentEffectWidget in sentimentEffectWidgets)            {                UIManager.Instance.DormancyGComponent(sentimentEffectWidget);            }            sentimentEffectWidgets.Clear();            currentSentimentEffectWidget = null;            curretnSentimentProperty = null;            // UIManager.Instance.DormancyGComponent(energyWidget);            // energyWidget = null;            await base.Close();        }    }}
 |