| Core/GameEngine/Model/Config/StoreConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/GameEngine/Model/Config/StoreConfig.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/GameEngine/Model/TelPartialConfig/tagStoreConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/ItemTip/TipBuyItemWidget.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/BuyItemController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/ShopItemCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/ShopSecondCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/ShopSecondCell.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/StoreModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/StoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Core/GameEngine/Model/Config/StoreConfig.cs
@@ -1,6 +1,6 @@ //-------------------------------------------------------- // [Author]: Fish // [ Date ]: Wednesday, May 15, 2019 // [ Date ]: Wednesday, December 11, 2019 //-------------------------------------------------------- using System.Collections.Generic; @@ -15,6 +15,7 @@ public readonly int ID; public readonly int ShopType; public readonly int[] SecondType; public readonly int ShopSort; public readonly int ItemID; public readonly int ItemCnt; @@ -25,6 +26,7 @@ public readonly int RefreshType; public readonly int[] VIPLV; public readonly int LV; public readonly int LVSee; public readonly int[] PurchaseNumber; public readonly int MoneyType; public readonly int MoneyNumber; @@ -49,53 +51,62 @@ int.TryParse(tables[1],out ShopType); int.TryParse(tables[2],out ShopSort); string[] SecondTypeStringArray = tables[2].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); SecondType = new int[SecondTypeStringArray.Length]; for (int i=0;i<SecondTypeStringArray.Length;i++) { int.TryParse(SecondTypeStringArray[i],out SecondType[i]); } int.TryParse(tables[3],out ItemID); int.TryParse(tables[3],out ShopSort); int.TryParse(tables[4],out ItemCnt); int.TryParse(tables[4],out ItemID); int.TryParse(tables[5],out IsBind); int.TryParse(tables[5],out ItemCnt); ItemListEx = tables[6]; int.TryParse(tables[6],out IsBind); int.TryParse(tables[7],out MainItemID); ItemListEx = tables[7]; JobItem = tables[8]; int.TryParse(tables[8],out MainItemID); int.TryParse(tables[9],out RefreshType); JobItem = tables[9]; string[] VIPLVStringArray = tables[10].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); int.TryParse(tables[10],out RefreshType); string[] VIPLVStringArray = tables[11].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); VIPLV = new int[VIPLVStringArray.Length]; for (int i=0;i<VIPLVStringArray.Length;i++) { int.TryParse(VIPLVStringArray[i],out VIPLV[i]); } int.TryParse(tables[11],out LV); int.TryParse(tables[12],out LV); string[] PurchaseNumberStringArray = tables[12].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); int.TryParse(tables[13],out LVSee); string[] PurchaseNumberStringArray = tables[14].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); PurchaseNumber = new int[PurchaseNumberStringArray.Length]; for (int i=0;i<PurchaseNumberStringArray.Length;i++) { int.TryParse(PurchaseNumberStringArray[i],out PurchaseNumber[i]); } int.TryParse(tables[13],out MoneyType); int.TryParse(tables[15],out MoneyType); int.TryParse(tables[14],out MoneyNumber); int.TryParse(tables[16],out MoneyNumber); int.TryParse(tables[15],out MoneyOriginal); int.TryParse(tables[17],out MoneyOriginal); int.TryParse(tables[16],out LimitValue); int.TryParse(tables[18],out LimitValue); SalesStatus = tables[17]; SalesStatus = tables[19]; int.TryParse(tables[18],out TheOnlyShop); int.TryParse(tables[20],out TheOnlyShop); int.TryParse(tables[19],out RemindSuccess); int.TryParse(tables[21],out RemindSuccess); int.TryParse(tables[20],out IsHideSellOut); int.TryParse(tables[22],out IsHideSellOut); } catch (Exception ex) { Core/GameEngine/Model/Config/StoreConfig.cs.meta
@@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 602ffd3ae93acbd4ab37153e80b12548 timeCreated: 1557892603 timeCreated: 1576073870 licenseType: Pro MonoImporter: serializedVersion: 2 Core/GameEngine/Model/TelPartialConfig/tagStoreConfig.cs
@@ -16,7 +16,7 @@ var _storeItem = new StoreItem() { shopType = this.ShopType, item = this.ItemID, itemID = this.ItemID, type = this.MoneyType, }; if (!s_StoreItemDict.ContainsKey(_storeItem)) @@ -33,13 +33,13 @@ list.Add(this); } public static StoreConfig GetStoreCfg(int _item, int _moneyType, int shopType = 0) public static StoreConfig GetStoreCfg(int _itemID, int _moneyType, int shopType = 0) { if (shopType != 0) { var storeItem = new StoreItem() { item = _item, itemID = _itemID, type = _moneyType, shopType = shopType, }; @@ -58,7 +58,7 @@ { var storeItem = new StoreItem() { item = _item, itemID = _itemID, type = _moneyType, shopType = shop1Types[i], }; @@ -82,13 +82,13 @@ public struct StoreItem { public int shopType; public int item; public int itemID; public int type; public override bool Equals(object x) { StoreItem _storeItem = (StoreItem)x; return this.item == _storeItem.item && this.type == _storeItem.type && this.shopType == _storeItem.shopType; return this.itemID == _storeItem.itemID && this.type == _storeItem.type && this.shopType == _storeItem.shopType; } public override int GetHashCode() System/ItemTip/TipBuyItemWidget.cs
@@ -93,6 +93,16 @@ m_Count.color = UIHelper.GetUIColor(isSellOut ? TextColType.Red : TextColType.Green); var config = StoreConfig.Get(this.goodId); int curVipIndex = -1; int nextVipIndex = -1; bool isVipBuy = BuyItemController.Instance.CheckIsVipBuy(config, out curVipIndex, out nextVipIndex); if (isVipBuy || PlayerDatas.Instance.baseData.LV < config.LV) { transform.Find("Container_Money").gameObject.SetActive(false); return; } transform.Find("Container_Money").gameObject.SetActive(true); var moneyOwn = UIHelper.GetMoneyCnt(config.MoneyType); var totalPrice = BuyItemController.Instance.GetTotalPrice(this.goodId, count); m_Money.text = totalPrice.ToString(); System/Store/BuyItemController.cs
@@ -9,7 +9,8 @@ public class BuyItemController : Singleton<BuyItemController> { Dictionary<int, int> vipBuyCntDict = new Dictionary<int, int>(); Dictionary<int, int> vipBuyCntDict = new Dictionary<int, int>(); public bool CheckIsVipBuy(StoreConfig model, out int curVipIndex, out int nextVipIndex) { vipBuyCntDict.Clear(); System/Store/ShopItemCell.cs
@@ -26,7 +26,7 @@ public Text itemNameText { get { if (_itemNameText == null) _itemNameText = transform.Find("ItemNameText").GetComponent<Text>(); _itemNameText = transform.Find("layout/ItemNameText").GetComponent<Text>(); return _itemNameText; } } @@ -35,7 +35,7 @@ public Text vipText { get { if (_vipText == null) _vipText = transform.Find("VIPText").GetComponent<Text>(); _vipText = transform.Find("layout/VIPText").GetComponent<Text>(); return _vipText; } } @@ -44,7 +44,7 @@ public Image coinsIcon { get { if (_coinsIcon == null) _coinsIcon = transform.Find("MoneyBG").GetComponent<Image>(); _coinsIcon = transform.Find("layout/MoneyBG").GetComponent<Image>(); return _coinsIcon; } } @@ -53,11 +53,22 @@ public Text coinNumText { get { if (_coinNumText == null) _coinNumText = transform.Find("MoneyBG/CountText").GetComponent<Text>(); _coinNumText = transform.Find("layout/MoneyBG/CountText").GetComponent<Text>(); return _coinNumText; } } private Text _buyOnceText; public Text buyOnceText { get { if (_buyOnceText == null) _buyOnceText = transform.Find("layout/BuyOnce").GetComponent<Text>(); return _buyOnceText; } } private Image _stateImage; public Image stateImage { get { System/Store/ShopSecondCell.cs
New file @@ -0,0 +1,33 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { //商城二级标签 public class ShopSecondCell: CellView { [SerializeField] Text m_ClassifyName; [SerializeField] Transform m_ContainerSelect; [SerializeField] Button m_Select; [SerializeField] Image m_SecondIcon; StoreModel model { get { return ModelCenter.Instance.GetModel<StoreModel>(); } } int classifyId = 0; public void Display(int id) { classifyId = id; m_ClassifyName.text = Language.Get("ShopSecond_" + id); m_ContainerSelect.gameObject.SetActive(model.selectSecondType == id); m_SecondIcon.SetSprite("ShopSecond_" + id); m_Select.SetListener(() => { model.selectSecondType = classifyId; }); } } } System/Store/ShopSecondCell.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 1f990a6d87944204c8165c1d0a3f67b2 timeCreated: 1575639264 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/Store/StoreModel.cs
@@ -48,6 +48,24 @@ public int fairyStoreJumpShopId = 0; int m_SelectClassifyId = 0; public int selectSecondType { get { return m_SelectClassifyId; } set { if (m_SelectClassifyId != value) { m_SelectClassifyId = value; if (selectClassifyRefresh != null) { selectClassifyRefresh(); } } } } public event Action selectClassifyRefresh; public event Action mysteryShopRefreshEvent; RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } } @@ -79,6 +97,7 @@ isUpdatePlayerLv = false; IsMustBuyDay = false; isLogin = true; sortStoreSecondType = true; ClearJump(); StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish; FuncOpen.Instance.OnFuncStateChangeEvent -= FuncStateChange; @@ -359,9 +378,8 @@ { int sort1 = start.storeConfig.ShopSort; int sort2 = end.storeConfig.ShopSort; if (sort1.CompareTo(sort2) != 0) return sort1.CompareTo(sort2); return 0; return sort1.CompareTo(sort2); } public class StoreData @@ -376,11 +394,15 @@ private Dictionary<int, List<StoreData>> showStoreTypeDict = new Dictionary<int, List<StoreData>>(); private Dictionary<int, Dictionary<int, List<StoreData>>> showStoreSecondTypeDict = new Dictionary<int, Dictionary<int, List<StoreData>>>(); // 新规则分二级标签,此函数保留,另增加UpdateShowStoreEx函数 public void UpdateShowStore() { showStoreTypeDict.Clear(); int playeLv = PlayerDatas.Instance.baseData.LV; int vipLevel = PlayerDatas.Instance.baseData.VIPLv; //int vipLevel = PlayerDatas.Instance.baseData.VIPLv; foreach (var type in storeTypeDict.Keys) { var storeDatas = storeTypeDict[type]; @@ -390,7 +412,7 @@ for (int i = 0; i < storeDatas.Count; i++) { var storeData = storeDatas[i]; bool isReachLv = playeLv >= storeData.storeConfig.LV ? true : false; bool isReachLv = playeLv >= storeData.storeConfig.LVSee ? true : false; bool isReachSpec = true; switch (storeData.storeConfig.ShopType) { @@ -430,6 +452,78 @@ showStoreTypeDict.Add(type, showStoreDatas); } } UpdateShowStoreEx(); } // 商城分二级标签 public void UpdateShowStoreEx() { sortStoreSecondType = true; showStoreSecondTypeDict.Clear(); foreach (var type in showStoreTypeDict.Keys) { if (!showStoreSecondTypeDict.ContainsKey(type)) showStoreSecondTypeDict[type] = new Dictionary<int, List<StoreData>>(); foreach (var storeData in showStoreTypeDict[type]) { foreach (var secondType in storeData.storeConfig.SecondType) { if (!showStoreSecondTypeDict[type].ContainsKey(secondType)) showStoreSecondTypeDict[type][secondType] = new List<StoreData>(); showStoreSecondTypeDict[type][secondType].Add(storeData); } } } } bool sortStoreSecondType = true; public void SortStoreSecondType() { //ArrayList lst = new ArrayList(showStoreSecondTypeDict.Keys); if (!sortStoreSecondType) return; foreach (var type in showStoreSecondTypeDict.Keys) { foreach (var secondType in showStoreSecondTypeDict[type].Keys) { var storeList = showStoreSecondTypeDict[type][secondType]; storeList.Sort(CompareSecondShop); } } sortStoreSecondType = false; } private bool IsSellOut(StoreData storeData) { int remainNum = 0; if (TryGetIsSellOut(storeData.storeConfig, out remainNum)) return true; if (storeData.storeConfig.TheOnlyShop == 1 && CheckTheOnlyShopSellOut(storeData.shopId)) return true; return false; } private int CompareSecondShop(StoreData start, StoreData end) { bool isSellOut1 = IsSellOut(start); bool isSellOut2 = IsSellOut(end); if (isSellOut1 != isSellOut2) return isSellOut1.CompareTo(isSellOut2); int sort1 = start.storeConfig.ShopSort; int sort2 = end.storeConfig.ShopSort; return sort1.CompareTo(sort2); } /// <summary> @@ -486,6 +580,41 @@ } return results; } // 获取二级标签商品 public List<StoreData> TryGetStoreDatasBySecondType(int type, int secondType) { if (!showStoreSecondTypeDict.ContainsKey(type)) return null; if (!showStoreSecondTypeDict[type].ContainsKey(secondType)) return null; SortStoreSecondType(); return showStoreSecondTypeDict[type][secondType]; } // 获得二级标签的第一个标签类型 public int GetFirstStoreSecondType(int type) { if (!showStoreSecondTypeDict.ContainsKey(type)) return 0; ArrayList sortList = new ArrayList(showStoreSecondTypeDict[type].Keys); sortList.Sort(); return (int)sortList[0]; } // 获得二级标签的第一个标签类型 public ArrayList GetStoreSecondTypeList(int type) { if (!showStoreSecondTypeDict.ContainsKey(type)) return null; ArrayList sortList = new ArrayList(showStoreSecondTypeDict[type].Keys); sortList.Sort(); return sortList; } public StoreData GetStoreData(int shopId) @@ -724,9 +853,10 @@ return remainSecond; } int refreshTime = 0; private void UpdateSecond() { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; if (isUpdatePlayerLv) { UpdatePlayerLv(); @@ -851,6 +981,7 @@ if (!isLogin) { sortStoreSecondType = true; UpdateShowStore(); UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); System/Store/StoreWin.cs
@@ -26,6 +26,7 @@ [SerializeField] Button m_RightBtn; [SerializeField] Button m_CloseBtn; [SerializeField] ScrollerController m_ShopCtrl; [SerializeField] ScrollerController m_ShopSecondCtrl; [SerializeField] GameObject m_FollowStoreBottom; [SerializeField] Text m_CoinsType1; [SerializeField] Text m_CoinsType2; @@ -50,7 +51,9 @@ protected override void AddListeners() { m_ShopCtrl.OnRefreshCell += RefreshShopCell; m_ShopSecondCtrl.OnRefreshCell += RefreshShopSecondCell; m_ShopCtrl.lockType = EnhanceLockType.KeepVertical; m_ShopSecondCtrl.lockType = EnhanceLockType.KeepVertical; m_DayStoreTitle.SetListener(OpenDayStore); m_WeekStoreTitle.SetListener(OpenMysteryStore); @@ -71,6 +74,7 @@ model.RefreshTCBPlayerDataEvent += OnRefreshPlayerInfo; model.RefreshBuyShopLimitEvent += OnCreate; model.mysteryShopRefreshEvent += OnCreate; model.selectClassifyRefresh += OnSecondTypeRefresh; GlobalTimeEvent.Instance.secondEvent += UpdateRefreshTime; RefreshCoins(); UpdateRefreshTime(); @@ -123,6 +127,7 @@ model.storeFuncType = StoreFunc.DayStore; model.RefreshBuyShopLimitEvent -= OnCreate; model.mysteryShopRefreshEvent -= OnCreate; model.selectClassifyRefresh -= OnSecondTypeRefresh; GlobalTimeEvent.Instance.secondEvent -= UpdateRefreshTime; model.RefreshTCBPlayerDataEvent -= OnRefreshPlayerInfo; } @@ -140,7 +145,7 @@ { if (model.jumpToItemId != 0) { var p_shopItemlist = model.TryGetStoreDatas(model.storeFuncType); var p_shopItemlist = model.TryGetStoreDatasBySecondType((int)model.storeFuncType, model.selectSecondType); for (int i = 0; i < p_shopItemlist.Count; i++) { var storeData = p_shopItemlist[i]; @@ -170,7 +175,7 @@ { if (commodities == null || commodities.Count < 1) { commodities = model.TryGetStoreDatas(model.storeFuncType); commodities = model.TryGetStoreDatasBySecondType((int)model.storeFuncType, model.selectSecondType); } if (commodities == null || commodities.Count == 0) @@ -248,10 +253,28 @@ m_CoinsType3.text = UIHelper.ReplaceXianYuanCoinsNum(UIHelper.GetMoneyCnt(17)); } private void OnSecondTypeRefresh() { OnCreate(); m_ShopSecondCtrl.m_Scorller.RefreshActiveCellViews(); } private void OnCreateSecondType() { var arrayList = model.GetStoreSecondTypeList((int)model.storeFuncType); m_ShopSecondCtrl.Refresh(); foreach(int secondType in arrayList) { m_ShopSecondCtrl.AddCell(ScrollerDataType.Header, secondType); } m_ShopSecondCtrl.Restart(); } private void OnCreate() { shopId = 0; commodities = model.TryGetStoreDatas(model.storeFuncType); commodities = model.TryGetStoreDatasBySecondType((int)model.storeFuncType, model.selectSecondType); m_ShopCtrl.Refresh(); if (commodities.Count > 0) { @@ -268,7 +291,7 @@ } } m_ShopCtrl.Restart(); m_ShopCtrl.JumpIndex(0); //m_ShopCtrl.JumpIndex(0); RefreshUI(); } @@ -287,6 +310,11 @@ default: break; } } private void RefreshShopSecondCell(ScrollerDataType type, CellView cell) { var secondCell = cell as ShopSecondCell; secondCell.Display(secondCell.index); } private void RefreshShopCell(ScrollerDataType type, CellView cell) @@ -318,6 +346,8 @@ { shopItemCell.stateImage.gameObject.SetActive(false); } shopItemCell.buyOnceText.gameObject.SetActive(false); var config = ItemConfig.Get(model.GetReplaceId(shopInfo.ID, shopInfo.ItemID)); if (config != null) @@ -352,6 +382,17 @@ isShowBuyPrice = false; } } else if (PlayerDatas.Instance.baseData.LV < shopInfo.LV) { //等级购买限制 shopItemCell.coinsIcon.gameObject.SetActive(false); shopItemCell.vipText.gameObject.SetActive(true); shopItemCell.vipText.text = Language.Get("StoreWin115", shopInfo.LV); shopItemCell.sellImage.gameObject.SetActive(false); shopItemCell.itemNameText.color = UIHelper.GetUIColor(TextColType.Red, true); shopItemCell.vipText.color = UIHelper.GetUIColor(TextColType.Red, true); isShowBuyPrice = false; } if (isShowBuyPrice) { @@ -360,6 +401,7 @@ shopItemCell.sellImage.gameObject.SetActive(false); shopItemCell.itemCell.countText.gameObject.SetActive(false); int buyCntYet = canBuyCnt; if (canBuyCnt > 0) { shopItemCell.itemCell.countText.gameObject.SetActive(true); @@ -368,7 +410,13 @@ if (shopItemLimit != null) { remainNum = canBuyCnt - shopItemLimit.BuyCnt; buyCntYet = shopItemLimit.BuyCnt; } else { buyCntYet = 0; } if (shopInfo.ShopType == (int)StoreFunc.MysteryStore) { @@ -377,7 +425,7 @@ else { var remainNumDescription = remainNum > 0 ? remainNum.ToString() : UIHelper.AppendColor(TextColType.Red, remainNum.ToString()); shopItemCell.itemCell.countText.text = StringUtility.Contact(remainNumDescription, "/", canBuyCnt); shopItemCell.itemCell.countText.text = shopInfo.TheOnlyShop == 1 ? "" : StringUtility.Contact(remainNumDescription, "/", canBuyCnt); } if (remainNum > 0) @@ -389,6 +437,12 @@ shopItemCell.sellImage.gameObject.SetActive(true); shopItemCell.stateImage.gameObject.SetActive(false); } } if (shopInfo.TheOnlyShop == 1) { shopItemCell.buyOnceText.gameObject.SetActive(true); shopItemCell.buyOnceText.text = Language.Get("StoreWin116", buyCntYet, canBuyCnt); } shopItemCell.itemNameText.color = UIHelper.GetUIColor(config.ItemColor, true); @@ -421,6 +475,8 @@ { model.CloseAllRedpoint(StoreFunc.IntegralStore); model.storeFuncType = StoreFunc.IntegralStore; OnCreateSecondType(); model.selectSecondType = model.GetFirstStoreSecondType((int)model.storeFuncType); OnCreate(); UpdateRefreshTime(); functionOrder = m_IntegralStoreTitle.order; @@ -439,6 +495,8 @@ { model.CloseAllRedpoint(StoreFunc.GrowStrongerStore); model.storeFuncType = StoreFunc.GrowStrongerStore; OnCreateSecondType(); model.selectSecondType = model.GetFirstStoreSecondType((int)model.storeFuncType); OnCreate(); UpdateRefreshTime(); functionOrder = m_GrowStrongerStoreTitle.order; @@ -448,6 +506,8 @@ { model.CloseAllRedpoint(StoreFunc.CommonStore); model.storeFuncType = StoreFunc.CommonStore; OnCreateSecondType(); model.selectSecondType = model.GetFirstStoreSecondType((int)model.storeFuncType); OnCreate(); UpdateRefreshTime(); functionOrder = m_CommonStoreTitle.order; @@ -466,6 +526,8 @@ { model.CloseAllRedpoint(StoreFunc.DayStore); model.storeFuncType = StoreFunc.DayStore; OnCreateSecondType(); model.selectSecondType = model.GetFirstStoreSecondType((int)model.storeFuncType); OnCreate(); UpdateRefreshTime(); functionOrder = m_DayStoreTitle.order;