//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, September 18, 2017 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TableConfig; using System.Text; using Snxxz.UI; namespace Snxxz.UI { public class RuneStoreWin : StoreUIBasic { #region 成员变量 private ScrollerController _runeCtrl; private FuncConfigConfig _tagFuncModel; private ItemConfig _tagChinModel; private RuneConfig _tagRuneModel; private Text _runeChipText; #endregion RuneModel m_RuneModel; RuneModel runemodel { get { return m_RuneModel ?? (m_RuneModel = ModelCenter.Instance.GetModel()); } } StoreModel _storeModel; StoreModel m_storeModel { get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel()); } } PackModelInterface _modelInterface; PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel()); } } #region Built-in protected override void BindController() { _runeCtrl = transform.Find("RuneCellCtrl").GetComponent(); _runeChipText = transform.Find("RuneBottom/BindChipsCountBG/CountText").GetComponent(); _runeCtrl.OnRefreshCell += RefreshShopCell; } protected override void AddListeners() { } protected override void OnPreOpen() { m_storeModel.RefreshBuyShopLimitEvent += InitModel; model.OnRefreshRuneChip += OnFrenshMoneyInfo; _tagFuncModel = Config.Instance.Get("RuneShop"); m_storeModel.storeFuncType = StoreFunc.RuneStore; InitModel(); OnFrenshMoneyInfo(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { } protected override void OnAfterClose() { m_storeModel.RefreshBuyShopLimitEvent -= InitModel; runemodel.OnRefreshRuneChip -= OnFrenshMoneyInfo; } #endregion RuneModel m_Model; RuneModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel()); } } public void InitModel() { CreateShopItemCell(_runeCtrl,2); } protected override void CreateShopItemCell(ScrollerController shopCtrl, int row) { base.CreateShopItemCell(shopCtrl, row); } private void RefreshShopCell(ScrollerDataType type, CellView cell) { int childCode = 0; for (childCode = 0; childCode < cell.transform.childCount; childCode++) { int cellCount = (cell.transform.childCount) * cell.index + (childCode + 1); RuneCell runeCell = cell.transform.GetChild(childCode).GetComponent(); if (runeCell == null) { runeCell = cell.transform.GetChild(childCode).gameObject.AddComponent(); } if (p_shopItemlist.Count >= cellCount) { StoreConfig shopInfo = p_shopItemlist[cellCount - 1]; cell.transform.GetChild(childCode).gameObject.SetActive(true); ItemConfig chinModel = Config.Instance.Get(shopInfo.ItemID); if (chinModel != null) { ItemCellModel cellModel = new ItemCellModel(chinModel.ID,false, 0, shopInfo.IsBind); runeCell.itemCell.Init(cellModel); string runeStr = model.GetRuneAttrStr(shopInfo.ItemID, 1); runeCell.itemNameText.text = runeStr; runeCell.converNumText.text = shopInfo.MoneyNumber.ToString(); RuneTowerFloorConfig runeTowerModel = m_storeModel.SetRuneSource(shopInfo.ItemID); if(runeTowerModel != null) { runeCell.SourceText.gameObject.SetActive(true); var tower = Config.Instance.Get(runeTowerModel.TowerId); runeCell.SourceText.text = StringUtility.Contact(tower.TowerName, runeTowerModel.FloorName); } else { runeCell.SourceText.gameObject.SetActive(false); } //m_storeModel.SetVipLimit(shopInfo); } runeCell.RuneCellBtn.RemoveAllListeners(); runeCell.RuneCellBtn.AddListener(() => { m_storeModel.OnClickShopCell(shopInfo); }); runeCell.converBtn.RemoveAllListeners(); runeCell.converBtn.AddListener(() => { m_storeModel.SendBuyShopItem(shopInfo, 1); }); } else { cell.transform.GetChild(childCode).gameObject.SetActive(false); } } } public void OnFrenshMoneyInfo() { if (PlayerDatas.Instance.baseData != null) { _runeChipText.text = modelInterface.OnChangeCoinsUnit((uint)runemodel.RuneChip); } else { _runeChipText.text = "0"; } } } }