| Core/GameEngine/Model/TelPartialConfig/tagStoreConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/BlastFurnace/DanDrugRecycleTip.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/BlastFurnace/DanDrugShopCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/HappyXB/HappyXBModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/HappyXB/XBShopCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/HappyXB/XBStoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/KnapSack/FBHelpPointExchageModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/MainInterfacePanel/HighSettingTip.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/BagStoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/RuneStoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/StoreModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/StoreUIBasic.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/StoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Store/UnionStoreWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Core/GameEngine/Model/TelPartialConfig/tagStoreConfig.cs
@@ -6,51 +6,11 @@ public partial class StoreConfig : ConfigBase, IConfigPostProcess { private static Dictionary<int, List<StoreConfig>> s_storeModelDict = new Dictionary<int, List<StoreConfig>>();//用于记录商城数据 private static Dictionary<string, List<StoreConfig>> s_canBuyShopDict = new Dictionary<string, List<StoreConfig>>(); //用于存储可以购买的商品 private static Dictionary<StoreItem, StoreConfig> s_StoreItemDict = new Dictionary<StoreItem, StoreConfig>(); private static Dictionary<int, List<StoreConfig>> s_TheOnlyShopDict = new Dictionary<int, List<StoreConfig>>(); //key 唯一商品的物品id private static Dictionary<int, List<StoreConfig>> storeConfigs = new Dictionary<int, List<StoreConfig>>(); public void OnConfigParseCompleted() { if (ShopType == 0) return; if (!s_storeModelDict.ContainsKey(ShopType)) { List<StoreConfig> modellist = new List<StoreConfig>(); modellist.Add(this); s_storeModelDict.Add(ShopType, modellist); } else { s_storeModelDict[ShopType].Add(this); } var key = StringUtility.Contact(ShopType, LimitValue).ToString(); if (!s_canBuyShopDict.ContainsKey(key)) { List<StoreConfig> modellist = new List<StoreConfig>(); modellist.Add(this); s_canBuyShopDict.Add(key, modellist); } else { s_canBuyShopDict[key].Add(this); } if (TheOnlyShop == 1) { if (!s_TheOnlyShopDict.ContainsKey(ItemID)) { List<StoreConfig> modellist = new List<StoreConfig>(); modellist.Add(this); s_TheOnlyShopDict.Add(ItemID, modellist); } else { s_TheOnlyShopDict[ItemID].Add(this); } } var _storeItem = new StoreItem() { @@ -69,203 +29,6 @@ storeConfigs.Add(ShopType, list); } list.Add(this); } private static List<StoreConfig> modellist = new List<StoreConfig>(); public static List<StoreConfig> GetTypeStoreModel(int type, bool _keepOld = false) { modellist.Clear(); if (s_storeModelDict.ContainsKey(type)) { for (int i = 0; i < s_storeModelDict[type].Count; i++) { if (PlayerDatas.Instance.baseData.LV >= s_storeModelDict[type][i].LV) { StoreConfig storeConfig = s_storeModelDict[type][i]; //等于1隐藏 if (storeConfig.TheOnlyShop == 1) { bool isSellOut = false; if (s_TheOnlyShopDict.ContainsKey(storeConfig.ItemID)) { List<StoreConfig> storelist = s_TheOnlyShopDict[storeConfig.ItemID]; for (int j = 0; j < storelist.Count; j++) { int remainCnt = 0; if (CheckShopIsSellOut(storelist[j], out remainCnt)) { isSellOut = true; break; } } } if (!isSellOut) { modellist.Add(storeConfig); } } else { if (storeConfig.IsHideSellOut != 1) { switch (storeConfig.ShopType) { case 12: if (CheckRuneStoreIsCanBuy(storeConfig)) { modellist.Add(storeConfig); } break; default: modellist.Add(storeConfig); break; } } else { int remainCnt = 0; switch (storeConfig.ShopType) { case 12: if (CheckRuneStoreIsCanBuy(storeConfig) && !CheckShopIsSellOut(storeConfig, out remainCnt)) { modellist.Add(storeConfig); } break; default: if (!CheckShopIsSellOut(storeConfig, out remainCnt)) { modellist.Add(storeConfig); } break; } } } } } } List<StoreConfig> sortlist = new List<StoreConfig>(); sortlist.AddRange(modellist); sortlist.Sort(CompareByShopSort); return sortlist; } public static bool CheckShopIsSellOut(StoreConfig storeConfig,out int remainCnt) { int canBuyCnt = 0; int addBuyCnt = 0; remainCnt = 0; bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt); BuyShopItemLimit shopItemLimit = ModelCenter.Instance.GetModel<StoreModel>().GetBuyShopLimit((uint)storeConfig.ID); if (!isLimitBuy) return false; if(shopItemLimit != null) { remainCnt = canBuyCnt - shopItemLimit.BuyCnt; if (canBuyCnt <= shopItemLimit.BuyCnt) { return true; } } return false; } public static bool CheckRuneStoreIsCanBuy(StoreConfig storeConfig) { Dictionary<int, List<int>> unlockRunelist = ModelCenter.Instance.GetModel<RuneModel>().GetAllUnlockRuneIdlist(); if(unlockRunelist != null) { foreach (var tower in unlockRunelist.Keys) { if(unlockRunelist[tower].Contains(storeConfig.ItemID)) { return true; } } } return false; } public static int CompareByShopSort(StoreConfig start, StoreConfig end) { int sort1 = start.ShopSort; int sort2 = end.ShopSort; if (sort1.CompareTo(sort2) != 0) return sort1.CompareTo(sort2); sort1 = modellist.IndexOf(start); sort2 = modellist.IndexOf(end); if (sort1.CompareTo(sort2) != 0) return sort1.CompareTo(sort2); return 0; } public static List<StoreConfig> GetSellShoplist() { List<StoreConfig> modellist = new List<StoreConfig>(); foreach (var type in s_storeModelDict.Keys) { if (type <= 5) { List<StoreConfig> list = GetTypeStoreModel(type); modellist.AddRange(list); } } return modellist; } public static List<StoreConfig> GetAllShoplist() { List<StoreConfig> modellist = new List<StoreConfig>(); foreach (var type in s_storeModelDict.Keys) { if (type <= 5) { modellist.AddRange(s_storeModelDict[type]); } } return modellist; } public static List<StoreConfig> GetCanBuyShopModel(int type, int limitValue) { List<StoreConfig> modellist = new List<StoreConfig>(); string id = StringUtility.Contact(type, limitValue).ToString(); if (s_canBuyShopDict.ContainsKey(id)) { for (int i = 0; i < s_canBuyShopDict[id].Count; i++) { if (PlayerDatas.Instance.baseData.LV >= s_canBuyShopDict[id][i].LV) { modellist.Add(s_canBuyShopDict[id][i]); } } } return modellist; } public static Dictionary<int, List<StoreConfig>> GetTheOnlyShopDict() { return s_TheOnlyShopDict; } public static StoreConfig GetDetailStoreModel(int shopType, int moneyType, int itemID) { List<StoreConfig> list = GetTypeStoreModel(shopType); if (list != null) { for (int i = 0; i < list.Count; i++) { if (list[i].MoneyType == moneyType && list[i].ItemID == itemID) { return list[i]; } } } return null; } public static StoreConfig GetStoreCfg(int _item, int _moneyType) System/BlastFurnace/DanDrugRecycleTip.cs
@@ -19,7 +19,7 @@ [Header("回收丹药格子数")] [SerializeField] int sumGridCnt = 45; List<StoreConfig> shoplist; List<StoreModel.StoreData> shoplist; int SingleLineCnt = 2; StoreModel _storeModel; StoreModel m_storeModel @@ -78,14 +78,14 @@ { if (shoplist != null && shoplist.Count > 0) { if (shoplist[0].RefreshType == 0) if (shoplist[0].storeConfig.RefreshType == 0) { _resetRefreshTimeText.gameObject.SetActive(false); } else { _resetRefreshTimeText.gameObject.SetActive(true); _resetRefreshTimeText.text = m_storeModel.GetStoreRefreshTimeByType(shoplist[0].RefreshType); _resetRefreshTimeText.text = m_storeModel.GetStoreRefreshTimeByType(shoplist[0].storeConfig.RefreshType); } } else @@ -117,7 +117,7 @@ private void CreateShopCell() { shopCtrl.Refresh(); shoplist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); shoplist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); if (shoplist.Count > 0) { int i = 0; @@ -148,7 +148,7 @@ if (shoplist.Count >= cellCount) { shopCell.gameObject.SetActive(true); shopCell.SetModel(shoplist[cellCount - 1]); shopCell.SetModel(shoplist[cellCount - 1].storeConfig); } else { System/BlastFurnace/DanDrugShopCell.cs
@@ -21,7 +21,7 @@ ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } } public void SetModel(StoreConfig storeConfig) { ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(m_storeModel.ReplaceItemIdByJob(storeConfig.ID, storeConfig.ItemID)); ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(m_storeModel.GetReplaceId(storeConfig.ID)); if (itemConfig == null) return; ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, 0, storeConfig.IsBind); System/HappyXB/HappyXBModel.cs
@@ -954,7 +954,7 @@ XBStoreRedPoint(); } private List<StoreConfig> storelist = null; private List<StoreModel.StoreData> storelist = null; public void XBStoreRedPoint() { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.HappyFindTreasure)) return; @@ -962,13 +962,13 @@ ulong moneyNum = UIHelper.GetMoneyCnt(25); for(int i = 11; i < 14; i++) { storelist = StoreConfig.GetTypeStoreModel(i); storelist = m_storeModel.TryGetStoreDatas(i); if(storelist.Count > 0) { List<StoreConfig> orderlist = new List<StoreConfig>(); List<StoreModel.StoreData> orderlist = new List<StoreModel.StoreData>(); orderlist.AddRange(storelist); orderlist.Sort(CompareByMoney); if(moneyNum >= (ulong)orderlist[0].MoneyNumber) if(moneyNum >= (ulong)orderlist[0].storeConfig.MoneyNumber) { xbStoreRed.state = RedPointState.Simple; return; @@ -978,10 +978,10 @@ xbStoreRed.state = RedPointState.None; } public int CompareByMoney(StoreConfig start, StoreConfig end) public int CompareByMoney(StoreModel.StoreData start, StoreModel.StoreData end) { int money1 = start.MoneyNumber; int money2 = end.MoneyNumber; int money1 = start.storeConfig.MoneyNumber; int money2 = end.storeConfig.MoneyNumber; if (money1.CompareTo(money2) != 0) return money1.CompareTo(money2); int index1 = storelist.IndexOf(start); int index2 = storelist.IndexOf(end); System/HappyXB/XBShopCell.cs
@@ -21,7 +21,7 @@ ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } } public void SetModel(StoreConfig storeConfig) { ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(m_storeModel.ReplaceItemIdByJob(storeConfig.ID, storeConfig.ItemID)); ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(m_storeModel.GetReplaceId(storeConfig.ID)); if (itemConfig == null) return; ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, 0, storeConfig.IsBind); System/HappyXB/XBStoreWin.cs
@@ -22,7 +22,7 @@ PackModelInterface modelInterface { get { return ModelCenter.Instance.GetModel<PackModelInterface>(); } } List<StoreConfig> shoplist; List<StoreModel.StoreData> shoplist; int SingleLineCnt = 2; protected override void BindController() @@ -110,7 +110,7 @@ private void CreateShopCell() { shopCtrl.Refresh(); shoplist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); shoplist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); if (shoplist.Count > 0) { int i = 0; @@ -141,7 +141,7 @@ if(shoplist.Count >= cellCount) { shopCell.gameObject.SetActive(true); shopCell.SetModel(shoplist[cellCount-1]); shopCell.SetModel(shoplist[cellCount-1].storeConfig); } else { System/KnapSack/FBHelpPointExchageModel.cs
@@ -128,7 +128,9 @@ for(int i = 0; i < helpPointShoplist.Count; i++) { var shopId = helpPointShoplist[i]; if (!CheckShopIsCanBuy(shopId)) StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopId); int remainNum = 0; if (storeModel.TryGetIsSellOut(storeConfig,out remainNum)) { RemoveHelpPointShop(shopId); } @@ -180,28 +182,6 @@ break; } return true; } public bool CheckShopIsCanBuy(int shopId) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopId); if (storeConfig == null) return false; int canBuyCnt = 0; int addBuyCnt = 0; bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt); BuyShopItemLimit shopItemLimit = storeModel.GetBuyShopLimit((uint)storeConfig.ID); int remainNum = canBuyCnt; if (shopItemLimit != null) { remainNum -= shopItemLimit.BuyCnt; } List<StoreConfig> list = StoreConfig.GetSellShoplist(); if (remainNum > 0 && list.Contains(storeConfig)) { return true; } return false; } } } System/MainInterfacePanel/HighSettingTip.cs
@@ -427,13 +427,15 @@ private void RefreshStoreEffect() { storeDesBtn.gameObject.SetActive(false); int limitLv = int.Parse(Config.Instance.Get<FuncConfigConfig>("MallPush").Numerical1); if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store) || PlayerDatas.Instance.baseData.LV < limitLv) || PlayerDatas.Instance.baseData.LV < storeModel.storeTrailerLv || !storeModel.IsNewDay(storeModel.StoreEffectRecord_Key)) return; List<StoreConfig> shoplist = ModelCenter.Instance.GetModel<StoreModel>().shoplist; if (shoplist.Count > 0 && !m_StoreEffect.IsPlaying) var storeDatas = storeModel.TryGetStoreDatas((int)StoreFunc.WeekStore); if (storeDatas != null && storeDatas.Count > 0 && !m_StoreEffect.IsPlaying) { if (isNeedTip) { @@ -447,7 +449,7 @@ } m_StoreEffect.Play(); } else if (shoplist.Count <= 0 && m_StoreEffect.IsPlaying) else { m_StoreEffect.StopImediatly(); } System/Store/BagStoreWin.cs
@@ -85,12 +85,13 @@ SuccessConfig successConfig = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId); if (successConfig.Type == 96) { p_shopItemlist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); p_shopItemlist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); for (int i = 0; i < p_shopItemlist.Count; i++) { if (p_shopItemlist[i].ItemID == m_storeModel.jumpToItemId) var storeData = p_shopItemlist[i]; if (storeData.storeConfig.ItemID == m_storeModel.jumpToItemId) { shopId = p_shopItemlist[i].ID; shopId = storeData.shopId; int index = i / 2; _shopCtrl.JumpIndex(index); _shopCtrl.m_Scorller.RefreshActiveCellViews(); @@ -127,7 +128,7 @@ if (p_shopItemlist.Count >= cellCount) { StoreConfig shopInfo = p_shopItemlist[cellCount - 1]; StoreConfig shopInfo = p_shopItemlist[cellCount - 1].storeConfig; cell.transform.GetChild(childCode).gameObject.SetActive(true); if (shopInfo.SalesStatus.Trim() != "") { @@ -140,7 +141,7 @@ shopItemCell.stateImage.gameObject.SetActive(false); } ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.ReplaceItemIdByJob(shopInfo.ID, shopInfo.ItemID)); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.GetReplaceId(shopInfo.ID)); if (chinModel != null) { ItemCellModel cellModel = new ItemCellModel(chinModel.ID, true, 0, shopInfo.IsBind); System/Store/RuneStoreWin.cs
@@ -1,170 +1,170 @@ //-------------------------------------------------------- // [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<RuneModel>()); } } StoreModel _storeModel; StoreModel m_storeModel { get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); } } PackModelInterface _modelInterface; PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } } #region Built-in protected override void BindController() { _runeCtrl = transform.Find("RuneCellCtrl").GetComponent<ScrollerController>(); _runeChipText = transform.Find("RuneBottom/BindChipsCountBG/CountText").GetComponent<Text>(); _runeCtrl.OnRefreshCell += RefreshShopCell; } protected override void AddListeners() { } protected override void OnPreOpen() { m_storeModel.RefreshBuyShopLimitEvent += InitModel; model.OnRefreshRuneChip += OnFrenshMoneyInfo; _tagFuncModel = Config.Instance.Get<FuncConfigConfig>("RuneShop"); m_storeModel.storeFuncType = StoreFunc.RuneStore; InitModel(); OnFrenshMoneyInfo(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { } protected override void OnAfterClose() //-------------------------------------------------------- // [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<RuneModel>()); } } StoreModel _storeModel; StoreModel m_storeModel { m_storeModel.RefreshBuyShopLimitEvent -= InitModel; runemodel.OnRefreshRuneChip -= OnFrenshMoneyInfo; } #endregion RuneModel m_Model; RuneModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RuneModel>()); } } 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<RuneCell>(); if (runeCell == null) { runeCell = cell.transform.GetChild(childCode).gameObject.AddComponent<RuneCell>(); } if (p_shopItemlist.Count >= cellCount) { StoreConfig shopInfo = p_shopItemlist[cellCount - 1]; cell.transform.GetChild(childCode).gameObject.SetActive(true); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(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<RuneTowerConfig>(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"; } } } } get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); } } PackModelInterface _modelInterface; PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } } #region Built-in protected override void BindController() { _runeCtrl = transform.Find("RuneCellCtrl").GetComponent<ScrollerController>(); _runeChipText = transform.Find("RuneBottom/BindChipsCountBG/CountText").GetComponent<Text>(); _runeCtrl.OnRefreshCell += RefreshShopCell; } protected override void AddListeners() { } protected override void OnPreOpen() { m_storeModel.RefreshBuyShopLimitEvent += InitModel; model.OnRefreshRuneChip += OnFrenshMoneyInfo; _tagFuncModel = Config.Instance.Get<FuncConfigConfig>("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<RuneModel>()); } } 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<RuneCell>(); if (runeCell == null) { runeCell = cell.transform.GetChild(childCode).gameObject.AddComponent<RuneCell>(); } if (p_shopItemlist.Count >= cellCount) { StoreConfig shopInfo = p_shopItemlist[cellCount - 1].storeConfig; cell.transform.GetChild(childCode).gameObject.SetActive(true); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(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<RuneTowerConfig>(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"; } } } } System/Store/StoreModel.cs
@@ -35,15 +35,31 @@ public string UNIONSTORESAVE_KEY { get; private set; } public string MUSTBUYSAVE_KEY { get; private set; } public string StoreEffectRecord_Key { get; private set; } public List<StoreConfig> shoplist; public Dictionary<int,Dictionary<int,int>> JobReplaceIdDict = new Dictionary<int, Dictionary<int, int>>(); public Dictionary<int, string> resetTimeDict { get; private set; } public Dictionary<int, int> showCoinsUIDict { get; private set; } public int[] StoreRedIdlist { get; private set;} public int storeTrailerLv { get; private set; } bool isLogin = true; RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } } ItemTipsModel _itemTipsModel; ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); } } public override void Init() { PlayerPrefs.DeleteAll(); ParseFuncConfig(); ParseStoreConfig(); SetShopRedpoint(); FuncConfigConfig buyItemHinit = Config.Instance.Get<FuncConfigConfig>("BuyItemHinit"); normalBuyCoinsTypes = ConfigParse.GetMultipleStr<int>(buyItemHinit.Numerical1); FuncConfigConfig restTimeConfig = Config.Instance.Get<FuncConfigConfig>("RefreshText"); @@ -52,6 +68,7 @@ showCoinsUIDict = ConfigParse.GetDic<int, int>(mallCurrency.Numerical1); FuncConfigConfig mallPush = Config.Instance.Get<FuncConfigConfig>("MallPush"); StoreRedIdlist = ConfigParse.GetMultipleStr<int>(mallPush.Numerical2); storeTrailerLv = int.Parse(mallPush.Numerical1); MainInterfaceWin.IsCopyOfThePanel += OnMoveTopPart; } @@ -96,17 +113,19 @@ WindowCenter.Instance.windowAfterOpenEvent += windowAfterOpen; WindowCenter.Instance.windowAfterCloseEvent += windowAfterClose; NewBieCenter.Instance.guideBeginEvent += GuidBegin; UpdateShowStore(); SetIsMustBuyDay(); shoplist = null; CheckWeekStoreIsShopBuy(out shoplist); ControllerRedPoint(); SetShopRedpoint(); UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); SetJobReplaceIDDict(); UpdateMustBuyRedpoint(); UpdatePetAndMountPutAwayRedpoint(); isLogin = false; } public override void UnInit() { MainInterfaceWin.IsCopyOfThePanel -= OnMoveTopPart; } #region 解析本地数据 @@ -165,25 +184,59 @@ } } public Dictionary<int,List<StoreConfig>> storeTypeDict { get; private set; } public Dictionary<int,List<StoreData>> storeTypeDict { get; private set; } public Dictionary<int, List<StoreData>> theOnlyShopDict { get; private set; } //key 物品id public Dictionary<string, List<StoreData>> limitValueShopDict { get; private set; } //key 商品类型和限制条件 private void ParseStoreConfig() { storeTypeDict = new Dictionary<int, List<StoreConfig>>(); storeTypeDict = new Dictionary<int, List<StoreData>>(); theOnlyShopDict = new Dictionary<int, List<StoreData>>(); limitValueShopDict = new Dictionary<string, List<StoreData>>(); List<StoreConfig> storeConfigs = Config.Instance.GetAllValues<StoreConfig>(); for(int i = 0; i < storeConfigs.Count; i++) { var config = storeConfigs[i]; if(config.ShopType != 0) { if(!storeTypeDict.ContainsKey(config.ShopType)) StoreData storeData = new StoreData(); storeData.shopId = config.ID; storeData.storeConfig = config; storeData.jobReplaceDict = AnalysisJobReplace(config); if (!storeTypeDict.ContainsKey(config.ShopType)) { List<StoreConfig> configs = new List<StoreConfig>(); configs.Add(config); storeTypeDict.Add(config.ShopType,configs); List<StoreData> storeDatas = new List<StoreData>(); storeDatas.Add(storeData); storeTypeDict.Add(config.ShopType, storeDatas); } else { storeTypeDict[config.ShopType].Add(config); storeTypeDict[config.ShopType].Add(storeData); } if (config.TheOnlyShop == 1) { if (!theOnlyShopDict.ContainsKey(config.ItemID)) { List<StoreData> storeDatas = new List<StoreData>(); storeDatas.Add(storeData); theOnlyShopDict.Add(config.ItemID, storeDatas); } else { theOnlyShopDict[config.ItemID].Add(storeData); } } string key = StringUtility.Contact(config.ShopType,config.LimitValue); if(!limitValueShopDict.ContainsKey(key)) { List<StoreData> storeDatas = new List<StoreData>(); storeDatas.Add(storeData); limitValueShopDict.Add(key,storeDatas); } else { limitValueShopDict[key].Add(storeData); } } } @@ -195,17 +248,187 @@ } } public int CompareByShopSort(StoreConfig start, StoreConfig end) private Dictionary<int,List<int>> AnalysisJobReplace(StoreConfig storeConfig) { int sort1 = start.ShopSort; int sort2 = end.ShopSort; if (storeConfig == null || string.IsNullOrEmpty(storeConfig.JobItem)) return null; Dictionary<int,List<int>> replaceDict = new Dictionary<int, List<int>>(); JsonData jsonData = JsonMapper.ToObject(storeConfig.JobItem); if (jsonData.IsArray) { for (int i = 0; i < jsonData.Count; i++) { List<int> idlist = new List<int>(); replaceDict.Add(i, idlist); if (jsonData[i].IsArray) { for (int j = 0; j < jsonData[i].Count; j++) { int itemId = int.Parse(jsonData[i][j].ToString()); idlist.Add(itemId); } } } } return replaceDict; } public int CompareByShopSort(StoreData start, StoreData end) { int sort1 = start.storeConfig.ShopSort; int sort2 = end.storeConfig.ShopSort; if (sort1.CompareTo(sort2) != 0) return sort1.CompareTo(sort2); return 0; } public class StoreData { public int shopId; public StoreConfig storeConfig; public Dictionary<int,List<int>> jobReplaceDict; } #endregion #region 获取数据 private Dictionary<int, List<StoreData>> showStoreTypeDict = new Dictionary<int, List<StoreData>>(); public void UpdateShowStore() { showStoreTypeDict.Clear(); int playeLv = PlayerDatas.Instance.baseData.LV; foreach (var type in storeTypeDict.Keys) { var storeDatas = storeTypeDict[type]; List<StoreData> showStoreDatas = new List<StoreData>(); if (!showStoreTypeDict.ContainsKey(type)) { for (int i = 0; i < storeDatas.Count; i++) { var storeData = storeDatas[i]; bool isReachLv = playeLv >= storeData.storeConfig.LV ? true : false; bool isReachSpec = true; switch (storeData.storeConfig.ShopType) { case 12: isReachSpec = TryGetUnlockRune(storeData.storeConfig.ItemID); break; } bool isReach = isReachSpec && isReachLv; if (isReach) { int remainNum = 0; bool isSellOut = TryGetIsSellOut(storeData.storeConfig, out remainNum); if (storeData.storeConfig.IsHideSellOut != 1) { showStoreDatas.Add(storeData); } else { if (storeData.storeConfig.TheOnlyShop == 1) { if(!CheckTheOnlyShopSellOut(storeData.shopId)) { showStoreDatas.Add(storeData); } } else { if (!isSellOut) { showStoreDatas.Add(storeData); } } } } } showStoreTypeDict.Add(type, showStoreDatas); } } } /// <summary> /// 检测唯一商品是否已售罄 /// </summary> /// <param name="shopIndex"></param> /// <param name="isTheOnlyShop"></param> /// <returns></returns> public bool CheckTheOnlyShopSellOut(int shopIndex) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopIndex); if (storeConfig == null || storeConfig.TheOnlyShop != 1) return false; if (theOnlyShopDict.ContainsKey(storeConfig.ItemID)) { List<StoreData> datas = theOnlyShopDict[storeConfig.ItemID]; for (int i = 0; i < datas.Count; i++) { var data = datas[i]; int remainNum = 0; if (TryGetIsSellOut(data.storeConfig, out remainNum)) { return true; } } } return false; } public List<StoreData> TryGetStoreDatas(int type) { List<StoreData> datas = null; showStoreTypeDict.TryGetValue(type,out datas); return datas; } public StoreData GetStoreData(int shopId) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopId); if (storeConfig == null) return null; List<StoreData> storeDatas = null; storeTypeDict.TryGetValue(storeConfig.ShopType, out storeDatas); if (storeDatas != null) { for(int i = 0; i < storeDatas.Count; i++) { var storeData = storeDatas[i]; if(storeData.shopId == shopId) { return storeData; } } } return null; } public int GetReplaceId(int shopId) { var storeData = GetStoreData(shopId); if (storeData == null) return 0; StoreConfig config = Config.Instance.Get<StoreConfig>(shopId); int job = PlayerDatas.Instance.baseData.Job; var replaceDict = storeData.jobReplaceDict; if(replaceDict != null) { foreach (var index in replaceDict.Keys) { var idlist = replaceDict[index]; if (idlist.Contains(config.ItemID)) { int replaceIndex = job - 1; return idlist[replaceIndex]; } } } return config.ItemID; } public bool TryGetRedTypeByShopId(int shopId, out int type) { type = 0; @@ -236,30 +459,6 @@ return false; } private Dictionary<int, List<StoreConfig>> showStoreTypeDict = new Dictionary<int, List<StoreConfig>>(); public void UpdateShowStore() { showStoreTypeDict.Clear(); foreach(var type in storeTypeDict.Keys) { var configs = storeTypeDict[type]; List<StoreConfig> showConfigs = new List<StoreConfig>(); if(!showStoreTypeDict.ContainsKey(type)) { for (int i = 0; i < configs.Count; i++) { var config = configs[i]; int remainNum = 0; bool isSellOut = TryGetIsSellOut(config, out remainNum); if(isSellOut && config.TheOnlyShop == 1) { } } } } } public bool TryGetIsSellOut(StoreConfig storeConfig, out int remainCnt) { int canBuyCnt = 0; @@ -361,6 +560,30 @@ return isVipBuy; } public bool TryGetUnlockRune(int runeId) { Dictionary<int, List<int>> unlockRunelist = runeModel.GetAllUnlockRuneIdlist(); if (unlockRunelist != null) { foreach (var tower in unlockRunelist.Keys) { if (unlockRunelist[tower].Contains(runeId)) { return true; } } } return false; } public List<StoreData> TryGetStoreDatasByLimit(int type,int limitValue) { string key = StringUtility.Contact(type,limitValue); List<StoreData> datas = null; limitValueShopDict.TryGetValue(key,out datas); return datas; } #endregion public string GetStoreRefreshTimeByType(int type) @@ -372,14 +595,6 @@ case 7: int willRefreshTime = GetWillRefreshTime(); return Language.Get(resetTimeDict[type],UIHelper.AppendStringColor(TextColType.Green, TimeUtility.SecondsToHMS(willRefreshTime),true)); //if(willRefreshTime == 0) //{ // return Language.Get("StoreWin201"); //} //else //{ // return Language.Get(resetTimeDict[type],willRefreshTime); //} default: return Language.Get(resetTimeDict[type]); } @@ -406,6 +621,7 @@ switch(type) { case PlayerDataRefresh.LV: UpdateShowStore(); UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); UpdateMustBuyRedpoint(); @@ -420,84 +636,6 @@ break; } } public override void UnInit() { MainInterfaceWin.IsCopyOfThePanel -= OnMoveTopPart; } ItemTipsModel _itemTipsModel; ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); } } #region 职业替换商品逻辑处理 public void SetJobReplaceIDDict() { JobReplaceIdDict.Clear(); List<StoreConfig> storeConfigs = Config.Instance.GetAllValues<StoreConfig>(); for(int i = 0; i < storeConfigs.Count; i++) { Dictionary<int, int> replaceItemDict = new Dictionary<int, int>(); JobReplaceIdDict.Add(storeConfigs[i].ID,replaceItemDict); AnalysisJobReplace(storeConfigs[i]); List<ShopItemInfo> shopItems = GetShopItemlistByIndex(storeConfigs[i]); for(int j = 0; j < shopItems.Count; j++) { foreach (var index in jobReplaceDic.Keys) { if (jobReplaceDic[index].Contains(shopItems[j].itemId)) { int replaceIndex = PlayerDatas.Instance.baseData.Job - 1; int replaceId = jobReplaceDic[index][replaceIndex]; replaceItemDict.Add(shopItems[j].itemId,replaceId); break; } } } } } Dictionary<int, List<int>> jobReplaceDic = new Dictionary<int, List<int>>(); private void AnalysisJobReplace(StoreConfig storeConfig) { jobReplaceDic.Clear(); JsonData jsonData = JsonMapper.ToObject(storeConfig.JobItem); if (jsonData.IsArray) { for (int i = 0; i < jsonData.Count; i++) { List<int> idlist = new List<int>(); jobReplaceDic.Add(i, idlist); if (jsonData[i].IsArray) { for (int j = 0; j < jsonData[i].Count; j++) { int itemId = int.Parse(jsonData[i][j].ToString()); idlist.Add(itemId); } } } } } public int ReplaceItemIdByJob(int storeId,int itemId) { if(JobReplaceIdDict.ContainsKey(storeId)) { if(JobReplaceIdDict[storeId].ContainsKey(itemId)) { return JobReplaceIdDict[storeId][itemId]; } } return itemId; } #endregion private void RefreshFamilyLv() { @@ -569,6 +707,7 @@ if(!isLogin) { UpdateShowStore(); UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); UpdateMustBuyRedpoint(); @@ -627,16 +766,16 @@ public bool TryGetShopItemInfo(StoreFunc _type, int _id, out List<ShopItemInfo> _shopItems) { _shopItems = null; var _list = StoreConfig.GetTypeStoreModel((int)_type, true); var _list = TryGetStoreDatas((int)_type); var _index = _list.FindIndex((x) => { return x.ID == _id; return x.shopId == _id; }); if (_index == -1) { return false; } _shopItems = GetShopItemlistByIndex(_list[_index]); _shopItems = GetShopItemlistByIndex(_list[_index].storeConfig); return _shopItems != null; } @@ -673,8 +812,8 @@ public void OnClickShopCell(StoreConfig shopInfo) { BuyItemPopModel.Instance.SetModel(shopInfo.ID); //SetOpenBuyType(chinModel); ItemAttrData attrData = new ItemAttrData(ReplaceItemIdByJob(shopInfo.ID,shopInfo.ItemID),true, (ulong)shopInfo.ItemCnt,-1,shopInfo.IsBind,true,PackType.rptDeleted int itemId = GetReplaceId(shopInfo.ID); ItemAttrData attrData = new ItemAttrData(itemId,true, (ulong)shopInfo.ItemCnt,-1,shopInfo.IsBind,true,PackType.rptDeleted ,"",null,ItemTipChildType.Buy); itemTipsModel.SetItemTipsModel(attrData,false); attrData.SetTipsFuncBtn(ItemWinBtnType.buy,(ItemWinBtnType type ,string id) => { OnClickBuyBtn(ItemWinBtnType.buy, shopInfo.ID); }); @@ -692,7 +831,7 @@ StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopId); int curVipIndex = -1; int nextVipIndex = -1; bool isVipBuy = BuyItemPopModel.Instance.CheckIsVipBuy(storeConfig, out curVipIndex, out nextVipIndex); bool isVipBuy = TryGetVipBuy(storeConfig, out curVipIndex, out nextVipIndex); if (shopItemLimit != null) { int remainNum = 0; @@ -773,7 +912,7 @@ StoreConfig tagStore = Config.Instance.Get<StoreConfig>((int)result.ItemIndex); if (tagStore != null) { ItemConfig chinModel = Config.Instance.Get<ItemConfig>(ReplaceItemIdByJob(tagStore.ID, tagStore.ItemID)); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(GetReplaceId(tagStore.ID)); if (!normalBuyCoinsTypes.Contains(tagStore.MoneyType)) { if (tagStore.RemindSuccess == 0) @@ -806,7 +945,7 @@ /// <returns></returns> public bool IsCanBuyItem(int limitTower) { int playerTower = (int)ModelCenter.Instance.GetModel<RuneModel>().RuneTowerOpenLV; int playerTower = (int)runeModel.RuneTowerOpenLV; int offset = playerTower - limitTower; if (offset >= 0) return true; @@ -831,34 +970,75 @@ { jumpToItemId = itemId; } #region 仙盟商店逻辑处理 public event Action StoreFuncOpenAct; private void FuncStateChange(int funcId) { if (funcId != (int)FuncOpenEnum.Store) return; if (StoreFuncOpenAct != null) { StoreFuncOpenAct(); } UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); UpdateMustBuyRedpoint(); UpdatePetAndMountPutAwayRedpoint(); } public bool IsNewDay(string recordKey) { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return false; if (PlayerPrefs.HasKey(recordKey)) { int day = LocalSave.GetInt(recordKey); if(day != TimeUtility.ServerNow.Day) { LocalSave.SetInt(recordKey, TimeUtility.ServerNow.Day); return true; } else { return false; } } else { LocalSave.SetInt(recordKey, TimeUtility.ServerNow.Day); return true; } } #region 商城红点 #region 仙盟红点逻辑处理 private bool CheckIsBuyNewItem(int fairyLv) { if(fairyLv > GetSaveFairyLV()) if (fairyLv > GetSaveFairyLV()) { if (StoreConfig.GetCanBuyShopModel((int)StoreFunc.ToolStore, fairyLv).Count > 0 || StoreConfig.GetCanBuyShopModel((int)StoreFunc.MountStoneStore, fairyLv).Count > 0 || StoreConfig.GetCanBuyShopModel((int)StoreFunc.MountSkillBookStore, fairyLv).Count > 0) var toolStoreDatas = TryGetStoreDatasByLimit((int)StoreFunc.ToolStore, fairyLv); var mountStoreDatas = TryGetStoreDatasByLimit((int)StoreFunc.MountStoneStore, fairyLv); var skillBookStoreData = TryGetStoreDatasByLimit((int)StoreFunc.MountSkillBookStore, fairyLv); if ((toolStoreDatas != null && toolStoreDatas.Count > 0) || (mountStoreDatas != null && mountStoreDatas.Count > 0) || (skillBookStoreData != null && skillBookStoreData.Count > 0)) { return true; } } return false; } private bool CheckIsNewMonth() { GetSaveDateTime(); if(datelist.Count > 0) if (datelist.Count > 0) { if(TimeUtility.ServerNow.Month == datelist[0]) if (TimeUtility.ServerNow.Month == datelist[0]) { if(TimeUtility.ServerNow.Day >= 1 if (TimeUtility.ServerNow.Day >= 1 && TimeUtility.ServerNow.Hour >= 5 && datelist[1] <= 1 && datelist[2] < 5) { @@ -867,7 +1047,7 @@ } else { if(TimeUtility.ServerNow.Day >= 1 if (TimeUtility.ServerNow.Day >= 1 && TimeUtility.ServerNow.Hour >= 5) { return true; @@ -895,7 +1075,7 @@ { int[] unionArray = LocalSave.GetIntArray(UNIONSTORESAVE_KEY); int fairyLv = 0; if(unionArray != null) if (unionArray != null) { return unionArray[0]; } @@ -904,22 +1084,22 @@ //1仙盟等级 2 月份 3 号 4 几点 public void SetStoreLocalSave(LocalSaveStoreType saveStoreType,params int[] infos) public void SetStoreLocalSave(LocalSaveStoreType saveStoreType, params int[] infos) { string key = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, saveStoreType); LocalSave.SetIntArray(key,infos); LocalSave.SetIntArray(key, infos); } public void ControllerRedPoint(bool isLook = false) { MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.None; if(!ModelCenter.Instance.GetModel<FairyModel>().fairyStoreOpen) if (!ModelCenter.Instance.GetModel<FairyModel>().fairyStoreOpen) { return; } int familyLv = PlayerDatas.Instance.fairyData.fairy.FamilyLV; if(!isLook) if (!isLook) { if (CheckIsBuyNewItem(familyLv)) { @@ -940,126 +1120,6 @@ #endregion #endregion public event Action StoreFuncOpenAct; private void FuncStateChange(int funcId) { if (funcId != (int)FuncOpenEnum.Store) return; shoplist = null; CheckWeekStoreIsShopBuy(out shoplist); if(shoplist.Count > 0) { if (StoreFuncOpenAct != null) { StoreFuncOpenAct(); } } SetShopRedpoint(); UpdateFreeShopRedpoint(); UpdateCanBuyRedpoint(); UpdateMustBuyRedpoint(); UpdatePetAndMountPutAwayRedpoint(); } public bool CheckWeekStoreIsShopBuy(out List<StoreConfig> buylist) { buylist = new List<StoreConfig>(); if (!IsNewDay(StoreEffectRecord_Key)) return false; List<StoreConfig> shoplist = StoreConfig.GetTypeStoreModel((int)StoreFunc.WeekStore); for(int i = 0; i < shoplist.Count; i++) { int canBuyCnt = 0; int addBuyCnt = 0; bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(shoplist[i], out canBuyCnt, out addBuyCnt); BuyShopItemLimit shopItemLimit = GetBuyShopLimit((uint)shoplist[i].ID); if (isLimitBuy) { int remainNum = canBuyCnt; if (shopItemLimit != null) { remainNum = canBuyCnt - shopItemLimit.BuyCnt; } if (remainNum > 0) { buylist.Add(shoplist[i]); } } else { buylist.Add(shoplist[i]); } } if(buylist.Count > 0) { return true; } else { return false; } } private bool IsNewDay(string recordKey) { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return false; if (PlayerPrefs.HasKey(recordKey)) { int day = LocalSave.GetInt(recordKey); if(day != TimeUtility.ServerNow.Day) { LocalSave.SetInt(recordKey, TimeUtility.ServerNow.Day); return true; } else { return false; } } else { LocalSave.SetInt(recordKey, TimeUtility.ServerNow.Day); return true; } } /// <summary> /// 检测唯一商品是否已售罄 /// </summary> /// <param name="shopIndex"></param> /// <param name="isTheOnlyShop"></param> /// <returns></returns> public bool CheckTheOnlyShopSellOut(int shopIndex,out bool isTheOnlyShop) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(shopIndex); isTheOnlyShop = false; if (storeConfig == null) return false; if(storeConfig.TheOnlyShop == 1) { if(StoreConfig.GetTheOnlyShopDict().ContainsKey(storeConfig.ItemID)) { List<StoreConfig> storelist = StoreConfig.GetTheOnlyShopDict()[storeConfig.ItemID]; for(int i = 0; i < storelist.Count; i++) { BuyShopItemLimit shoplimit = GetBuyShopLimit((uint)storelist[i].ID); if(shoplimit != null && shoplimit.BuyCnt >= storelist[i].PurchaseNumber[0]) { return true; } } } } return false; } #region 商城红点 public const int StoreFunc_RedKey = 22; public const int StoreFunc1_RedKey = 2201; public const int StoreFunc2_RedKey = 2202; @@ -1076,9 +1136,7 @@ public void SetShopRedpoint() { shopRedDict.Clear(); if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; List<StoreConfig> storelist = StoreConfig.GetAllShoplist(); List<StoreConfig> storelist = Config.Instance.GetAllValues<StoreConfig>(); for(int i = 0; i < storelist.Count; i++) { StoreConfig storeConfig = storelist[i]; @@ -1089,25 +1147,29 @@ case 1: redKey = StoreFunc1_RedKey*10000 + storeConfig.ID; redpoint = new Redpoint(StoreFunc1_RedKey,redKey); shopRedDict.Add(storeConfig.ID, redpoint); break; case 2: redKey = StoreFunc2_RedKey * 10000 + storeConfig.ID; redpoint = new Redpoint(StoreFunc2_RedKey, redKey); shopRedDict.Add(storeConfig.ID,redpoint); break; case 3: redKey = StoreFunc3_RedKey * 10000 + storeConfig.ID; redpoint = new Redpoint(StoreFunc3_RedKey, redKey); shopRedDict.Add(storeConfig.ID, redpoint); break; case 4: redKey = StoreFunc4_RedKey * 10000 + storeConfig.ID; redpoint = new Redpoint(StoreFunc4_RedKey, redKey); shopRedDict.Add(storeConfig.ID, redpoint); break; case 5: redKey = StoreFunc5_RedKey * 10000 + storeConfig.ID; redpoint = new Redpoint(StoreFunc5_RedKey, redKey); shopRedDict.Add(storeConfig.ID, redpoint); break; } shopRedDict.Add(storeConfig.ID,redpoint); } } @@ -1115,20 +1177,26 @@ { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; foreach (var key in shopRedDict.Keys) foreach (var key in showStoreTypeDict.Keys) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(key); if (storeConfig.MoneyNumber == 0) var storeDatas = showStoreTypeDict[key]; for(int i = 0; i < storeDatas.Count; i++) { if (CheckShopIsCanBuy(storeConfig)) var storeConfig = storeDatas[i].storeConfig; if (storeConfig.MoneyNumber == 0) { shopRedDict[storeConfig.ID].state = RedPointState.Simple; } else { shopRedDict[storeConfig.ID].state = RedPointState.None; int remainNum = 0; if (!TryGetIsSellOut(storeConfig, out remainNum)) { shopRedDict[storeConfig.ID].state = RedPointState.Simple; } else { shopRedDict[storeConfig.ID].state = RedPointState.None; } } } } } public event Action<int> UpdateHelpPointExchangeEvent; @@ -1136,22 +1204,31 @@ { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; foreach (var key in shopRedDict.Keys) foreach (var key in showStoreTypeDict.Keys) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(key); if (StoreRedIdlist.Contains(storeConfig.ID)) var storeDatas = showStoreTypeDict[key]; for (int i = 0; i < storeDatas.Count; i++) { if (CheckShopIsCanBuy(storeConfig)) var storeConfig = storeDatas[i].storeConfig; if (StoreRedIdlist.Contains(storeConfig.ID)) { if (UIHelper.GetMoneyCnt(storeConfig.MoneyType) >= (ulong)storeConfig.MoneyNumber) int remainNum = 0; if (!TryGetIsSellOut(storeConfig, out remainNum)) { shopRedDict[storeConfig.ID].state = RedPointState.Simple; if(storeConfig.ShopType == (int)StoreFunc.IntegralStore) if (UIHelper.GetMoneyCnt(storeConfig.MoneyType) >= (ulong)storeConfig.MoneyNumber) { if(UpdateHelpPointExchangeEvent != null) shopRedDict[storeConfig.ID].state = RedPointState.Simple; if (storeConfig.ShopType == (int)StoreFunc.IntegralStore) { UpdateHelpPointExchangeEvent(key); if (UpdateHelpPointExchangeEvent != null) { UpdateHelpPointExchangeEvent(key); } } } else { shopRedDict[storeConfig.ID].state = RedPointState.None; } } else @@ -1159,11 +1236,8 @@ shopRedDict[storeConfig.ID].state = RedPointState.None; } } else { shopRedDict[storeConfig.ID].state = RedPointState.None; } } } } @@ -1171,20 +1245,25 @@ { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; foreach (var key in shopRedDict.Keys) foreach (var key in showStoreTypeDict.Keys) { StoreConfig storeConfig = Config.Instance.Get<StoreConfig>(key); if(mustIdlist.Contains(storeConfig.ItemID)) var storeDatas = showStoreTypeDict[key]; for (int i = 0; i < storeDatas.Count; i++) { if (CheckIsMustBuy(storeConfig)) var storeConfig = storeDatas[i].storeConfig; if (mustIdlist.Contains(storeConfig.ItemID)) { shopRedDict[storeConfig.ID].state = RedPointState.Simple; } else { shopRedDict[storeConfig.ID].state = RedPointState.None; if (CheckIsMustBuy(storeConfig)) { shopRedDict[storeConfig.ID].state = RedPointState.Simple; } else { shopRedDict[storeConfig.ID].state = RedPointState.None; } } } } } @@ -1230,42 +1309,8 @@ public List<int> mustIdlist = new List<int>() { 4741}; public bool CheckIsMustBuy(StoreConfig config) { if(CheckShopIsCanBuy(config) && IsMustBuyDay) { return true; } return false; } public bool CheckScoreStoreIsCanBuy(StoreConfig storeConfig) { List<StoreConfig> list = StoreConfig.GetSellShoplist(); if(StoreRedIdlist.Contains(storeConfig.ID)) { if (CheckShopIsCanBuy(storeConfig)) { if(UIHelper.GetMoneyCnt(storeConfig.MoneyType) >= (ulong)storeConfig.MoneyNumber) { return true; } } } return false; } public bool CheckShopIsCanBuy(StoreConfig storeConfig) { int canBuyCnt = 0; int addBuyCnt = 0; bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt); BuyShopItemLimit shopItemLimit = GetBuyShopLimit((uint)storeConfig.ID); int remainNum = canBuyCnt; if (shopItemLimit != null) { remainNum -= shopItemLimit.BuyCnt; } List<StoreConfig> list = StoreConfig.GetSellShoplist(); if (remainNum > 0 && list.Contains(storeConfig)) int remainNum = 0; if(!TryGetIsSellOut(config,out remainNum) && IsMustBuyDay) { return true; } @@ -1279,34 +1324,36 @@ { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return; List<StoreConfig> storelist = StoreConfig.GetAllShoplist(); List<StoreData> storelist = TryGetStoreDatas((int)StoreFunc.BindStore); if (storelist == null) return; for(int i = 0; i < storelist.Count; i++) { if (storelist[i].ShopType != (int)StoreFunc.BindStore) continue; ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(storelist[i].ItemID); string key = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID,"ShopId",storelist[i].ID); var storeData = storelist[i]; ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(storeData.storeConfig.ItemID); string key = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID,"ShopId",storeData.shopId); int remainNum = 0; switch(itemConfig.Type) { case 26: case 41: if(CheckShopIsCanBuy(storelist[i])) if(!TryGetIsSellOut(storeData.storeConfig,out remainNum)) { if (!PlayerPrefs.HasKey(key)) { shopRedDict[storelist[i].ID].state = RedPointState.Simple; shopRedDict[storeData.shopId].state = RedPointState.Simple; LocalSave.SetBool(key,true); SetPetAndMountPushData(storelist[i].ID); SetPetAndMountPushData(storeData.shopId); } else { if(LocalSave.GetBool(key)) { shopRedDict[storelist[i].ID].state = RedPointState.Simple; shopRedDict[storeData.shopId].state = RedPointState.Simple; } else { shopRedDict[storelist[i].ID].state = RedPointState.None; shopRedDict[storeData.shopId].state = RedPointState.None; } } @@ -1314,7 +1361,7 @@ else { //PlayerPrefs.DeleteKey(key); shopRedDict[storelist[i].ID].state = RedPointState.None; shopRedDict[storeData.shopId].state = RedPointState.None; } break; } System/Store/StoreUIBasic.cs
@@ -16,7 +16,7 @@ { protected RuneConfig p_tagRuneModel; protected List<StoreConfig> p_shopItemlist; protected List<StoreModel.StoreData> p_shopItemlist; StoreModel _storeModel; StoreModel m_storeModel @@ -53,7 +53,7 @@ virtual protected void CreateShopItemCell(ScrollerController shopCtrl,int row) { shopCtrl.Refresh(); p_shopItemlist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); p_shopItemlist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); if (p_shopItemlist.Count > 0) { int i = 0; System/Store/StoreWin.cs
@@ -69,7 +69,7 @@ get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); } } private List<StoreConfig> _tagStoreModellist; private List<StoreModel.StoreData> _tagStoreModellist; private FuncConfigConfig _tagFuncModel1; private FuncConfigConfig _tagFuncModel2; private int shopId = 0; @@ -148,7 +148,6 @@ { m_storeModel.ClearAllPetAndMountRedpoint(StoreFunc.WeekStore); m_storeModel.storeFuncType = StoreFunc.WeekStore; m_storeModel.shoplist.Clear(); m_storeModel.RefreshBuyShopLimitEvent -= OnCreate; GlobalTimeEvent.Instance.secondEvent -= RefreshResetTime; m_storeModel.RefreshTCBPlayerDataEvent -= OnRefreshPlayerInfo; @@ -171,15 +170,15 @@ SuccessConfig successConfig = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId); if(successConfig.Type == 97) { _tagStoreModellist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); List<StoreConfig> orderlist = new List<StoreConfig>(); _tagStoreModellist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); List<StoreModel.StoreData> orderlist = new List<StoreModel.StoreData>(); orderlist.AddRange(_tagStoreModellist); orderlist.Sort(CompareByMoney); for (int i = 0; i < _tagStoreModellist.Count; i++) { if (_tagStoreModellist[i].ID == orderlist[0].ID) if (_tagStoreModellist[i].shopId == orderlist[0].shopId) { shopId = _tagStoreModellist[i].ID; shopId = _tagStoreModellist[i].shopId; int index = i / 2; _shopCtrl.JumpIndex(index); _shopCtrl.m_Scorller.RefreshActiveCellViews(); @@ -193,10 +192,10 @@ { if(m_storeModel.jumpShopId != 0) { _tagStoreModellist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); _tagStoreModellist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); for (int i = 0; i < _tagStoreModellist.Count; i++) { if (_tagStoreModellist[i].ID == m_storeModel.jumpShopId) if (_tagStoreModellist[i].shopId == m_storeModel.jumpShopId) { int index = i / 2 ; _shopCtrl.JumpIndex(index > 2 ? index - 1 : index); @@ -213,28 +212,28 @@ { if(_tagStoreModellist == null || _tagStoreModellist.Count < 1) { _tagStoreModellist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); _tagStoreModellist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); } if(_tagStoreModellist.Count > 0) { if (_tagStoreModellist[0].RefreshType == 0) if (_tagStoreModellist[0].storeConfig.RefreshType == 0) { _resetRefreshTimeText.gameObject.SetActive(false); } else { _resetRefreshTimeText.gameObject.SetActive(true); _resetRefreshTimeText.text = m_storeModel.GetStoreRefreshTimeByType(_tagStoreModellist[0].RefreshType); _resetRefreshTimeText.text = m_storeModel.GetStoreRefreshTimeByType(_tagStoreModellist[0].storeConfig.RefreshType); } } } public int CompareByMoney(StoreConfig start,StoreConfig end) public int CompareByMoney(StoreModel.StoreData start, StoreModel.StoreData end) { int money1 = start.MoneyNumber; int money2 = end.MoneyNumber; int money1 = start.storeConfig.MoneyNumber; int money2 = end.storeConfig.MoneyNumber; if (money1.CompareTo(money2) != 0) return money1.CompareTo(money2); int index1 = _tagStoreModellist.IndexOf(start); int index2 = _tagStoreModellist.IndexOf(end); @@ -247,14 +246,14 @@ if (_tagStoreModellist.Count < 1) return; if(m_storeModel.showCoinsUIDict != null && m_storeModel.showCoinsUIDict.ContainsKey(_tagStoreModellist[0].ShopType)) if(m_storeModel.showCoinsUIDict != null && m_storeModel.showCoinsUIDict.ContainsKey(_tagStoreModellist[0].storeConfig.ShopType)) { if(m_storeModel.showCoinsUIDict[_tagStoreModellist[0].ShopType] == 1) if(m_storeModel.showCoinsUIDict[_tagStoreModellist[0].storeConfig.ShopType] == 1) { _followStoreBottom.gameObject.SetActive(true); _integralBottom.gameObject.SetActive(false); } else if(m_storeModel.showCoinsUIDict[_tagStoreModellist[0].ShopType] == 2) else if(m_storeModel.showCoinsUIDict[_tagStoreModellist[0].storeConfig.ShopType] == 2) { _followStoreBottom.gameObject.SetActive(false); _integralBottom.gameObject.SetActive(true); @@ -273,7 +272,7 @@ private void OnCreate() { shopId = 0; _tagStoreModellist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); _tagStoreModellist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); _shopCtrl.Refresh(); if (_tagStoreModellist.Count > 0) { @@ -322,7 +321,7 @@ if (_tagStoreModellist.Count >= cellCount) { StoreConfig shopInfo = _tagStoreModellist[cellCount - 1]; StoreConfig shopInfo = _tagStoreModellist[cellCount - 1].storeConfig; if(m_storeModel.shopRedDict.ContainsKey(shopInfo.ID)) { shopItemCell.redpoint.redpointId = m_storeModel.shopRedDict[shopInfo.ID].id; @@ -339,7 +338,7 @@ shopItemCell.stateImage.gameObject.SetActive(false); } ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.ReplaceItemIdByJob(shopInfo.ID,shopInfo.ItemID)); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.GetReplaceId(shopInfo.ID)); if(chinModel != null) { ItemCellModel cellModel = new ItemCellModel(chinModel.ID,true,0,shopInfo.IsBind,"",PackType.rptDeleted,true); @@ -435,7 +434,6 @@ private void OnClickIntegralStore() { m_storeModel.ClearAllPetAndMountRedpoint(StoreFunc.IntegralStore); m_storeModel.shoplist.Clear(); m_storeModel.storeFuncType = StoreFunc.IntegralStore; OnCreate(); RefreshResetTime(); @@ -445,7 +443,6 @@ private void OnClickBindStore() { m_storeModel.ClearAllPetAndMountRedpoint(StoreFunc.BindStore); m_storeModel.shoplist.Clear(); m_storeModel.storeFuncType = StoreFunc.BindStore; OnCreate(); RefreshResetTime(); @@ -455,7 +452,6 @@ private void OnClickStrengthStore() { m_storeModel.ClearAllPetAndMountRedpoint(StoreFunc.GrowStrongerStore); m_storeModel.shoplist.Clear(); m_storeModel.storeFuncType = StoreFunc.GrowStrongerStore; OnCreate(); RefreshResetTime(); @@ -465,7 +461,6 @@ private void OnClickCommonStore() { m_storeModel.ClearAllPetAndMountRedpoint(StoreFunc.CommonStore); m_storeModel.shoplist.Clear(); m_storeModel.storeFuncType = StoreFunc.CommonStore; OnCreate(); RefreshResetTime(); System/Store/UnionStoreWin.cs
@@ -113,15 +113,15 @@ SuccessConfig successConfig = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId); if (successConfig.Type == 97) { p_shopItemlist = StoreConfig.GetTypeStoreModel((int)m_storeModel.storeFuncType); List<StoreConfig> orderlist = new List<StoreConfig>(); p_shopItemlist = m_storeModel.TryGetStoreDatas((int)m_storeModel.storeFuncType); List<StoreModel.StoreData> orderlist = new List<StoreModel.StoreData>(); orderlist.AddRange(p_shopItemlist); orderlist.Sort(CompareByMoney); for (int i = 0; i < p_shopItemlist.Count; i++) { if (p_shopItemlist[i].ID == orderlist[0].ID) if (p_shopItemlist[i].shopId == orderlist[0].shopId) { shopId = p_shopItemlist[i].ID; shopId = p_shopItemlist[i].shopId; int index = i / 2; _shopCtrl.JumpIndex(index); _shopCtrl.m_Scorller.RefreshActiveCellViews(); @@ -133,10 +133,10 @@ } } public int CompareByMoney(StoreConfig start, StoreConfig end) public int CompareByMoney(StoreModel.StoreData start, StoreModel.StoreData end) { int money1 = start.MoneyNumber; int money2 = end.MoneyNumber; int money1 = start.storeConfig.MoneyNumber; int money2 = end.storeConfig.MoneyNumber; if (money1.CompareTo(money2) != 0) return money1.CompareTo(money2); int index1 = p_shopItemlist.IndexOf(start); int index2 = p_shopItemlist.IndexOf(end); @@ -180,7 +180,7 @@ if (p_shopItemlist.Count >= cellCount) { StoreConfig shopInfo = p_shopItemlist[cellCount - 1]; StoreConfig shopInfo = p_shopItemlist[cellCount - 1].storeConfig; cell.transform.GetChild(childCode).gameObject.SetActive(true); if (shopInfo.SalesStatus.Trim() != "") { @@ -191,7 +191,7 @@ { shopItemCell.stateImage.gameObject.SetActive(false); } ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.ReplaceItemIdByJob(shopInfo.ID, shopInfo.ItemID)); ItemConfig chinModel = Config.Instance.Get<ItemConfig>(m_storeModel.GetReplaceId(shopInfo.ID)); if (chinModel != null) { ItemCellModel cellModel = new ItemCellModel(chinModel.ID,false, 0, shopInfo.IsBind);