using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using EnhancedUI.EnhancedScroller; using vnxbqy.UI; public class DungeonLiquidCell : ScrollerUI { [SerializeField] Transform m_ContainerUp; [SerializeField] Text m_ExpUpper; [SerializeField] Image m_UpperIcon; [SerializeField] Transform m_ContainerBuy; [SerializeField] Text m_Cost; [SerializeField] Image m_ItemBG; [SerializeField] Image m_ItemIcon; [SerializeField] Image m_MoneyIcon; [SerializeField] Text m_ItemCount; [SerializeField] Button m_FuncBtn; [SerializeField] Button m_ItemBtn; [SerializeField] Text m_BtnTxt; [SerializeField] Transform m_ContainerUse; [SerializeField] Text m_ItemTime; DungeonLiquidModel m_Model; DungeonLiquidModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel()); } } BuffModel m_BuffModel; BuffModel Buffmodel { get { return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel()); } } StoreModel _storeModel; StoreModel m_storeModel { get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel()); } } public override void Refresh(CellView cell) { int index = cell.index; if (model.IsBagHasLiquid) { if (index < model.liquidItemList.Count) { ItemModel itemModel = model.liquidItemList[index]; ItemConfig cfg = ItemConfig.Get((int)itemModel.itemId); m_ItemIcon.SetSprite(cfg.IconKey); m_ItemBG.SetItemBackGround(cfg.ItemColor); if (itemModel.count > 1) { m_ItemCount.SetActive(true); m_ItemCount.text = itemModel.count.ToString(); } else { m_ItemCount.SetActive(false); } if (Buffmodel._BuffDic.ContainsKey(cfg.AddSkill1)) { m_ContainerUp.SetActive(false); m_ContainerUse.SetActive(true); } else { m_ContainerUse.SetActive(false); m_ContainerUp.SetActive(true); m_ContainerUp.transform.localPosition = m_ContainerUp.transform.localPosition.SetY(0); SkillConfig skillCfg = SkillConfig.Get(cfg.AddSkill1); m_ExpUpper.text = Language.Get("FairyLand_Func24", skillCfg.EffectValue11 / 100); m_ItemTime.text = Language.Get("BuyExpShow_" + itemModel.itemId); var _buffId = 0; m_UpperIcon.SetActive(true); if (UseLiquid(out _buffId)) { var currentSkillConfig = SkillConfig.Get(_buffId); if (currentSkillConfig.EffectValue11 >= skillCfg.EffectValue11) { m_UpperIcon.SetActive(false); } } } m_ContainerBuy.SetActive(false); m_BtnTxt.text = Language.Get("FairyLand_Func25"); m_FuncBtn.onClick.RemoveAllListeners(); m_FuncBtn.onClick.AddListener(() => { OnUseItemClick(itemModel); }); m_ItemBtn.onClick.RemoveAllListeners(); m_ItemBtn.onClick.AddListener(() => { OnItemClick(itemModel); }); } } else { if (index < model.liquidStoreConfigs.Count) { StoreConfig storeModel = model.liquidStoreConfigs[index]; ItemConfig cfg = ItemConfig.Get(storeModel.ItemID); m_ItemIcon.SetSprite(cfg.IconKey); m_ItemBG.SetItemBackGround(cfg.ItemColor); m_ItemCount.SetActive(false); m_MoneyIcon.SetIconWithMoneyType(storeModel.MoneyType); m_ContainerUp.transform.localPosition = m_ContainerUp.transform.localPosition.SetY(8); SkillConfig skillCfg = SkillConfig.Get(cfg.AddSkill1); m_ExpUpper.text = Language.Get("FairyLand_Func24", skillCfg.EffectValue11 / 100); m_ItemTime.text = Language.Get("BuyExpShow_" + storeModel.ItemID); m_ContainerUp.SetActive(true); var _buffId = 0; m_UpperIcon.SetActive(true); if (UseLiquid(out _buffId)) { var currentSkillConfig = SkillConfig.Get(_buffId); if (currentSkillConfig.EffectValue11 >= skillCfg.EffectValue11) { m_UpperIcon.SetActive(false); } } m_ContainerBuy.SetActive(true); m_ContainerUse.SetActive(false); m_Cost.text = storeModel.MoneyNumber.ToString(); m_BtnTxt.text = Language.Get("FairyLand_Func23"); m_FuncBtn.onClick.RemoveAllListeners(); m_FuncBtn.onClick.AddListener(() => { OnBuyItemClick(storeModel); }); m_ItemBtn.onClick.RemoveAllListeners(); m_ItemBtn.onClick.AddListener(() => { OnItemClick(cfg); }); } } } private bool UseLiquid(out int _buffId) { _buffId = 0; for (int i = 0; i < model.liquidItems.Count; i++) { var config = ItemConfig.Get(model.liquidItems[i]); if (Buffmodel._BuffDic.ContainsKey(config.AddSkill1)) { _buffId = config.AddSkill1; return true; } } return false; } private void OnBuyItemClick(StoreConfig storeModel) { m_storeModel.SendBuyShopItem(storeModel, 1); } private void OnUseItemClick(ItemModel itemModel) { int buffid = 0; for (int i = 0; i < model.liquidItems.Count; i++) { ItemConfig cfg = ItemConfig.Get(model.liquidItems[i]); if (Buffmodel._BuffDic.ContainsKey(cfg.AddSkill1)) { buffid = cfg.AddSkill1; break; } } ItemConfig _useItemCfg = ItemConfig.Get(itemModel.itemId); //if (buffid != 0 && buffid != _useItemCfg.AddSkill1) //{ // ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("FairyLand_Func22"), (System.Action)((bool isOk) => // { // if (isOk) // { // WindowCenter.Instance.Close(); // ItemOperateUtility.Instance.UseItem(itemModel.guid); // } // })); //} //else { WindowCenter.Instance.Close(); ItemOperateUtility.Instance.UseItem(itemModel.guid); } } private void OnItemClick(ItemConfig _itemCfg) { ItemTipUtility.Show(_itemCfg.ID); } private void OnItemClick(ItemModel _itemModel) { ItemTipUtility.Show(_itemModel.guid); } }