| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using LitJson;
|
| | | using TableConfig;
|
| | | using UnityEngine;
|
| | |
| | | {
|
| | | 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;//首冲试用结束
|
| | |
|
| | |
| | |
|
| | | public readonly int VipExperirnceID = 985;
|
| | | public readonly int VipCardID = 978;
|
| | |
|
| | | Dictionary<int, Dictionary<int, List<ItemModel>>> allGuardDict = new Dictionary<int, Dictionary<int, List<ItemModel>>>(); //守护类型,守护ID
|
| | | public override void Init()
|
| | | {
|
| | | SysNotifyMgr.Instance.sysNotifyEvent += GetSysNotify;
|
| | |
| | | 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":
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | | isOverdue = false;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (isOverdue)
|
| | | models = allGuardDict[type][idlist[idlist.Count - 1]];
|
| | | if (isOverdue && models != null && models.Count > 0)
|
| | | {
|
| | | guardItemlist.Add(itemModel);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (guardItemlist.Count > 0)
|
| | | ItemModel itemModel = models[0];
|
| | | if (!overdueGuardPushlist.Contains(itemModel))
|
| | | {
|
| | | guardItemlist.Sort(CompareItemID);
|
| | | OnGetOverdueItem(guardItemlist[0].itemInfo.ItemID, guardItemlist[0].itemInfo.ItemGUID, guardItemlist[0].itemInfo.ItemPlace);
|
| | | overdueGuardPushlist.Add(itemModel);
|
| | | }
|
| | | }
|
| | |
|
| | | public int CompareItemID(ItemModel start, ItemModel end)
|
| | | }
|
| | | for(int i = 0; i < overdueGuardPushlist.Count; i++)
|
| | | {
|
| | | int startId = start.itemInfo.ItemID;
|
| | | int endId = end.itemInfo.ItemID;
|
| | | if (startId.CompareTo(endId) != 0)
|
| | | return -startId.CompareTo(endId);
|
| | |
|
| | | return 0;
|
| | | OnGetOverdueItem(overdueGuardPushlist[i].itemInfo.ItemID, overdueGuardPushlist[i].itemInfo.ItemGUID, overdueGuardPushlist[i].itemInfo.ItemPlace);
|
| | | }
|
| | | }
|
| | |
|
| | | public bool IsMoneyEnough(int moneyType, int needMoney)
|
| | |
| | | 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;
|