From b0326592b8124fddd28a35e40d37f9415cd3119f Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 04 七月 2025 11:29:16 +0800
Subject: [PATCH] 70 子 【常规】排行榜 / 【常规】排行榜-客户端
---
Main/System/KnapSack/PackManager.cs | 1961 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 983 insertions(+), 978 deletions(-)
diff --git a/Main/System/KnapSack/PackManager.cs b/Main/System/KnapSack/PackManager.cs
index 0dbd7f1..c621633 100644
--- a/Main/System/KnapSack/PackManager.cs
+++ b/Main/System/KnapSack/PackManager.cs
@@ -6,1025 +6,1030 @@
using System.Text.RegularExpressions;
using System.Collections;
- public class PackManager : GameSystemManager<PackManager>
- //public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
+public class PackManager : GameSystemManager<PackManager>
+//public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
+{
+ public static string StrengthAttrShift_RecordKey = "";
+ public const string RecordKnapsackTitle = "RecordKnapsackTitle";
+
+ Dictionary<int, int> DrugToDungeonDict { get; set; } //key 涓硅嵂ID,value鍓湰ID
+ Dictionary<int, int[]> DungeonToDrugDict { get; set; } //key 鍓湰ID,value涓硅嵂ID鍒楄〃
+ //public List<AttrFruitConfig> makeDruglist { get; private set; }
+ Dictionary<int, Dictionary<int, int>> decomposeAttrDict = new Dictionary<int, Dictionary<int, int>>();
+ string RoleEquipLocalSave = "";
+ List<int> LocalSavePlaceArray { get; set; }
+ Dictionary<int, List<int>> sharedUseCountItemDict { get; set; }
+ bool isUpdatePlayerLv = false;
+
+ //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
+ //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
+
+ List<string> commonShowAwardEvents = new List<string>();
+
+ public int[] autoUseItemIDs;
+ public override void Init()
{
- public static string StrengthAttrShift_RecordKey = "";
- public const string RecordKnapsackTitle = "RecordKnapsackTitle";
-
- Dictionary<int, int> DrugToDungeonDict { get; set; } //key 涓硅嵂ID,value鍓湰ID
- Dictionary<int, int[]> DungeonToDrugDict { get; set; } //key 鍓湰ID,value涓硅嵂ID鍒楄〃
- //public List<AttrFruitConfig> makeDruglist { get; private set; }
- Dictionary<int, Dictionary<int, int>> decomposeAttrDict = new Dictionary<int, Dictionary<int, int>>();
- string RoleEquipLocalSave = "";
- List<int> LocalSavePlaceArray { get; set; }
- Dictionary<int, List<int>> sharedUseCountItemDict { get; set; }
- bool isUpdatePlayerLv = false;
-
- //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
- //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
-
- List<string> commonShowAwardEvents = new List<string>();
-
- public int[] autoUseItemIDs;
- public override void Init()
- {
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
- DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
- ParseConfig();
- //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo;
-
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
+ DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
+ ParseConfig();
+ //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo;
+
- // FuncConfigConfig ShareUseCntItem = FuncConfigConfig.Get("ShareUseCntItem");
- // sharedUseCountItemDict = new Dictionary<int, List<int>>();
- // JsonData shareUseJson = JsonMapper.ToObject(ShareUseCntItem.Numerical1);
- // if (shareUseJson.IsArray)
- // {
- // for (int i = 0; i < shareUseJson.Count; i++)
- // {
- // var idListJson = shareUseJson[i];
- // var idlist = new List<int>();
- // sharedUseCountItemDict.Add(i, idlist);
- // foreach (var id in idListJson)
- // {
- // idlist.Add(int.Parse(id.ToString()));
- // }
- // }
- // }
+ // FuncConfigConfig ShareUseCntItem = FuncConfigConfig.Get("ShareUseCntItem");
+ // sharedUseCountItemDict = new Dictionary<int, List<int>>();
+ // JsonData shareUseJson = JsonMapper.ToObject(ShareUseCntItem.Numerical1);
+ // if (shareUseJson.IsArray)
+ // {
+ // for (int i = 0; i < shareUseJson.Count; i++)
+ // {
+ // var idListJson = shareUseJson[i];
+ // var idlist = new List<int>();
+ // sharedUseCountItemDict.Add(i, idlist);
+ // foreach (var id in idListJson)
+ // {
+ // idlist.Add(int.Parse(id.ToString()));
+ // }
+ // }
+ // }
- ParseItemCount();
+ ParseItemCount();
- autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2);
- }
+ autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2);
+ }
- public override void Release()
- {
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+ public override void Release()
+ {
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
+ DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
- // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo;
+ // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo;
+ }
+
+ public Dictionary<int, string> textCountShow = new Dictionary<int, string>();
+ public int[] textCountShow2;
+ public List<int> gameCashShow = new List<int>();
+
+ public void ParseItemCount()
+ {
+ var textConfig = FuncConfigConfig.Get("ItemCountShow");
+ var json = JsonMapper.ToObject(textConfig.Numerical1);
+ foreach (var key in json.Keys)
+ {
+ var itemID = int.Parse(key);
+ textCountShow[itemID] = json[key].ToString();
}
- public Dictionary<int, string> textCountShow = new Dictionary<int, string>();
- public int[] textCountShow2;
- public List<int> gameCashShow = new List<int>();
+ textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2);
+ gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3);
+ }
- public void ParseItemCount()
+
+ private void OnFuncStateChangeEvent(int id)
+ {
+
+ }
+ public void OnBeforePlayerDataInitialize()
+ {
+ GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
+ PlayerDatas.Instance.playerDataRefreshEvent -= UpdatePlayerLv;
+ LocalSave.DeleteKey(RecordKnapsackTitle);
+ playerPackDict.Clear();
+ itemDayUseCntDict.Clear();
+ itemSumUseCntDict.Clear();
+ itemGUIDDict.Clear();
+ isPlayBetterEquipEffect = false;
+ }
+
+ public void OnAfterPlayerDataInitialize()
+ {
+
+ }
+
+ public void OnPlayerLoginOk()
+ {
+ //ItemOperateUtility.Instance.RequestWarehouseData();
+ RoleEquipLocalSave = StringUtility.Contact("RoleEquipLocalSave", PlayerDatas.Instance.baseData.PlayerID);
+ StrengthAttrShift_RecordKey = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "StrengthAttrShift");
+ if (LocalSave.GetIntArray(RoleEquipLocalSave) != null)
{
- var textConfig = FuncConfigConfig.Get("ItemCountShow");
- var json = JsonMapper.ToObject(textConfig.Numerical1);
- foreach (var key in json.Keys)
- {
- var itemID = int.Parse(key);
- textCountShow[itemID] = json[key].ToString();
- }
+ LocalSavePlaceArray = LocalSave.GetIntArray(RoleEquipLocalSave).ToList();
+ }
+ else
+ {
+ LocalSavePlaceArray = null;
+ }
+ GlobalTimeEvent.Instance.secondEvent += UpdateSecond;
+ PlayerDatas.Instance.playerDataRefreshEvent += UpdatePlayerLv;
+ isUpdatePlayerLv = true;
+ FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
+ }
- textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2);
- gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3);
+ private void RefreshSysInfo(string key, ArrayList infolist)
+ {
+ // if (key != "GetMoney") return;
+ // if (ItemLogicUtility.Instance.hidePickItem)
+ // return;
+
+ // if (PlayerDatas.Instance.baseData.LV < 3)
+ // return;
+
+ // var type = 0;
+ // int.TryParse(infolist[0].ToString(), out type);
+ // if (type == 1)
+ // {
+ // Vector3 pos = new Vector3(-100, 0, 0);
+ // Vector3 rot = new Vector3(0, 0, 0);
+ // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
+ // {
+ // pos = new Vector3(0, 50, 0);
+ // rot = new Vector3(180, 180, 0);
+ // }
+ // EffectMgr.Instance.PlayUIEffect(1204, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
+ // }
+ // else if (type == 2)
+ // {
+ // Vector3 pos = new Vector3(-100, 0, 0);
+ // Vector3 rot = new Vector3(0, 0, 0);
+ // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
+ // {
+ // pos = new Vector3(150, 50, 0);
+ // rot = new Vector3(180, 180, 0);
+ // }
+ // lingshiEffect = EffectMgr.Instance.PlayUIEffect(1158, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
+ // }
+ }
+
+ public event Action<PackType> refrechPackEvent; //鍒锋柊鏁翠釜鑳屽寘鏁版嵁
+ public event Action<PackType, int, int> refreshItemCountEvent; // 鎱庣敤浼氬崱锛堝崟涓級鏈�鏂扮墿鍝佹暟閲忓埛鏂�(鏃х殑寮冪敤)鍦ㄥ緱鍒版柊鐗╁搧銆佺墿鍝佹暟閲忕殑鏀瑰彉锛屾竻鐞嗚鐗╁搧鏃跺潎浼氳Е鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<PackType> gridRefreshEvent; //鑳屽寘绌烘牸鍒锋柊
+ public event Action<PackType, int, int> itemCntAddEvent; //鐗╁搧鏁伴噺澧炲姞 int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<PackType, int, int> itemCntReduceEvent; //鐗╁搧鏁伴噺鍑忓皯鐨勬敼鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<int, int> useItemSuccessEvent; //鐗╁搧浣跨敤鎴愬姛 int 浣嶇疆绱㈠紩 int鐗╁搧id
+
+ public event Action<int> refreshItemDayUseCountEvent; //鍒锋柊鐗╁搧姣忔棩浣跨敤鏁伴噺
+ public event Action<int> refreshItemSumUseCountEvent; //鍒锋柊鐗╁搧鎬讳娇鐢ㄦ暟閲�
+
+ public bool isPlayBetterEquipEffect { get; set; } //鏁寸悊鑳屽寘鏃舵槸鍚︽挱鏀剧壒鏁�
+
+ #region 鎺ユ敹鏈嶅姟绔暟鎹�
+ private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
+ private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
+
+ public void UpdatePack(H0725_tagRolePackRefreshEx packInfo)
+ {
+ SetLookIndex(null);
+ var packType = (PackType)packInfo.PackType;
+ if (!playerPackDict.ContainsKey(packType))
+ {
+ playerPackDict.Add(packType, new SinglePack(packType));
}
-
- private void OnFuncStateChangeEvent(int id)
+ if (isPlayBetterEquipEffect)
{
-
- }
- public void OnBeforePlayerDataInitialize()
- {
- GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
- PlayerDatas.Instance.playerDataRefreshEvent -= UpdatePlayerLv;
- LocalSave.DeleteKey(RecordKnapsackTitle);
- playerPackDict.Clear();
- itemDayUseCntDict.Clear();
- itemSumUseCntDict.Clear();
- itemGUIDDict.Clear();
- isPlayBetterEquipEffect = false;
+ ItemLogicUtility.Instance.ClearSortedBetterEquip();
}
- public void OnAfterPlayerDataInitialize()
+ for (int i = 0; i < packInfo.ItemCount; i++)
{
-
- }
-
- public void OnPlayerLoginOk()
- {
- //ItemOperateUtility.Instance.RequestWarehouseData();
- RoleEquipLocalSave = StringUtility.Contact("RoleEquipLocalSave", PlayerDatas.Instance.baseData.PlayerID);
- StrengthAttrShift_RecordKey = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "StrengthAttrShift");
- if (LocalSave.GetIntArray(RoleEquipLocalSave) != null)
- {
- LocalSavePlaceArray = LocalSave.GetIntArray(RoleEquipLocalSave).ToList();
- }
- else
- {
- LocalSavePlaceArray = null;
- }
- GlobalTimeEvent.Instance.secondEvent += UpdateSecond;
- PlayerDatas.Instance.playerDataRefreshEvent += UpdatePlayerLv;
- isUpdatePlayerLv = true;
- FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
- }
-
- private void RefreshSysInfo(string key, ArrayList infolist)
- {
- // if (key != "GetMoney") return;
- // if (ItemLogicUtility.Instance.hidePickItem)
- // return;
-
- // if (PlayerDatas.Instance.baseData.LV < 3)
- // return;
-
- // var type = 0;
- // int.TryParse(infolist[0].ToString(), out type);
- // if (type == 1)
- // {
- // Vector3 pos = new Vector3(-100, 0, 0);
- // Vector3 rot = new Vector3(0, 0, 0);
- // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
- // {
- // pos = new Vector3(0, 50, 0);
- // rot = new Vector3(180, 180, 0);
- // }
- // EffectMgr.Instance.PlayUIEffect(1204, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
- // }
- // else if (type == 2)
- // {
- // Vector3 pos = new Vector3(-100, 0, 0);
- // Vector3 rot = new Vector3(0, 0, 0);
- // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
- // {
- // pos = new Vector3(150, 50, 0);
- // rot = new Vector3(180, 180, 0);
- // }
- // lingshiEffect = EffectMgr.Instance.PlayUIEffect(1158, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
- // }
- }
-
- public event Action<PackType> refrechPackEvent; //鍒锋柊鏁翠釜鑳屽寘鏁版嵁
- public event Action<PackType, int, int> refreshItemCountEvent; // 鎱庣敤浼氬崱锛堝崟涓級鏈�鏂扮墿鍝佹暟閲忓埛鏂�(鏃х殑寮冪敤)鍦ㄥ緱鍒版柊鐗╁搧銆佺墿鍝佹暟閲忕殑鏀瑰彉锛屾竻鐞嗚鐗╁搧鏃跺潎浼氳Е鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<PackType> gridRefreshEvent; //鑳屽寘绌烘牸鍒锋柊
- public event Action<PackType, int, int> itemCntAddEvent; //鐗╁搧鏁伴噺澧炲姞 int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<PackType, int, int> itemCntReduceEvent; //鐗╁搧鏁伴噺鍑忓皯鐨勬敼鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<int, int> useItemSuccessEvent; //鐗╁搧浣跨敤鎴愬姛 int 浣嶇疆绱㈠紩 int鐗╁搧id
-
- public event Action<int> refreshItemDayUseCountEvent; //鍒锋柊鐗╁搧姣忔棩浣跨敤鏁伴噺
- public event Action<int> refreshItemSumUseCountEvent; //鍒锋柊鐗╁搧鎬讳娇鐢ㄦ暟閲�
-
- public bool isPlayBetterEquipEffect { get; set; } //鏁寸悊鑳屽寘鏃舵槸鍚︽挱鏀剧壒鏁�
-
- #region 鎺ユ敹鏈嶅姟绔暟鎹�
- private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
- private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
-
- public void UpdatePack(H0725_tagRolePackRefreshEx packInfo)
- {
- SetLookIndex(null);
- var packType = (PackType)packInfo.PackType;
- if (!playerPackDict.ContainsKey(packType))
- {
- playerPackDict.Add(packType, new SinglePack(packType));
- }
+ var itemInfo = new ItemInfo(packInfo.ItemInfo[i]);
+ var item = playerPackDict[packType].UpdateItem(itemInfo);
+ AddItemGUIDDict(item, false);
if (isPlayBetterEquipEffect)
{
- ItemLogicUtility.Instance.ClearSortedBetterEquip();
+ ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid));
}
+ }
- for (int i = 0; i < packInfo.ItemCount; i++)
+ if (refrechPackEvent != null)
+ {
+ refrechPackEvent(packType);
+ }
+
+ UpdatePackRedpoint(packType);
+ }
+
+ public void UpdateItem(H0704_tagRolePackRefresh serverItem)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ PackType type = (PackType)serverItem.PackType;
+ if (!playerPackDict.ContainsKey(type))
+ {
+ playerPackDict.Add(type, new SinglePack(type));
+ }
+
+ var showNewItem = false;
+ if (itemGUIDDict.ContainsKey(serverItem.ItemGUID))
+ {
+ var prePack = itemGUIDDict[serverItem.ItemGUID].packType;
+ var preAuction = itemGUIDDict[serverItem.ItemGUID].isAuction;
+ var nowPackType = type;
+ var nowAcution = serverItem.IsBind == 1;
+ showNewItem = preAuction != nowAcution || prePack != nowPackType;
+ }
+ else
+ {
+ showNewItem = true;
+ }
+
+ var itemInfo = new ItemInfo(serverItem);
+ var item = playerPackDict[type].UpdateItem(itemInfo);
+ AddItemGUIDDict(item, showNewItem);
+
+ if (refreshItemCountEvent != null)
+ {
+ refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId);
+ }
+
+ if (itemCntAddEvent != null)
+ {
+ itemCntAddEvent(type, itemInfo.index, itemInfo.itemId);
+ }
+
+ // if (type == PackType.Equip)
+ // {
+ // if (ItemLogicUtility.Instance.IsRealmEquip(itemInfo.itemId))
+ // {
+ // ItemOperateUtility.Instance.ShowPutOnNewEquipRemind(itemInfo.itemId);
+ // }
+ // }
+
+ UpdatePackRedpoint(type);
+ //EquipDecomRedCtrl();
+ AutoUseItem(itemInfo.itemId, serverItem.ItemGUID);
+ }
+
+
+
+
+ public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount)
+ {
+ PackType type = (PackType)useCount.PackType;
+ if (!playerPackDict.ContainsKey(type))
+ {
+ playerPackDict.Add(type, new SinglePack(type));
+ }
+
+ playerPackDict[type].SetOpenGridCount(useCount.CanUseCount);
+
+ if (gridRefreshEvent != null)
+ {
+ gridRefreshEvent(type);
+ }
+
+ UpdatePackRedpoint(type);
+ }
+
+ public void RefreshItemCount(H0707_tagItemCountRefresh refresh)
+ {
+ SetLookIndex(null);
+ isPlayBetterEquipEffect = false;
+ PackType type = (PackType)refresh.PackType;
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+
+ if (singlePack != null)
+ {
+ ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex);
+ if (itemModel != null)
{
- var itemInfo = new ItemInfo(packInfo.ItemInfo[i]);
- var item = playerPackDict[packType].UpdateItem(itemInfo);
- AddItemGUIDDict(item, false);
-
- if (isPlayBetterEquipEffect)
+ bool isAddItemCount = false;
+ if (refresh.ItemCount > itemModel.count)
{
- ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid));
+ isAddItemCount = true;
}
- }
+ itemModel.RefreshCount(refresh.ItemCount);
- if (refrechPackEvent != null)
- {
- refrechPackEvent(packType);
- }
-
- UpdatePackRedpoint(packType);
- }
-
- public void UpdateItem(H0704_tagRolePackRefresh serverItem)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- PackType type = (PackType)serverItem.PackType;
- if (!playerPackDict.ContainsKey(type))
- {
- playerPackDict.Add(type, new SinglePack(type));
- }
-
- var showNewItem = false;
- if (itemGUIDDict.ContainsKey(serverItem.ItemGUID))
- {
- var prePack = itemGUIDDict[serverItem.ItemGUID].packType;
- var preAuction = itemGUIDDict[serverItem.ItemGUID].isAuction;
- var nowPackType = type;
- var nowAcution = serverItem.IsBind == 1;
- showNewItem = preAuction != nowAcution || prePack != nowPackType;
- }
- else
- {
- showNewItem = true;
- }
-
- var itemInfo = new ItemInfo(serverItem);
- var item = playerPackDict[type].UpdateItem(itemInfo);
- AddItemGUIDDict(item, showNewItem);
-
- if (refreshItemCountEvent != null)
- {
- refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId);
- }
-
- if (itemCntAddEvent != null)
- {
- itemCntAddEvent(type, itemInfo.index, itemInfo.itemId);
- }
-
- // if (type == PackType.Equip)
- // {
- // if (ItemLogicUtility.Instance.IsRealmEquip(itemInfo.itemId))
- // {
- // ItemOperateUtility.Instance.ShowPutOnNewEquipRemind(itemInfo.itemId);
- // }
- // }
-
- UpdatePackRedpoint(type);
- //EquipDecomRedCtrl();
- AutoUseItem(itemInfo.itemId, serverItem.ItemGUID);
- }
-
-
-
-
- public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount)
- {
- PackType type = (PackType)useCount.PackType;
- if (!playerPackDict.ContainsKey(type))
- {
- playerPackDict.Add(type, new SinglePack(type));
- }
-
- playerPackDict[type].SetOpenGridCount(useCount.CanUseCount);
-
- if (gridRefreshEvent != null)
- {
- gridRefreshEvent(type);
- }
-
- UpdatePackRedpoint(type);
- }
-
- public void RefreshItemCount(H0707_tagItemCountRefresh refresh)
- {
- SetLookIndex(null);
- isPlayBetterEquipEffect = false;
- PackType type = (PackType)refresh.PackType;
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
-
- if (singlePack != null)
- {
- ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex);
- if (itemModel != null)
+ if (isAddItemCount)
{
- bool isAddItemCount = false;
- if (refresh.ItemCount > itemModel.count)
+ if (itemCntAddEvent != null)
{
- isAddItemCount = true;
+ itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId);
}
- itemModel.RefreshCount(refresh.ItemCount);
-
- if (isAddItemCount)
- {
- if (itemCntAddEvent != null)
- {
- itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
- ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString());
- }
- else
- {
- if (itemCntReduceEvent != null)
- {
- itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
- }
-
- if (refreshItemCountEvent != null)
- {
- refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
-
+ ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString());
}
- }
+ else
+ {
+ if (itemCntReduceEvent != null)
+ {
+ itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId);
+ }
+ }
- }
-
- public void ClearPack(H0711_tagClearItemPack clearPack)
- {
- PackType type = (PackType)clearPack.PackIndex;
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- if (singlePack != null)
- {
- singlePack.Clear();
- }
- }
-
- public void RemoveItem(H0709_tagClearItem clearItem)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- PackType type = (PackType)clearItem.PackType;
-
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- string guid = "";
- if (singlePack != null)
- {
- ItemModel itemModel = singlePack.GetItemByIndex(clearItem.ItemIndex);
- guid = itemModel.guid;
- int itemId = itemModel.itemId;
-
- DeleteItemDictByGUID(type, itemModel.guid);
-
- singlePack.RemoveItem(clearItem.ItemIndex);
if (refreshItemCountEvent != null)
{
- refreshItemCountEvent(type, clearItem.ItemIndex, itemId);
- }
-
- if (itemCntReduceEvent != null)
- {
- itemCntReduceEvent(type, clearItem.ItemIndex, itemId);
- }
- }
-
- UpdatePackRedpoint(type);
-
- if (GetItemByGuid(guid) == null)
- {
- KnapsackTimeCDMgr.Instance.UnRegister(guid);
- }
-
- }
-
- public void PackResetOk(H0316_tagPackResetOK packreset)
- {
- ItemLogicUtility.Instance.isPackResetOk = true;
- }
-
- public void UseItemSuccess(H0706_tagUseItemSuccess success)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID)
- {
- return;
- }
-
-
- if (useItemSuccessEvent != null)
- {
- useItemSuccessEvent(success.ItemIndex, (int)success.ItemID);
- }
- }
-
- void AutoUseItem(int itemID, string guid)
- {
- // if (autoUseItemIDs.Contains(itemID))
- // {
- // ItemOperateUtility.Instance.GotoUseItem(guid);
- // }
- }
-
-
- void AddItemGUIDDict(ItemModel itemModel, bool showNewItem)
- {
- itemGUIDDict[itemModel.guid] = itemModel;
- GetItemEventCtrl(itemModel, showNewItem);
- }
-
- void DeleteItemDictByGUID(PackType type, string guid)
- {
- if (itemGUIDDict.ContainsKey(guid))
- {
- if (itemGUIDDict[guid].packType == type)
- {
- itemGUIDDict.Remove(guid);
- }
- }
- }
-
- /// <summary>
- /// 鐗╁搧姣忔棩浣跨敤鐨勬鏁�
- /// </summary>
- private Dictionary<int, int> itemDayUseCntDict = new Dictionary<int, int>();
- public void UpdateItemUseCnt(HA809_tagMCItemDayUseCntInfo useCntInfo)
- {
- for (int i = 0; i < useCntInfo.Count; i++)
- {
- int itemId = (int)useCntInfo.ItemUseCntList[i].ItemID;
- int cnt = useCntInfo.ItemUseCntList[i].UseCnt;
- if (!itemDayUseCntDict.ContainsKey(itemId))
- {
- itemDayUseCntDict.Add(itemId, cnt);
- }
- else
- {
- itemDayUseCntDict[itemId] = cnt;
- }
-
- if (refreshItemDayUseCountEvent != null)
- {
- refreshItemDayUseCountEvent(itemId);
+ refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId);
}
}
}
- private Dictionary<int, int> itemSumUseCntDict = new Dictionary<int, int>();
- // public void UpdateItemSumUseCnt(HA339_tagMCAttrFruitEatCntList useCntInfo)
- // {
- // for (int i = 0; i < useCntInfo.count; i++)
- // {
- // int itemId = (int)useCntInfo.EatCntList[i].ItemID;
- // int cnt = (int)useCntInfo.EatCntList[i].EatCnt;
- // if (!itemSumUseCntDict.ContainsKey(itemId))
- // {
- // itemSumUseCntDict.Add(itemId, cnt);
- // }
- // else
- // {
- // itemSumUseCntDict[itemId] = cnt;
- // }
+ }
- // if (refreshItemSumUseCountEvent != null)
- // {
- // refreshItemSumUseCountEvent(itemId);
- // }
- // }
- // }
-
- #endregion
-
- #region 鐜╁瑁呭鐗规畩閫昏緫
- void ParseConfig()
+ public void ClearPack(H0711_tagClearItemPack clearPack)
+ {
+ PackType type = (PackType)clearPack.PackIndex;
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ if (singlePack != null)
{
-
-
- var config = FuncConfigConfig.Get("CommonShowAwards");
- commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1);
-
- }
-
-
-
- private void UpdateSecond()
- {
- if (isUpdatePlayerLv)
- {
- isUpdatePlayerLv = false;
- }
- }
-
- private void UpdatePlayerLv(PlayerDataType type)
- {
- if (type != PlayerDataType.LV) return;
-
- isUpdatePlayerLv = true;
- }
-
- #endregion
-
-
- private void GetItemEventCtrl(ItemModel itemModel, bool showNewItem)
- {
- // if (showNewItem)
- // {
- // bool isOverdue = false;
- // if (itemModel.config.ExpireTime > 0)
- // {
- // ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.guid);
- // switch ((ItemTimeType)itemModel.config.EndureReduceType)
- // {
- // case ItemTimeType.EquipedTime:
- // List<int> itemEffectTime = itemModel.GetUseData((int)ItemUseDataKey.createTime);
- // if (itemEffectTime != null && itemEffectTime[0] != 0)
- // {
- // if (cool == null || cool.GetRemainTime() <= 0)
- // {
- // isOverdue = true;
- // }
- // }
- // break;
-
- // case ItemTimeType.RealityTime:
- // if (cool == null || cool.GetRemainTime() <= 0)
- // {
- // isOverdue = true;
- // }
- // break;
-
- // }
- // }
-
- // if (!isOverdue)
- // {
- // ItemLogicUtility.Instance.RecommendItem(itemModel);
- // ItemLogicUtility.Instance.OnGetEquip(itemModel);
- // ItemLogicUtility.Instance.RefreshPickItem(itemModel.packType, itemModel.itemId.ToString());
- // }
- // }
-
- }
-
- /// <summary>
- /// 寰楀埌鏌愪釜鍖呰9鐨勬墍鏈夋暟鎹�
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public SinglePack GetSinglePack(PackType type)
- {
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- return singlePack;
- }
-
- public void UnLockPackGrid(int chooseGridCount, PackType type)
- {
- // var singlePack = GetSinglePack(type);
- // int openCount = chooseGridCount - singlePack.unlockedGridCount;
- // int index = 0;
- // switch (type)
- // {
- // case PackType.Item:
- // index = chooseGridCount - GeneralDefine.initBagGridCount;
- // break;
- // case PackType.Warehouse:
- // index = chooseGridCount - GeneralDefine.initDepotGridCount;
- // break;
- // }
-
- // itemTipsModel.SetExtendGirdModel(openCount, index, type);
- // WindowCenter.Instance.Open<ExtendWin>();
- }
-
- public ItemModel GetItemByGuid(string guid)
- {
- if (string.IsNullOrEmpty(guid))
- {
- return null;
- }
-
- ItemModel itemModel = null;
- itemGUIDDict.TryGetValue(guid, out itemModel);
- return itemModel;
- }
-
- public ItemModel GetItemByIndex(PackType type, int index)
- {
- ItemModel itemModel = null;
- if (playerPackDict.ContainsKey(type))
- {
- itemModel = playerPackDict[type].GetItemByIndex(index);
- }
- return itemModel;
- }
-
- /// <summary>
- /// 鑾峰彇鎸囧畾鑳屽寘鍐� 鎸囧畾ID鐨勬墍鏈夌墿鍝�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <param name="includeAuction"></param>
- /// <returns></returns>
- public List<ItemModel> GetItemsById(PackType type, int id, bool includeAuction = true)
- {
- if (playerPackDict.ContainsKey(type))
- {
- var singlePack = playerPackDict[type];
- return singlePack.GetItemsById(id, includeAuction);
- }
- else
- {
- return null;
- }
- }
-
- /// <summary>
- /// 鑾峰彇鎸囧畾鑳屽寘鍐呮寚瀹欼D鐨勪竴涓墿鍝�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <param name="includeAuction"></param>
- /// <returns></returns>
- public ItemModel GetItemByID(PackType type, int id, bool includeAuction = true)
- {
- if (playerPackDict.ContainsKey(type))
- {
- var singlePack = playerPackDict[type];
- return singlePack.GetItemByID(id, includeAuction);
- }
- else
- {
- return null;
- }
- }
-
- public List<ItemModel> GetItems(PackType packType, SinglePack.FilterParams param)
- {
- if (playerPackDict.ContainsKey(packType))
- {
- return playerPackDict[packType].GetItems(param);
- }
- else
- {
- return null;
- }
- }
-
- //閫氳繃id鎵剧墿鍝侊紝娉ㄦ剰妫�鏌ユ槸鍚︽寚瀹氳儗鍖�
- public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item)
- {
- string guid = string.Empty;
- foreach (var key in itemGUIDDict.Keys)
- {
- if (!includeAuction && itemGUIDDict[key].isAuction)
- {
- continue;
- }
-
- if (itemGUIDDict[key].itemId == itemId && packType == itemGUIDDict[key].packType)
- {
- guid = key;
- return guid;
- }
- }
-
- return guid;
- }
-
- /// <summary>
- /// 寰楀埌ID鐩稿悓鐨勭墿鍝佹暟閲�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public int GetItemCountByID(PackType type, int id, bool includeAuction = true)
- {
- int count = 0;
- var singlePack = GetSinglePack(type);
- if (singlePack != null)
- {
- count = singlePack.GetCountById(id, includeAuction);
- }
-
- return count;
- }
-
- public int GetEmptyGridCount(PackType type)
- {
- int count = 0;
- SinglePack singlePack = GetSinglePack(type);
- if (singlePack != null)
- {
- count = singlePack.GetEmptyGridCount();
- }
-
- return count;
- }
-
- public bool TryGetShareNumItem(int itemId, out List<int> idlist)
- {
- idlist = new List<int>();
- foreach (var list in sharedUseCountItemDict.Values)
- {
- if (list.Contains(itemId))
- {
- idlist = list;
- return true;
- }
- }
- return false;
- }
-
- /// <summary>
- /// 寰楀埌鐗╁搧浠婃棩浣跨敤娆℃暟
- /// </summary>
- /// <param name="itemId"></param>
- /// <returns></returns>
- public int GetItemUsedTimesToday(int itemId)
- {
- int useCnt = 0;
- List<int> shareIdlist = null;
- bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
- if (isShare)
- {
- foreach (var id in shareIdlist)
- {
- int singleUseCnt = 0;
- itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
- useCnt += singleUseCnt;
- }
- }
- else
- {
- itemDayUseCntDict.TryGetValue(itemId, out useCnt);
- }
- return useCnt;
- }
-
- /// <summary>
- /// 寰楀埌鐗╁搧鎬讳娇鐢ㄦ鏁�
- /// </summary>
- /// <param name="itemId"></param>
- /// <returns></returns>
- public int GetItemTotalUsedTimes(int itemId)
- {
- int useCnt = 0;
- List<int> shareIdlist = null;
- bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
- if (isShare)
- {
- foreach (var id in shareIdlist)
- {
- int singleUseCnt = 0;
- itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
- useCnt += singleUseCnt;
- }
- }
- else
- {
- itemSumUseCntDict.TryGetValue(itemId, out useCnt);
- }
- return useCnt;
- }
-
- public void GotoWashAttributePoint(string guid)
- {
- // ItemModel itemModel = GetItemByGuid(guid);
- // if (itemModel == null) return;
-
- // WashAttrPointWin.itemModel = itemModel;
- // WindowCenter.Instance.Open<WashAttrPointWin>();
- }
-
- #region 绾㈢偣閫昏緫鍒ゆ柇
-
- const int ITEMPACK_REDKEY = 102011003;
- Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
-
- const int LS_REDKEY = 102011015;
- Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY);
-
-
- private void UpdatePackRedpoint(PackType type)
- {
- var singlePack = GetSinglePack(type);
- if (singlePack == null)
- {
- return;
- }
-
- switch (type)
- {
- case PackType.Item:
- if (singlePack.GetEmptyGridCount() <= 0)
- {
- redpointItemPack.state = RedPointState.Full;
- //SysNotifyMgr.Instance.ShowTip("BagFull");
- }
- else
- {
- redpointItemPack.state = RedPointState.None;
- }
-
- break;
- case PackType.Warehouse:
- if (singlePack.GetEmptyGridCount() <= 0)
- {
- MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
- }
- else
- {
- MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
- }
- break;
- }
- }
-
-
- #endregion
-
- #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
- public event Action lookEquipEvent;
- private int _lookLineIndex = -1;
- public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
-
- public string lookItemGUID { get; private set; }
-
- public void SetLookIndex(string guid, int singleRowCount = 5)
- {
- if (string.IsNullOrEmpty(guid) || guid == "")
- {
- lookLineIndex = -1;
- lookItemGUID = "";
- }
- else
- {
- int index = GetItemByGuid(guid).gridIndex;
- lookLineIndex = index / singleRowCount;
- lookItemGUID = guid;
- }
-
- if (lookEquipEvent != null)
- {
- lookEquipEvent();
- }
- }
-
- public event Action RefreshBagEvent;
- public void RefreshBagInfo()
- {
- if (RefreshBagEvent != null)
- {
- RefreshBagEvent();
- }
- }
- #endregion
-
- public void SetJumpToOneKeySell(Transform parent)
- {
- // var goEffect = AchievementGuideEffectPool.Require(1);
- // goEffect.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
- // AchievementGoto.guideAchievementId = 0;
- }
-
- #region 鐗╁搧浣跨敤蹇嵎鎻愮ず
-
- private int cacheMapId = 0;
- public event Action<PackType, string> itemUseAct;
- private Dictionary<int, int> itemUseTypeDict = new Dictionary<int, int>(); //key SkillTypeID,value 浣跨敤鐗╁搧鐨処D
-
-
- private void AddItemUseTypeDict(int id)
- {
- SkillConfig skillConfig = GetSkillConfig(id);
- int itemCount = GetItemCountByID(PackType.Item, id);
- if (skillConfig != null && itemCount > 0)
- {
- if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID))
- {
- itemUseTypeDict.Add(skillConfig.SkillTypeID, id);
- }
- else
- {
- SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]);
- if (skillConfig.SkillLV > preSkillConfig.SkillLV)
- {
- itemUseTypeDict[skillConfig.SkillTypeID] = id;
- }
- }
- }
- }
-
-
-
-
- public SkillConfig GetSkillConfig(int itemId)
- {
- ItemConfig itemConfig = ItemConfig.Get(itemId);
- SkillConfig skillConfig = SkillConfig.Get(itemConfig.AddSkill1);
- return skillConfig;
- }
-
-
-
- #endregion
-
- #region 鍒ゆ柇鐗╁搧鏄惁杈惧埌浣跨敤涓婇檺
- // public bool IsReachUseLimit(string guid, out ulong count)
- // {
- // count = 0;
- // ItemModel itemModel = GetItemByGuid(guid);
- // if (itemModel == null) return false;
-
- // AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId);
- // int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId);
- // int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId);
- // count = (ulong)itemModel.count;
- // bool isReach = false;
- // int remainDayCnt = 0;
- // if (itemModel.config.MaxSkillCnt > 0)
- // {
- // remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt;
- // if (itemModel.count > remainDayCnt)
- // {
- // count = (ulong)remainDayCnt;
- // }
- // }
-
- // int remainSumCnt = 0;
- // if (fruitConfig != null)
- // {
- // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt;
- // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt)
- // {
- // count = (ulong)remainSumCnt;
- // }
- // }
-
- // if (count < (ulong)itemModel.count)
- // {
- // isReach = true;
- // }
-
- // return isReach;
- // }
- #endregion
-
-
-
-
-
- public enum EquipColorType
- {
- None = 0,
- White = 1,
- Blue = 2,
- Purple = 3,
- Orange = 4,
- Red = 5,
-
- }
-
-
-
-
- public void ReceiveAwardNotify(HA801_tagMCGiveAwardInfo netPack)
- {
- var eventName = UIHelper.ServerStringTrim(netPack.EventName);
- if (eventName == "BuyItem")
- return;
-
- // 浠欑洘鏀诲煄鎴�
- // if (eventName == "FamilyGCZSQGrid" || eventName == "FamilyGCZSQPass" || eventName == "FamilyGCZSQPassAll" ||
- // eventName == "FamilyGCZContiribution" || eventName == "FamilyGCZAtk")
- // {
- // ModelCenter.Instance.GetModel<FairySiegeActModel>()?.OnUpdateAwardInfoAction(netPack);
- // return;
- // }
- if (!commonShowAwardEvents.Contains(eventName))
- return;
-
- List<Item> showItems = new List<Item>();
-
- if (netPack.Exp != 0 || netPack.ExpPoint != 0)
- {
- ulong expValue = netPack.Exp + netPack.ExpPoint * (ulong)Constants.ExpPointValue;
- showItems.Add(new Item(GeneralDefine.expDisplayId, expValue));
- }
- if (netPack.MoneyList.Length != 0)
- {
- for (int i = 0; i < netPack.MoneyLen; i++)
- {
- var moneyType = netPack.MoneyList[i].MoneyType;
- if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType) && netPack.MoneyList[i].MoneyValue != 0)
- {
- showItems.Add(new Item(GeneralDefine.moneyDisplayIds[moneyType], netPack.MoneyList[i].MoneyValue));
- }
-
- }
- }
-
- if (netPack.ItemList.Length != 0)
- {
- for (int i = 0; i < netPack.ItemLen; i++)
- {
- showItems.Add(new Item((int)netPack.ItemList[i].ItemID, netPack.ItemList[i].Count, netPack.ItemList[i].IsBind));
- }
- }
-
-
- string info = string.Empty;
- if (LanguageConfig.HasKey("commonShowAwardEvents_" + eventName))
- info = Language.Get("commonShowAwardEvents_" + eventName);
-
- if (showItems.Count == 0)
- return;
-
- ItemLogicUtility.Instance.ShowGetItem(showItems, info, 0, eventName: eventName);
+ singlePack.Clear();
}
}
+
+ public void RemoveItem(H0709_tagClearItem clearItem)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ PackType type = (PackType)clearItem.PackType;
+
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ string guid = "";
+ if (singlePack != null)
+ {
+ ItemModel itemModel = singlePack.GetItemByIndex(clearItem.ItemIndex);
+ if (itemModel == null)
+ {
+ Debug.LogErrorFormat("鍒犻櫎涓嶅瓨鍦ㄧ殑鐗╁搧绱㈠紩:{0}", clearItem.ItemIndex);
+ return;
+ }
+ guid = itemModel.guid;
+ int itemId = itemModel.itemId;
+
+ DeleteItemDictByGUID(type, itemModel.guid);
+
+ singlePack.RemoveItem(clearItem.ItemIndex);
+ if (refreshItemCountEvent != null)
+ {
+ refreshItemCountEvent(type, clearItem.ItemIndex, itemId);
+ }
+
+ if (itemCntReduceEvent != null)
+ {
+ itemCntReduceEvent(type, clearItem.ItemIndex, itemId);
+ }
+ }
+
+ UpdatePackRedpoint(type);
+
+ if (GetItemByGuid(guid) == null)
+ {
+ KnapsackTimeCDMgr.Instance.UnRegister(guid);
+ }
+
+ }
+
+ public void PackResetOk(H0316_tagPackResetOK packreset)
+ {
+ ItemLogicUtility.Instance.isPackResetOk = true;
+ }
+
+ public void UseItemSuccess(H0706_tagUseItemSuccess success)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID)
+ {
+ return;
+ }
+
+
+ if (useItemSuccessEvent != null)
+ {
+ useItemSuccessEvent(success.ItemIndex, (int)success.ItemID);
+ }
+ }
+
+ void AutoUseItem(int itemID, string guid)
+ {
+ // if (autoUseItemIDs.Contains(itemID))
+ // {
+ // ItemOperateUtility.Instance.GotoUseItem(guid);
+ // }
+ }
+
+
+ void AddItemGUIDDict(ItemModel itemModel, bool showNewItem)
+ {
+ itemGUIDDict[itemModel.guid] = itemModel;
+ GetItemEventCtrl(itemModel, showNewItem);
+ }
+
+ void DeleteItemDictByGUID(PackType type, string guid)
+ {
+ if (itemGUIDDict.ContainsKey(guid))
+ {
+ if (itemGUIDDict[guid].packType == type)
+ {
+ itemGUIDDict.Remove(guid);
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鐗╁搧姣忔棩浣跨敤鐨勬鏁�
+ /// </summary>
+ private Dictionary<int, int> itemDayUseCntDict = new Dictionary<int, int>();
+ public void UpdateItemUseCnt(HA809_tagMCItemDayUseCntInfo useCntInfo)
+ {
+ for (int i = 0; i < useCntInfo.Count; i++)
+ {
+ int itemId = (int)useCntInfo.ItemUseCntList[i].ItemID;
+ int cnt = useCntInfo.ItemUseCntList[i].UseCnt;
+ if (!itemDayUseCntDict.ContainsKey(itemId))
+ {
+ itemDayUseCntDict.Add(itemId, cnt);
+ }
+ else
+ {
+ itemDayUseCntDict[itemId] = cnt;
+ }
+
+ if (refreshItemDayUseCountEvent != null)
+ {
+ refreshItemDayUseCountEvent(itemId);
+ }
+
+ }
+ }
+
+ private Dictionary<int, int> itemSumUseCntDict = new Dictionary<int, int>();
+ // public void UpdateItemSumUseCnt(HA339_tagMCAttrFruitEatCntList useCntInfo)
+ // {
+ // for (int i = 0; i < useCntInfo.count; i++)
+ // {
+ // int itemId = (int)useCntInfo.EatCntList[i].ItemID;
+ // int cnt = (int)useCntInfo.EatCntList[i].EatCnt;
+ // if (!itemSumUseCntDict.ContainsKey(itemId))
+ // {
+ // itemSumUseCntDict.Add(itemId, cnt);
+ // }
+ // else
+ // {
+ // itemSumUseCntDict[itemId] = cnt;
+ // }
+
+ // if (refreshItemSumUseCountEvent != null)
+ // {
+ // refreshItemSumUseCountEvent(itemId);
+ // }
+ // }
+ // }
+
+ #endregion
+
+ #region 鐜╁瑁呭鐗规畩閫昏緫
+ void ParseConfig()
+ {
+
+
+ var config = FuncConfigConfig.Get("CommonShowAwards");
+ commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1);
+
+ }
+
+
+
+ private void UpdateSecond()
+ {
+ if (isUpdatePlayerLv)
+ {
+ isUpdatePlayerLv = false;
+ }
+ }
+
+ private void UpdatePlayerLv(PlayerDataType type)
+ {
+ if (type != PlayerDataType.LV) return;
+
+ isUpdatePlayerLv = true;
+ }
+
+ #endregion
+
+
+ private void GetItemEventCtrl(ItemModel itemModel, bool showNewItem)
+ {
+ // if (showNewItem)
+ // {
+ // bool isOverdue = false;
+ // if (itemModel.config.ExpireTime > 0)
+ // {
+ // ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.guid);
+ // switch ((ItemTimeType)itemModel.config.EndureReduceType)
+ // {
+ // case ItemTimeType.EquipedTime:
+ // List<int> itemEffectTime = itemModel.GetUseData((int)ItemUseDataKey.createTime);
+ // if (itemEffectTime != null && itemEffectTime[0] != 0)
+ // {
+ // if (cool == null || cool.GetRemainTime() <= 0)
+ // {
+ // isOverdue = true;
+ // }
+ // }
+ // break;
+
+ // case ItemTimeType.RealityTime:
+ // if (cool == null || cool.GetRemainTime() <= 0)
+ // {
+ // isOverdue = true;
+ // }
+ // break;
+
+ // }
+ // }
+
+ // if (!isOverdue)
+ // {
+ // ItemLogicUtility.Instance.RecommendItem(itemModel);
+ // ItemLogicUtility.Instance.OnGetEquip(itemModel);
+ // ItemLogicUtility.Instance.RefreshPickItem(itemModel.packType, itemModel.itemId.ToString());
+ // }
+ // }
+
+ }
+
+ /// <summary>
+ /// 寰楀埌鏌愪釜鍖呰9鐨勬墍鏈夋暟鎹�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <returns></returns>
+ public SinglePack GetSinglePack(PackType type)
+ {
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ return singlePack;
+ }
+
+ public void UnLockPackGrid(int chooseGridCount, PackType type)
+ {
+ // var singlePack = GetSinglePack(type);
+ // int openCount = chooseGridCount - singlePack.unlockedGridCount;
+ // int index = 0;
+ // switch (type)
+ // {
+ // case PackType.Item:
+ // index = chooseGridCount - GeneralDefine.initBagGridCount;
+ // break;
+ // case PackType.Warehouse:
+ // index = chooseGridCount - GeneralDefine.initDepotGridCount;
+ // break;
+ // }
+
+ // itemTipsModel.SetExtendGirdModel(openCount, index, type);
+ // WindowCenter.Instance.Open<ExtendWin>();
+ }
+
+ public ItemModel GetItemByGuid(string guid)
+ {
+ if (string.IsNullOrEmpty(guid))
+ {
+ return null;
+ }
+
+ ItemModel itemModel = null;
+ itemGUIDDict.TryGetValue(guid, out itemModel);
+ return itemModel;
+ }
+
+ public ItemModel GetItemByIndex(PackType type, int index)
+ {
+ ItemModel itemModel = null;
+ if (playerPackDict.ContainsKey(type))
+ {
+ itemModel = playerPackDict[type].GetItemByIndex(index);
+ }
+ return itemModel;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸囧畾鑳屽寘鍐� 鎸囧畾ID鐨勬墍鏈夌墿鍝�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <param name="includeAuction"></param>
+ /// <returns></returns>
+ public List<ItemModel> GetItemsById(PackType type, int id, bool includeAuction = true)
+ {
+ if (playerPackDict.ContainsKey(type))
+ {
+ var singlePack = playerPackDict[type];
+ return singlePack.GetItemsById(id, includeAuction);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸囧畾鑳屽寘鍐呮寚瀹欼D鐨勪竴涓墿鍝�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <param name="includeAuction"></param>
+ /// <returns></returns>
+ public ItemModel GetItemByID(PackType type, int id, bool includeAuction = true)
+ {
+ if (playerPackDict.ContainsKey(type))
+ {
+ var singlePack = playerPackDict[type];
+ return singlePack.GetItemByID(id, includeAuction);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public List<ItemModel> GetItems(PackType packType, SinglePack.FilterParams param)
+ {
+ if (playerPackDict.ContainsKey(packType))
+ {
+ return playerPackDict[packType].GetItems(param);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ //閫氳繃id鎵剧墿鍝侊紝娉ㄦ剰妫�鏌ユ槸鍚︽寚瀹氳儗鍖�
+ public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item)
+ {
+ string guid = string.Empty;
+ foreach (var key in itemGUIDDict.Keys)
+ {
+ if (!includeAuction && itemGUIDDict[key].isAuction)
+ {
+ continue;
+ }
+
+ if (itemGUIDDict[key].itemId == itemId && packType == itemGUIDDict[key].packType)
+ {
+ guid = key;
+ return guid;
+ }
+ }
+
+ return guid;
+ }
+
+ /// <summary>
+ /// 寰楀埌ID鐩稿悓鐨勭墿鍝佹暟閲�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public int GetItemCountByID(PackType type, int id, bool includeAuction = true)
+ {
+ int count = 0;
+ var singlePack = GetSinglePack(type);
+ if (singlePack != null)
+ {
+ count = singlePack.GetCountById(id, includeAuction);
+ }
+
+ return count;
+ }
+
+ public int GetEmptyGridCount(PackType type)
+ {
+ int count = 0;
+ SinglePack singlePack = GetSinglePack(type);
+ if (singlePack != null)
+ {
+ count = singlePack.GetEmptyGridCount();
+ }
+
+ return count;
+ }
+
+ public bool TryGetShareNumItem(int itemId, out List<int> idlist)
+ {
+ idlist = new List<int>();
+ foreach (var list in sharedUseCountItemDict.Values)
+ {
+ if (list.Contains(itemId))
+ {
+ idlist = list;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// 寰楀埌鐗╁搧浠婃棩浣跨敤娆℃暟
+ /// </summary>
+ /// <param name="itemId"></param>
+ /// <returns></returns>
+ public int GetItemUsedTimesToday(int itemId)
+ {
+ int useCnt = 0;
+ List<int> shareIdlist = null;
+ bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
+ if (isShare)
+ {
+ foreach (var id in shareIdlist)
+ {
+ int singleUseCnt = 0;
+ itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
+ useCnt += singleUseCnt;
+ }
+ }
+ else
+ {
+ itemDayUseCntDict.TryGetValue(itemId, out useCnt);
+ }
+ return useCnt;
+ }
+
+ /// <summary>
+ /// 寰楀埌鐗╁搧鎬讳娇鐢ㄦ鏁�
+ /// </summary>
+ /// <param name="itemId"></param>
+ /// <returns></returns>
+ public int GetItemTotalUsedTimes(int itemId)
+ {
+ int useCnt = 0;
+ List<int> shareIdlist = null;
+ bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
+ if (isShare)
+ {
+ foreach (var id in shareIdlist)
+ {
+ int singleUseCnt = 0;
+ itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
+ useCnt += singleUseCnt;
+ }
+ }
+ else
+ {
+ itemSumUseCntDict.TryGetValue(itemId, out useCnt);
+ }
+ return useCnt;
+ }
+
+ public void GotoWashAttributePoint(string guid)
+ {
+ // ItemModel itemModel = GetItemByGuid(guid);
+ // if (itemModel == null) return;
+
+ // WashAttrPointWin.itemModel = itemModel;
+ // WindowCenter.Instance.Open<WashAttrPointWin>();
+ }
+
+ #region 绾㈢偣閫昏緫鍒ゆ柇
+
+ const int ITEMPACK_REDKEY = 102011003;
+ Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
+
+ const int LS_REDKEY = 102011015;
+ Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY);
+
+
+ private void UpdatePackRedpoint(PackType type)
+ {
+ var singlePack = GetSinglePack(type);
+ if (singlePack == null)
+ {
+ return;
+ }
+
+ switch (type)
+ {
+ case PackType.Item:
+ if (singlePack.GetEmptyGridCount() <= 0)
+ {
+ redpointItemPack.state = RedPointState.Full;
+ //SysNotifyMgr.Instance.ShowTip("BagFull");
+ }
+ else
+ {
+ redpointItemPack.state = RedPointState.None;
+ }
+
+ break;
+ case PackType.Warehouse:
+ if (singlePack.GetEmptyGridCount() <= 0)
+ {
+ MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
+ }
+ else
+ {
+ MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
+ }
+ break;
+ }
+ }
+
+
+ #endregion
+
+ #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
+ public event Action lookEquipEvent;
+ private int _lookLineIndex = -1;
+ public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
+
+ public string lookItemGUID { get; private set; }
+
+ public void SetLookIndex(string guid, int singleRowCount = 5)
+ {
+ if (string.IsNullOrEmpty(guid) || guid == "")
+ {
+ lookLineIndex = -1;
+ lookItemGUID = "";
+ }
+ else
+ {
+ int index = GetItemByGuid(guid).gridIndex;
+ lookLineIndex = index / singleRowCount;
+ lookItemGUID = guid;
+ }
+
+ if (lookEquipEvent != null)
+ {
+ lookEquipEvent();
+ }
+ }
+
+ public event Action RefreshBagEvent;
+ public void RefreshBagInfo()
+ {
+ if (RefreshBagEvent != null)
+ {
+ RefreshBagEvent();
+ }
+ }
+ #endregion
+
+ public void SetJumpToOneKeySell(Transform parent)
+ {
+ // var goEffect = AchievementGuideEffectPool.Require(1);
+ // goEffect.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
+ // AchievementGoto.guideAchievementId = 0;
+ }
+
+ #region 鐗╁搧浣跨敤蹇嵎鎻愮ず
+
+ private int cacheMapId = 0;
+ public event Action<PackType, string> itemUseAct;
+ private Dictionary<int, int> itemUseTypeDict = new Dictionary<int, int>(); //key SkillTypeID,value 浣跨敤鐗╁搧鐨処D
+
+
+ private void AddItemUseTypeDict(int id)
+ {
+ SkillConfig skillConfig = GetSkillConfig(id);
+ int itemCount = GetItemCountByID(PackType.Item, id);
+ if (skillConfig != null && itemCount > 0)
+ {
+ if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID))
+ {
+ itemUseTypeDict.Add(skillConfig.SkillTypeID, id);
+ }
+ else
+ {
+ SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]);
+ if (skillConfig.SkillLV > preSkillConfig.SkillLV)
+ {
+ itemUseTypeDict[skillConfig.SkillTypeID] = id;
+ }
+ }
+ }
+ }
+
+
+
+
+ public SkillConfig GetSkillConfig(int itemId)
+ {
+ ItemConfig itemConfig = ItemConfig.Get(itemId);
+ SkillConfig skillConfig = SkillConfig.Get(itemConfig.AddSkill1);
+ return skillConfig;
+ }
+
+
+
+ #endregion
+
+ #region 鍒ゆ柇鐗╁搧鏄惁杈惧埌浣跨敤涓婇檺
+ // public bool IsReachUseLimit(string guid, out ulong count)
+ // {
+ // count = 0;
+ // ItemModel itemModel = GetItemByGuid(guid);
+ // if (itemModel == null) return false;
+
+ // AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId);
+ // int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId);
+ // int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId);
+ // count = (ulong)itemModel.count;
+ // bool isReach = false;
+ // int remainDayCnt = 0;
+ // if (itemModel.config.MaxSkillCnt > 0)
+ // {
+ // remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt;
+ // if (itemModel.count > remainDayCnt)
+ // {
+ // count = (ulong)remainDayCnt;
+ // }
+ // }
+
+ // int remainSumCnt = 0;
+ // if (fruitConfig != null)
+ // {
+ // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt;
+ // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt)
+ // {
+ // count = (ulong)remainSumCnt;
+ // }
+ // }
+
+ // if (count < (ulong)itemModel.count)
+ // {
+ // isReach = true;
+ // }
+
+ // return isReach;
+ // }
+ #endregion
+
+
+
+
+
+ public enum EquipColorType
+ {
+ None = 0,
+ White = 1,
+ Blue = 2,
+ Purple = 3,
+ Orange = 4,
+ Red = 5,
+
+ }
+
+
+
+
+ public void ReceiveAwardNotify(HA801_tagMCGiveAwardInfo netPack)
+ {
+ var eventName = UIHelper.ServerStringTrim(netPack.EventName);
+ if (eventName == "BuyItem")
+ return;
+
+ // 浠欑洘鏀诲煄鎴�
+ // if (eventName == "FamilyGCZSQGrid" || eventName == "FamilyGCZSQPass" || eventName == "FamilyGCZSQPassAll" ||
+ // eventName == "FamilyGCZContiribution" || eventName == "FamilyGCZAtk")
+ // {
+ // ModelCenter.Instance.GetModel<FairySiegeActModel>()?.OnUpdateAwardInfoAction(netPack);
+ // return;
+ // }
+ if (!commonShowAwardEvents.Contains(eventName))
+ return;
+
+ List<Item> showItems = new List<Item>();
+
+ if (netPack.Exp != 0 || netPack.ExpPoint != 0)
+ {
+ ulong expValue = netPack.Exp + netPack.ExpPoint * (ulong)Constants.ExpPointValue;
+ showItems.Add(new Item(GeneralDefine.expDisplayId, expValue));
+ }
+ if (netPack.MoneyList.Length != 0)
+ {
+ for (int i = 0; i < netPack.MoneyLen; i++)
+ {
+ var moneyType = netPack.MoneyList[i].MoneyType;
+ if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType) && netPack.MoneyList[i].MoneyValue != 0)
+ {
+ showItems.Add(new Item(GeneralDefine.moneyDisplayIds[moneyType], netPack.MoneyList[i].MoneyValue));
+ }
+
+ }
+ }
+
+ if (netPack.ItemList.Length != 0)
+ {
+ for (int i = 0; i < netPack.ItemLen; i++)
+ {
+ showItems.Add(new Item((int)netPack.ItemList[i].ItemID, netPack.ItemList[i].Count, netPack.ItemList[i].IsBind));
+ }
+ }
+
+
+ string info = string.Empty;
+ if (LanguageConfig.HasKey("commonShowAwardEvents_" + eventName))
+ info = Language.Get("commonShowAwardEvents_" + eventName);
+
+ if (showItems.Count == 0)
+ return;
+
+ ItemLogicUtility.Instance.ShowGetItem(showItems, info, 0, eventName: eventName);
+ }
+}
--
Gitblit v1.8.0