From f12a20e66eda4e6cddbf850dede6b8b66fb0e34a Mon Sep 17 00:00:00 2001
From: Client_PangDeRong <593317293@qq.com>
Date: 星期三, 19 九月 2018 11:03:47 +0800
Subject: [PATCH] 3650 守护过期提醒逻辑优化
---
System/KnapSack/Logic/ItemOverdueModel.cs | 158 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 103 insertions(+), 55 deletions(-)
diff --git a/System/KnapSack/Logic/ItemOverdueModel.cs b/System/KnapSack/Logic/ItemOverdueModel.cs
index cb48871..e946db1 100644
--- a/System/KnapSack/Logic/ItemOverdueModel.cs
+++ b/System/KnapSack/Logic/ItemOverdueModel.cs
@@ -1,6 +1,7 @@
锘縰sing System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using LitJson;
using TableConfig;
using UnityEngine;
@@ -9,7 +10,7 @@
{
public class ItemOverdueModel : Model,IBeforePlayerDataInitialize,IPlayerLoginOk, ISwitchAccount
{
- private List<ItemModel> guardItemlist = new List<ItemModel>();
+ private List<ItemModel> overdueGuardPushlist = new List<ItemModel>();
private Dictionary<int, List<int>> itemOverdueDict;
public static event Action FirstGoldWPOver;//棣栧啿璇曠敤缁撴潫
@@ -37,7 +38,7 @@
public readonly int VipExperirnceID = 985;
public readonly int VipCardID = 978;
-
+ Dictionary<int, Dictionary<int, List<ItemModel>>> allGuardDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>(); //瀹堟姢绫诲瀷锛屽畧鎶D
public override void Init()
{
SysNotifyMgr.Instance.sysNotifyEvent += GetSysNotify;
@@ -191,23 +192,49 @@
switch (sysID)
{
case "Guardian_Timeout":
- DebugEx.Log("Guardian_Timeout:" + list.Count);
if (list.Count > 1)
{
guardOverdueIndex = int.Parse(list[1].ToString());
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem, guardOverdueIndex);
if (itemModel != null)
{
- if (itemModel.chinItemModel.EquipPlace == (int)RoleEquipType.retSpiritAnimal)
+ List<int> renewallist = GetRenewallist(itemModel.itemId);
+ if(renewallist != null && allGuardDict.ContainsKey(renewallist[0]))
{
- OnGetOverdueItem(itemModel.itemInfo.ItemID,itemModel.itemInfo.ItemGUID,itemModel.itemInfo.ItemPlace);
+ Dictionary<int, List<ItemModel>> pairs = allGuardDict[renewallist[0]];
+ bool isOverdue = true;
+ List<int> idlist = pairs.Keys.ToList();
+ idlist.Sort();
+ List<ItemModel> models = null;
+ for (int i = idlist.Count - 1; i > -1; i--)
+ {
+ models = pairs[idlist[i]];
+ for (int j = 0; j < models.Count; j++)
+ {
+ if (!modelInterface.IsOverdue(models[j].itemInfo.ItemGUID, models[j].itemId, models[j].useDataDict))
+ {
+ isOverdue = false;
+ break;
+ }
+ }
+ }
+ models = pairs[idlist[idlist.Count - 1]];
+ if (isOverdue && models != null && models.Count > 0)
+ {
+ ItemModel overdueModel = models[0];
+ guardOverdueIndex = overdueModel.itemInfo.ItemPlace;
+ OnGetOverdueItem(overdueModel.itemInfo.ItemID, overdueModel.itemInfo.ItemGUID, overdueModel.itemInfo.ItemPlace);
+ }
+ else
+ {
+ guardOverdueIndex = -1;
+ }
}
}
}
break;
case "VipTiyan_Timeout":
-
OnGetOverdueItem(VipExperirnceID, "", -1);
break;
case "Vip_Timeout":
@@ -232,65 +259,41 @@
public void GetOverdueGuard()
{
- guardItemlist.Clear();
- List<string> itemEffectlist = modelInterface.GetItemEffectTimelist();
- int i = 0;
- for (i = 0; i < itemEffectlist.Count; i++)
+ SetAllGuardIdlist();
+ overdueGuardPushlist.Clear();
+ foreach(var type in allGuardDict.Keys)
{
- ItemModel itemModel = playerPack.GetItemModelByGUID(itemEffectlist[i]);
- if (itemModel != null && itemModel.packType == PackType.rptItem)
+ bool isOverdue = true;
+ List<int> idlist = allGuardDict[type].Keys.ToList();
+ idlist.Sort();
+ List<ItemModel> models = null;
+ for (int i = idlist.Count - 1; i > -1; i--)
{
- if (itemModel.chinItemModel.EquipPlace == (int)RoleEquipType.retSpiritAnimal)
+ models = allGuardDict[type][idlist[i]];
+ for (int j = 0; j < models.Count; j++)
{
- bool isOverdue = false;
- ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.itemInfo.ItemGUID);
- if (itemModel.chinItemModel.ExpireTime > 0)
+ if (!modelInterface.IsOverdue(models[j].itemInfo.ItemGUID, models[j].itemId, models[j].useDataDict))
{
- switch ((EquipReduceType)itemModel.chinItemModel.EndureReduceType)
- {
- case EquipReduceType.Def_EquipReduceType_Time:
- List<int> itemEffectTime = itemModel.GetUseDataModel((int)ItemUseDataKey.Def_IudetCreateTime);
- if (itemEffectTime != null && itemEffectTime[0] != 0)
- {
- if (cool == null || cool.GetRemainTime() <= 0)
- {
- isOverdue = true;
- }
- }
- break;
-
- case EquipReduceType.Def_EquipReduceType_RTimeItem:
- if (cool == null || cool.GetRemainTime() <= 0)
- {
- isOverdue = true;
- }
- break;
- }
- }
-
- if (isOverdue)
- {
- guardItemlist.Add(itemModel);
+ isOverdue = false;
+ break;
}
}
}
- }
- if (guardItemlist.Count > 0)
+ models = allGuardDict[type][idlist[idlist.Count - 1]];
+ if (isOverdue && models != null && models.Count > 0)
+ {
+ ItemModel itemModel = models[0];
+ if (!overdueGuardPushlist.Contains(itemModel))
+ {
+ overdueGuardPushlist.Add(itemModel);
+ }
+ }
+ }
+ for(int i = 0; i < overdueGuardPushlist.Count; i++)
{
- guardItemlist.Sort(CompareItemID);
- OnGetOverdueItem(guardItemlist[0].itemInfo.ItemID, guardItemlist[0].itemInfo.ItemGUID, guardItemlist[0].itemInfo.ItemPlace);
+ OnGetOverdueItem(overdueGuardPushlist[i].itemInfo.ItemID, overdueGuardPushlist[i].itemInfo.ItemGUID, overdueGuardPushlist[i].itemInfo.ItemPlace);
}
- }
-
- public int CompareItemID(ItemModel start, ItemModel end)
- {
- int startId = start.itemInfo.ItemID;
- int endId = end.itemInfo.ItemID;
- if (startId.CompareTo(endId) != 0)
- return -startId.CompareTo(endId);
-
- return 0;
}
public bool IsMoneyEnough(int moneyType, int needMoney)
@@ -302,6 +305,51 @@
return false;
}
+ public void SetAllGuardIdlist()
+ {
+ allGuardDict.Clear();
+ foreach(var id in itemOverdueDict.Keys)
+ {
+ SetGurdIdlistByPack(PackType.rptItem,id);
+ SetGurdIdlistByPack(PackType.rptEquip,id);
+ SetGurdIdlistByPack(PackType.rptWarehouse,id);
+ }
+ }
+
+ private void SetGurdIdlistByPack(PackType type,int itemId)
+ {
+ SinglePackModel singlePack = playerPack.GetSinglePackModel(type);
+ if (singlePack == null) return;
+ List<ItemModel> itemModels = null;
+ singlePack.GetItemCountByID(itemId, out itemModels);
+ if (itemModels == null) return;
+
+ List<int> renewallist = GetRenewallist(itemId);
+ if (renewallist == null) return;
+
+ if (!allGuardDict.ContainsKey(renewallist[0]))
+ {
+ Dictionary<int, List<ItemModel>> pairs = new Dictionary<int, List<ItemModel>>();
+ List<ItemModel> modellist = new List<ItemModel>();
+ modellist.AddRange(itemModels);
+ pairs.Add(itemId,modellist);
+ allGuardDict.Add(renewallist[0],pairs);
+ }
+ else
+ {
+ if(!allGuardDict[renewallist[0]].ContainsKey(itemId))
+ {
+ List<ItemModel> modellist = new List<ItemModel>();
+ modellist.AddRange(itemModels);
+ allGuardDict[renewallist[0]].Add(itemId, modellist);
+ }
+ else
+ {
+ allGuardDict[renewallist[0]][itemId].AddRange(itemModels);
+ }
+ }
+ }
+
public List<int> GetRenewallist(int itemID)
{
List<int> renewallist = null;
--
Gitblit v1.8.0