| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | using System.Collections.Generic;using Core.Language;using Excel2Json;using Fort23.Core;using Fort23.UTool;using GameLogic.Bag;using UnityEngine;namespace Fort23.Mono{    [UIBinding(prefab = "DivineSenceRestoredWidget")]    public partial class DivineSenceRestoredWidget : UIComponent    {        private ShopItemConfig ShopItemConfig;        private AccountFileInfo.ShopItem shopItem;        private ItemConfig itemConfig;        private int openType;        private void Init()        {        }        public override void AddEvent()        {        }        public override void DelEvent()        {        }        public override void AddButtonEvent()        {            Btn_Use.onClick.AddListener(async () =>            {                //购买并使用道具                if (openType == 1)                {                    if (ShopItemConfig.buyCount != -1 && shopItem.buyCount >= ShopItemConfig.buyCount)                    {                        TipMessagePanel.OpenTipMessagePanel(10366, Vector2.zero);                        return;                    }                    if (ShopItemConfig.price != 0 &&                        !PlayerManager.Instance.BagController.IsEnough(ShopItemConfig.costItemId,                            ShopItemConfig.price * 1))                    {                        ItemSourcePanel.OpenPanel(ShopItemConfig.costItemId);                        // TipMessagePanel.OpenTipMessagePanel(829, Vector2.zero);                        return;                    }                    List<ItemInfo> itemInfos = await ShopManger.Instance.BuyItem(ShopItemConfig.ID, 1);                    if (itemInfos != null)                    {                        //使用道具                        foreach (var itemInfo in itemInfos)                        {                            if (itemInfo.config.itemTag == 8)                            {                                AccountFileInfo.Instance.playerData.divineSensePoint +=                                    itemInfo.config.associateVlaue[0];                                PlayerManager.Instance.BagController.DeductItem(itemInfo.config.ID, 1);                            }                        }                        CustomInit(ShopItemConfig.ID);                    }                    else                    {                        TipMessagePanel.OpenTipMessagePanel(833, Vector2.zero);                    }                }                //世界使用道具                else                {                    if (PlayerManager.Instance.BagController.IsEnough(itemConfig.ID, 1))                    {                        AccountFileInfo.Instance.playerData.divineSensePoint +=                            itemConfig.associateVlaue[0];                        PlayerManager.Instance.BagController.DeductItem(itemConfig.ID, 1);                        CustomInit1(itemConfig.ID);                    }                    else                    {                        TipMessagePanel.OpenTipMessagePanel(10324, Vector2.zero);                    }                }                EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);            });        }        public void CustomInit(int shopitemId)        {            openType = 1;            ShopItemConfig = ConfigComponent.Instance.Get<ShopItemConfig>(shopitemId);            shopItem = ShopManger.Instance.GetShopItem(shopitemId);            itemConfig = ConfigComponent.Instance.Get<ItemConfig>(ShopItemConfig.itemId[0]);            if (ShopItemConfig.costItemId == 0)            {                Group_Price.SetActive(false);                Text_Free.gameObject.SetActive(true);                Text_Free.text = LanguageManager.Instance.Text(10328);            }            else            {                ItemConfig costItemConfig = ConfigComponent.Instance.Get<ItemConfig>(ShopItemConfig.costItemId);                Group_Price.SetActive(true);                Text_Free.gameObject.SetActive(false);                Icon_PriceItem.icon_name = costItemConfig.icon;                Text_Price.text = ShopItemConfig.price.ToString();            }            Icon_Itemicon.icon_name = itemConfig.icon;            Text_Count.text = $"x{itemConfig.associateVlaue[0]}";            Text_Tip.text = LanguageManager.Instance.Text(10369, ShopItemConfig.buyCount - shopItem.buyCount);        }        public void CustomInit1(int itemId)        {            openType = 2;            itemConfig = ConfigComponent.Instance.Get<ItemConfig>(itemId);            Icon_Itemicon.icon_name = itemConfig.icon;            Text_Count.text = $"x{itemConfig.associateVlaue[0]}";            Text_Tip.text =                LanguageManager.Instance.Text(10327, PlayerManager.Instance.BagController.GetItemCount(itemId));            Group_Price.SetActive(false);            Text_Free.gameObject.SetActive(true);            Text_Free.text = LanguageManager.Instance.Text(10329);        }    }}
 |