using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
using LitJson;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class PlayerPackModel : 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 = "";
|
public int MaxBagGridCnt { get; private set; }
|
public int InitBagGridCnt { get; private set; }
|
public int MaxDepotGridCnt { get; private set; }
|
public int InitDepotGridCnt { get; private set; }
|
List<int> LocalSavePlaceArray { get; set; }
|
Dictionary<int, List<int>> ShareUseCntItemDict { get; set; }
|
bool isUpdatePlayerLv = false;
|
|
BlastFurnaceModel FurnaceModel { get { return ModelCenter.Instance.GetModel<BlastFurnaceModel>(); } }
|
|
public override void Init()
|
{
|
ParseConfig();
|
List<DungeonOpenTimeConfig> dungeonlist = DungeonOpenTimeConfig.GetValues();
|
if (dungeonlist != null)
|
{
|
DrugToDungeonDict = new Dictionary<int, int>();
|
DungeonToDrugDict = new Dictionary<int, int[]>();
|
|
for (int i = 0; i < dungeonlist.Count; i++)
|
{
|
int[] drugIdlist = dungeonlist[i].ElixirHint;
|
if (drugIdlist != null && drugIdlist.Length > 0)
|
{
|
DungeonToDrugDict.Add(dungeonlist[i].DataMapID, drugIdlist);
|
for (int j = 0; j < drugIdlist.Length; j++)
|
{
|
DrugToDungeonDict.Add(drugIdlist[j], dungeonlist[i].DataMapID);
|
}
|
|
}
|
}
|
}
|
|
makeDruglist = new List<AttrFruitConfig>();
|
List<AttrFruitConfig> fruitlist = AttrFruitConfig.GetValues();
|
for (int i = 0; i < fruitlist.Count; i++)
|
{
|
if (fruitlist[i].FuncID == 2)
|
{
|
makeDruglist.Add(fruitlist[i]);
|
}
|
}
|
StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
|
|
SetDevourEquipPlace();
|
|
decomposeAttrDict.Clear();
|
List<EquipDeComposeConfig> decomlist = EquipDeComposeConfig.GetValues();
|
for (int i = 0; i < decomlist.Count; i++)
|
{
|
JsonData attrData = JsonMapper.ToObject(decomlist[i].Attr);
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
decomposeAttrDict.Add(decomlist[i].LV, attrDict);
|
foreach (var id in attrData.Keys)
|
{
|
attrDict.Add(int.Parse(id), int.Parse(attrData[id].ToString()));
|
}
|
}
|
|
FuncConfigConfig equipDecompose = FuncConfigConfig.Get("EquipDevourCount");
|
minDecomposeNum = int.Parse(equipDecompose.Numerical1);
|
defaultUnSelectlist = ConfigParse.GetMultipleStr<int>(equipDecompose.Numerical2);
|
|
FuncConfigConfig ShareUseCntItem = FuncConfigConfig.Get("ShareUseCntItem");
|
ShareUseCntItemDict = 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>();
|
ShareUseCntItemDict.Add(i, idlist);
|
foreach (var id in idListJson)
|
{
|
idlist.Add(int.Parse(id.ToString()));
|
}
|
}
|
}
|
|
InitDepotGridCnt = int.Parse(FuncConfigConfig.Get("InitDepotCellCount").Numerical1);
|
InitBagGridCnt = int.Parse(FuncConfigConfig.Get("InitBagCellCount").Numerical1);
|
MaxBagGridCnt = int.Parse(FuncConfigConfig.Get("MaxBagCellCount").Numerical1);
|
MaxDepotGridCnt = int.Parse(FuncConfigConfig.Get("MaxDepotCellCount").Numerical1);
|
SetRoleEquipRedpoint();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= UpdatePlayerLv;
|
LocalSave.DeleteKey(RecordKnapsackTitle);
|
cacheMapId = 0;
|
playerPackDict.Clear();
|
itemDayUseCntDict.Clear();
|
itemSumUseCntDict.Clear();
|
itemGUIDDict.Clear();
|
showDropItem = false;
|
isPlayBetterEquipEffect = false;
|
equipAttrActiveDict.Clear();
|
colorType = EquipColorType.Purple;
|
lvType = EquipLvType.All;
|
starType = EquipStarType.None;
|
decomposeLv = 1;
|
decomposeExp = 0;
|
decomposeProgress = 0;
|
isAutoDecompose = false;
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
ItemLogicUtility.Instance.SendOpenWarehouse();
|
SetPlayerAttrActiveRedPoint();
|
EquipDecomRedCtrl();
|
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.PlayerDataRefreshInfoEvent += UpdatePlayerLv;
|
isUpdatePlayerLv = true;
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
PackModelInterface _modelInterface;
|
PackModelInterface modelInterface {
|
get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel {
|
get {
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
public event Action<PackType> RefreshPackAct; //刷新整个背包数据
|
public event Action<PackType, int, int> RefreshItemCountAct; //(单个)最新物品数量刷新(旧的弃用)在得到新物品、物品数量的改变,清理该物品时均会触发 int 位置索引 int物品id
|
public event Action<PackType> GridRefreshEvent; //背包空格刷新
|
public event Action<PackType, int, int> ItemCntAddAct; //物品数量增加 int 位置索引 int物品id
|
public event Action<PackType, int, int> ItemCntReduceAct; //物品数量减少的改变 int 位置索引 int物品id
|
public event Action<int, int> UseItemSuccessAct; //物品使用成功 int 位置索引 int物品id
|
|
public event Action<int> RefreshItemDayUseCntAct; //刷新物品每日使用数量
|
public event Action<int> RefreshItemSumUseCntAct; //刷新物品总使用数量
|
|
public bool isPlayBetterEquipEffect { get; set; } //整理背包时是否播放特效
|
|
#region 接收服务端数据
|
public bool showDropItem { get; private set; }
|
private Dictionary<PackType, SinglePackModel> playerPackDict = new Dictionary<PackType, SinglePackModel>();
|
private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
|
public void SetPlayerPackModel(H0725_tagRolePackRefreshEx packInfo)
|
{
|
showDropItem = false;
|
SetLookIndex(null);
|
PackType type = (PackType)packInfo.PackType;
|
if (!playerPackDict.ContainsKey(type))
|
{
|
SinglePackModel packModel = new SinglePackModel(type);
|
playerPackDict.Add(type, packModel);
|
}
|
|
if (isPlayBetterEquipEffect)
|
{
|
modelInterface.itemModelDict.Clear();
|
}
|
for (int i = 0; i < packInfo.ItemCount; i++)
|
{
|
|
ItemInfo itemInfo = new ItemInfo();
|
itemInfo.ItemID = (int)packInfo.ItemInfo[i].ItemID;
|
itemInfo.ItemPlace = packInfo.ItemInfo[i].ItemPlace;
|
itemInfo.ItemCount = packInfo.ItemInfo[i].ItemCount;
|
itemInfo.RemainHour = (int)packInfo.ItemInfo[i].RemainHour;
|
itemInfo.IsBind = packInfo.ItemInfo[i].IsBind;
|
itemInfo.IsSuite = packInfo.ItemInfo[i].IsSuite;
|
itemInfo.UserData = packInfo.ItemInfo[i].UserData;
|
itemInfo.IsLocked = packInfo.ItemInfo[i].IsLocked;
|
itemInfo.ItemGUID = packInfo.ItemInfo[i].ItemGUID;
|
playerPackDict[type].SetPackModel(itemInfo);
|
|
if (isPlayBetterEquipEffect)
|
{
|
modelInterface.SetBagSortBetterEquipList(GetItemModelByGUID(itemInfo.ItemGUID));
|
}
|
}
|
|
if (RefreshPackAct != null)
|
{
|
RefreshPackAct(type);
|
}
|
|
RedPointPackCtrl(type);
|
}
|
|
public void SetItemModel(H0704_tagRolePackRefresh item)
|
{
|
isPlayBetterEquipEffect = false;
|
SetLookIndex(null);
|
showDropItem = true;
|
PackType type = (PackType)item.PackType;
|
if (!playerPackDict.ContainsKey(type))
|
{
|
SinglePackModel packModel = new SinglePackModel(type);
|
playerPackDict.Add(type, packModel);
|
}
|
|
ItemInfo itemInfo = new ItemInfo();
|
itemInfo.ItemID = (int)item.ItemID;
|
itemInfo.ItemPlace = item.ItemPlace;
|
itemInfo.ItemCount = item.ItemCount;
|
itemInfo.RemainHour = (int)item.RemainHour;
|
itemInfo.IsBind = item.IsBind;
|
itemInfo.IsSuite = item.IsSuite;
|
itemInfo.UserData = item.UserData;
|
itemInfo.IsLocked = item.IsLocked;
|
itemInfo.ItemGUID = item.ItemGUID;
|
playerPackDict[type].SetPackModel(itemInfo);
|
DebugEx.Log("Add:" + item.ItemGUID);
|
if (RefreshItemCountAct != null)
|
{
|
RefreshItemCountAct(type, itemInfo.ItemPlace, itemInfo.ItemID);
|
}
|
|
if (ItemCntAddAct != null)
|
{
|
ItemCntAddAct(type, itemInfo.ItemPlace, itemInfo.ItemID);
|
}
|
if (type == PackType.Equip)
|
{
|
SetPlayerAttrActiveRedPoint();
|
}
|
RedPointPackCtrl(type);
|
EquipDecomRedCtrl();
|
}
|
|
public void SetOpenGridCount(H0724_tagRolePackCanUseCount useCount)
|
{
|
PackType type = (PackType)useCount.PackType;
|
if (!playerPackDict.ContainsKey(type))
|
{
|
SinglePackModel packModel = new SinglePackModel(type);
|
playerPackDict.Add(type, packModel);
|
}
|
|
playerPackDict[type].SetOpenGridCount(useCount.CanUseCount);
|
|
if (GridRefreshEvent != null)
|
{
|
GridRefreshEvent(type);
|
}
|
|
RedPointPackCtrl(type);
|
}
|
|
public void RefreshItemCount(H0707_tagItemCountRefresh refresh)
|
{
|
SetLookIndex(null);
|
isPlayBetterEquipEffect = false;
|
PackType type = (PackType)refresh.PackType;
|
SinglePackModel singlePack = null;
|
playerPackDict.TryGetValue(type, out singlePack);
|
if (singlePack != null)
|
{
|
ItemModel itemModel = singlePack.GetItemModelByIndex(refresh.ItemIndex);
|
if (itemModel != null)
|
{
|
bool isAddItemCount = false;
|
if (refresh.ItemCount > itemModel.itemInfo.ItemCount)
|
{
|
isAddItemCount = true;
|
}
|
itemModel.RefreshItemCount(refresh.ItemCount);
|
|
if (isAddItemCount)
|
{
|
if (ItemCntAddAct != null)
|
{
|
ItemCntAddAct(type, itemModel.itemPlace, itemModel.itemId);
|
}
|
modelInterface.GetPreciousItem(itemModel);
|
modelInterface.RefreshPickItem(type, itemModel.itemInfo.ItemGUID);
|
}
|
else
|
{
|
if (ItemCntReduceAct != null)
|
{
|
ItemCntReduceAct(type, itemModel.itemPlace, itemModel.itemId);
|
}
|
}
|
|
if (RefreshItemCountAct != null)
|
{
|
RefreshItemCountAct(type, itemModel.itemPlace, itemModel.itemId);
|
}
|
}
|
}
|
|
|
}
|
|
public void ClearPackModel(H0711_tagClearItemPack clearPack)
|
{
|
PackType type = (PackType)clearPack.PackIndex;
|
SinglePackModel singlePack = null;
|
playerPackDict.TryGetValue(type, out singlePack);
|
if (singlePack != null)
|
{
|
singlePack.ClearPackModel();
|
}
|
|
if (type == PackType.Equip)
|
{
|
SetPlayerAttrActiveRedPoint();
|
}
|
//if (RefreshPackAct != null)
|
//{
|
// RefreshPackAct(type);
|
//}
|
|
//RedPointPackCtrl(type);
|
}
|
|
public void ClearItemModel(H0709_tagClearItem clearItem)
|
{
|
isPlayBetterEquipEffect = false;
|
SetLookIndex(null);
|
PackType type = (PackType)clearItem.PackType;
|
|
SinglePackModel singlePack = null;
|
playerPackDict.TryGetValue(type, out singlePack);
|
string guid = "";
|
if (singlePack != null)
|
{
|
ItemModel itemModel = singlePack.GetItemModelByIndex(clearItem.ItemIndex);
|
guid = itemModel.itemInfo.ItemGUID;
|
int itemId = itemModel.itemId;
|
DeleteItemDictByGUID(type, itemModel.itemInfo.ItemGUID);
|
singlePack.ClearItemModelByIndex(clearItem.ItemIndex);
|
if (RefreshItemCountAct != null)
|
{
|
RefreshItemCountAct(type, clearItem.ItemIndex, itemId);
|
}
|
|
if (ItemCntReduceAct != null)
|
{
|
ItemCntReduceAct(type, clearItem.ItemIndex, itemId);
|
}
|
}
|
if (type == PackType.Equip)
|
{
|
SetPlayerAttrActiveRedPoint();
|
}
|
RedPointPackCtrl(type);
|
EquipDecomRedCtrl();
|
|
if (GetItemModelByGUID(guid) == null)
|
{
|
KnapsackTimeCDMgr.Instance.UnRegister(guid);
|
}
|
|
}
|
|
public void PackResetOk(H0316_tagPackResetOK packreset)
|
{
|
modelInterface.isPackResetOk = true;
|
}
|
|
public void UseItemSuccess(H0706_tagUseItemSuccess success)
|
{
|
isPlayBetterEquipEffect = false;
|
SetLookIndex(null);
|
if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID)
|
return;
|
|
ItemConfig itemConfig = ItemConfig.Get((int)success.ItemID);
|
MakeUseItemSuccess(success.ItemIndex, (int)success.ItemID);
|
|
switch (success.ItemID)
|
{
|
case 221:
|
if (WindowCenter.Instance.IsOpen<KnapSackWin>())
|
{
|
WindowCenter.Instance.Close<KnapSackWin>();
|
}
|
break;
|
}
|
|
if (UseItemSuccessAct != null)
|
{
|
UseItemSuccessAct(success.ItemIndex, (int)success.ItemID);
|
}
|
}
|
|
private void MakeUseItemSuccess(int index, int id)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(id);
|
if (itemConfig.CDType != 0)
|
{
|
float configCdTime = (float)Math.Round((double)itemConfig.CDTime / 1000, 1);
|
List<ItemModel> modellist = null;
|
GetSinglePackModel(PackType.Item).GetItemCountByType((int)ItemType.Buff, out modellist);
|
for (int i = 0; i < modellist.Count; i++)
|
{
|
if (modellist[i].itemId == 901
|
|| modellist[i].itemId == 902
|
|| modellist[i].itemId == 903
|
|| modellist[i].itemId == 904)
|
{
|
KnapsackTimeCDMgr.Instance.Register(modellist[i].itemInfo.ItemGUID, modellist[i].itemId, configCdTime);
|
break;
|
}
|
}
|
|
}
|
}
|
|
public void SetItemGUIDDict(ItemModel itemModel)
|
{
|
if (!itemGUIDDict.ContainsKey(itemModel.itemInfo.ItemGUID))
|
{
|
itemGUIDDict.Add(itemModel.itemInfo.ItemGUID, itemModel);
|
GetItemEventCtrl(itemModel);
|
}
|
else
|
{
|
PackType prePack = itemGUIDDict[itemModel.itemInfo.ItemGUID].packType;
|
itemGUIDDict[itemModel.itemInfo.ItemGUID] = itemModel;
|
if (prePack != itemModel.packType)
|
{
|
GetItemEventCtrl(itemModel);
|
}
|
}
|
}
|
|
public 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 SetItemUseCnt(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 (RefreshItemDayUseCntAct != null)
|
{
|
RefreshItemDayUseCntAct(itemId);
|
}
|
|
}
|
}
|
|
private Dictionary<int, int> itemSumUseCntDict = new Dictionary<int, int>();
|
public void SetItemSumUseCnt(HA339_tagMCAttrFruitEatCntList useCntInfo)
|
{
|
for (int i = 0; i < useCntInfo.count; i++)
|
{
|
int itemId = (int)useCntInfo.EatCntList[i].ItemID;
|
int cnt = useCntInfo.EatCntList[i].EatCnt;
|
if (!itemSumUseCntDict.ContainsKey(itemId))
|
{
|
itemSumUseCntDict.Add(itemId, cnt);
|
}
|
else
|
{
|
itemSumUseCntDict[itemId] = cnt;
|
}
|
|
if (RefreshItemSumUseCntAct != null)
|
{
|
RefreshItemSumUseCntAct(itemId);
|
}
|
|
}
|
}
|
|
#region 接收全身星级,强化属性激活
|
public event Action RefreshActiveAttrAct;
|
private Dictionary<int, int> equipAttrActiveDict = new Dictionary<int, int>();
|
public void SetPlayerEquipAttrActiveInfo(HA317_tagMCAllEquipAttrActiveInfo info)
|
{
|
for (int i = 0; i < info.Count; i++)
|
{
|
int type = info.ActiveInfo[i].Type;
|
int cnt = (int)info.ActiveInfo[i].Cnt;
|
if (type == 1)
|
{
|
cnt = RoleEquipStarsConfig.GetActiveStars(cnt);
|
}
|
if (!equipAttrActiveDict.ContainsKey(type))
|
{
|
equipAttrActiveDict.Add(type, cnt);
|
}
|
else
|
{
|
equipAttrActiveDict[type] = cnt;
|
}
|
}
|
|
if (RefreshActiveAttrAct != null)
|
{
|
RefreshActiveAttrAct();
|
}
|
|
SetPlayerAttrActiveRedPoint();
|
}
|
|
public void SendActiveAttrQuest(int type, int cnt)
|
{
|
CA503_tagCMActiveAllEquipAttr equipAttr = new CA503_tagCMActiveAllEquipAttr();
|
equipAttr.Type = (byte)type;
|
equipAttr.Cnt = (uint)cnt;
|
GameNetSystem.Instance.SendInfo(equipAttr);
|
}
|
|
public int GetActiveCntByType(int type)
|
{
|
int cnt = 0;
|
equipAttrActiveDict.TryGetValue(type, out cnt);
|
return cnt;
|
}
|
|
public List<int> GetAddAttrIdByStars(int _curStarsCount, out int starsCount)
|
{
|
starsCount = 0;
|
List<int> activeIdlist = new List<int>();
|
List<int> addIdlist = new List<int>();
|
List<int> starslist = RoleEquipStarsConfig.GetEquipStarsCntlist();
|
if (starslist == null || starslist.Count < 1) return addIdlist;
|
int activeStars = GetActiveCntByType(1);
|
int realActiveStars = _curStarsCount > activeStars ? activeStars : _curStarsCount;
|
for (int i = starslist.Count - 1; i > -1; i--)
|
{
|
if (i == 0 && starslist[i] > realActiveStars)
|
{
|
realActiveStars = 0;
|
break;
|
}
|
if (starslist[i] <= realActiveStars)
|
{
|
realActiveStars = starslist[i];
|
break;
|
}
|
}
|
|
RoleEquipStarsConfig activeStarsConfig = RoleEquipStarsConfig.GetEquipStarsModel(realActiveStars);
|
if (activeStarsConfig != null)
|
{
|
for (int i = 0; i < activeStarsConfig.attType.Length; i++)
|
{
|
activeIdlist.Add(activeStarsConfig.attType[i]);
|
}
|
}
|
List<RoleEquipStarsConfig> starsConfigs = RoleEquipStarsConfig.GetValues();
|
for (int i = 0; i < starsConfigs.Count; i++)
|
{
|
bool isAddId = false;
|
RoleEquipStarsConfig starsConfig = starsConfigs[i];
|
if (realActiveStars < starsConfig.countNeed)
|
{
|
for (int j = 0; j < starsConfig.attType.Length; j++)
|
{
|
int attrId = starsConfig.attType[j];
|
if (!activeIdlist.Contains(attrId))
|
{
|
isAddId = true;
|
addIdlist.Add(attrId);
|
}
|
}
|
}
|
if (isAddId)
|
{
|
starsCount = starsConfig.countNeed;
|
break;
|
}
|
|
}
|
return addIdlist;
|
}
|
#endregion
|
|
#endregion
|
|
#region 玩家装备特殊逻辑
|
public int fairyRedPointLvlimt { get; private set; }
|
public int wingsRedpointLvlimt { get; private set; }
|
public int fairyGetPathId { get; private set; }
|
public Dictionary<int, int> wingsGetPathIdDict { get; private set; }
|
public Dictionary<int, List<int>> dungeonUseDict { get; private set; }
|
public void ParseConfig()
|
{
|
FuncConfigConfig funcConfig = FuncConfigConfig.Get("WingYuPeiHQTJ");
|
fairyRedPointLvlimt = int.Parse(funcConfig.Numerical1);
|
wingsRedpointLvlimt = int.Parse(funcConfig.Numerical2);
|
fairyGetPathId = int.Parse(funcConfig.Numerical3);
|
wingsGetPathIdDict = ConfigParse.GetDic<int, int>(funcConfig.Numerical4);
|
FuncConfigConfig copyItemBulletWindow = FuncConfigConfig.Get("CopyItemBulletWindow");
|
JsonData copyWinData = JsonMapper.ToObject(copyItemBulletWindow.Numerical1);
|
dungeonUseDict = new Dictionary<int, List<int>>();
|
foreach (var dungeonId in copyWinData.Keys)
|
{
|
List<int> idlist = new List<int>();
|
dungeonUseDict.Add(int.Parse(dungeonId), idlist);
|
if (copyWinData[dungeonId].IsArray)
|
{
|
JsonData useData = copyWinData[dungeonId];
|
for (int i = 0; i < useData.Count; i++)
|
{
|
idlist.Add(int.Parse(useData[i].ToString()));
|
}
|
}
|
}
|
}
|
|
public int GetRoleEquipPathId(int equipPlace)
|
{
|
int playerJob = PlayerDatas.Instance.baseData.Job;
|
switch ((RoleEquipType)equipPlace)
|
{
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.FairyCan2:
|
return fairyGetPathId;
|
case RoleEquipType.Wing:
|
if (wingsGetPathIdDict.ContainsKey(playerJob))
|
{
|
return wingsGetPathIdDict[playerJob];
|
}
|
break;
|
}
|
return 0;
|
}
|
|
private void UpdateSecond()
|
{
|
if (isUpdatePlayerLv)
|
{
|
for (int i = 1; i < 13; i++)
|
{
|
CheckRoleEquipByPlace((RoleEquipType)i);
|
}
|
UpdateRoleEquipRed();
|
isUpdatePlayerLv = false;
|
}
|
}
|
|
private void UpdatePlayerLv(PlayerDataRefresh type)
|
{
|
if (type != PlayerDataRefresh.LV) return;
|
|
isUpdatePlayerLv = true;
|
}
|
|
public bool IsShowAddEquipByPlace(int equipPlace)
|
{
|
switch ((RoleEquipType)equipPlace)
|
{
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.FairyCan2:
|
if (PlayerDatas.Instance.baseData.LV >= fairyRedPointLvlimt)
|
{
|
return true;
|
}
|
break;
|
case RoleEquipType.Wing:
|
if (PlayerDatas.Instance.baseData.LV >= wingsRedpointLvlimt)
|
{
|
return true;
|
}
|
break;
|
}
|
return false;
|
}
|
|
public void CheckRoleEquipByPlace(RoleEquipType equipType)
|
{
|
ItemModel itemModel = GetItemModelByIndex(PackType.Equip, (int)equipType);
|
switch (equipType)
|
{
|
case RoleEquipType.FairyCan:
|
case RoleEquipType.FairyCan2:
|
if (PlayerDatas.Instance.baseData.LV >= fairyRedPointLvlimt && itemModel != null)
|
{
|
SetRoleEquipLocalSave((int)equipType);
|
}
|
break;
|
case RoleEquipType.Wing:
|
if (PlayerDatas.Instance.baseData.LV >= wingsRedpointLvlimt && itemModel != null)
|
{
|
SetRoleEquipLocalSave((int)equipType);
|
}
|
break;
|
|
}
|
}
|
|
public void SetRoleEquipLocalSave(int equipPlace, bool isRedState = false)
|
{
|
if (isRedState && roleEquipRedDict[equipPlace].state == RedPointState.None) return;
|
|
if (LocalSavePlaceArray != null)
|
{
|
if (!LocalSavePlaceArray.Contains(equipPlace))
|
{
|
LocalSavePlaceArray.Add(equipPlace);
|
LocalSave.SetIntArray(RoleEquipLocalSave, LocalSavePlaceArray.ToArray());
|
}
|
}
|
else
|
{
|
LocalSavePlaceArray = new List<int>();
|
LocalSavePlaceArray.Add(equipPlace);
|
LocalSave.SetIntArray(RoleEquipLocalSave, LocalSavePlaceArray.ToArray());
|
}
|
}
|
#endregion
|
|
private void GetItemEventCtrl(ItemModel itemModel)
|
{
|
if (showDropItem)
|
{
|
bool isOverdue = false;
|
if (itemModel.config.ExpireTime > 0)
|
{
|
ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.itemInfo.ItemGUID);
|
switch ((EquipReduceType)itemModel.config.EndureReduceType)
|
{
|
case EquipReduceType.Def_EquipReduceType_Time:
|
List<int> itemEffectTime = itemModel.GetUseDataModel((int)ItemUseDataKey.createTime);
|
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)
|
{
|
modelInterface.GetPreciousItem(itemModel);
|
modelInterface.OnGetEquip(itemModel);
|
modelInterface.RefreshPickItem(itemModel.packType, itemModel.itemInfo.ItemGUID);
|
}
|
}
|
|
}
|
|
/// <summary>
|
/// 得到某个包裹的所有数据
|
/// </summary>
|
/// <param name="type"></param>
|
/// <returns></returns>
|
public SinglePackModel GetSinglePackModel(PackType type)
|
{
|
SinglePackModel singlePack = null;
|
playerPackDict.TryGetValue(type, out singlePack);
|
return singlePack;
|
}
|
|
public ItemModel GetItemModelByGUID(string guid)
|
{
|
ItemModel itemModel = null;
|
itemGUIDDict.TryGetValue(guid, out itemModel);
|
return itemModel;
|
}
|
|
public ItemModel GetItemModelByIndex(PackType type, int index)
|
{
|
switch (type)
|
{
|
case PackType.JadeDynastyEquip:
|
if (index >= 121)
|
{
|
index = index - 121;
|
}
|
break;
|
}
|
|
ItemModel itemModel = null;
|
if (playerPackDict.ContainsKey(type))
|
{
|
itemModel = playerPackDict[type].GetItemModelByIndex(index);
|
}
|
return itemModel;
|
}
|
|
public List<ItemModel> GetItemModelsById(PackType type, int id)
|
{
|
List<ItemModel> itemModels = null;
|
if (playerPackDict.ContainsKey(type))
|
{
|
var singlePack = playerPackDict[type];
|
singlePack.GetItemCountByID(id, out itemModels);
|
}
|
return itemModels;
|
}
|
|
public string GetItemGUIDByID(int itemId)
|
{
|
string guid = string.Empty;
|
|
foreach (var key in itemGUIDDict.Keys)
|
{
|
if (itemGUIDDict[key].itemId == itemId)
|
{
|
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)
|
{
|
int count = 0;
|
SinglePackModel singlePack = GetSinglePackModel(type);
|
if (singlePack != null)
|
{
|
count = singlePack.GetItemCountByID(id);
|
}
|
|
return count;
|
}
|
|
public bool CheckBagIsPutNewItem(int itemId)
|
{
|
SinglePackModel singlePack = GetSinglePackModel(PackType.Item);
|
if (singlePack == null) return false;
|
List<ItemModel> modellist = null;
|
int haveCnt = singlePack.GetItemCountByID(itemId, out modellist);
|
ItemConfig config = ItemConfig.Get(itemId);
|
int sumPutCnt = config.PackCount * modellist.Count;
|
if (sumPutCnt > haveCnt)
|
{
|
return true;
|
}
|
else if (GetReaminGridCount(PackType.Item) > 0)
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
public int GetReaminGridCount(PackType type)
|
{
|
int count = 0;
|
SinglePackModel singlePack = GetSinglePackModel(type);
|
if (singlePack != null)
|
{
|
count = singlePack.GetRemainGridCount();
|
}
|
|
return count;
|
}
|
|
public bool TryGetShareNumItem(int itemId, out List<int> idlist)
|
{
|
idlist = new List<int>();
|
foreach (var list in ShareUseCntItemDict.Values)
|
{
|
if (list.Contains(itemId))
|
{
|
idlist = list;
|
return true;
|
}
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 得到物品今日使用次数
|
/// </summary>
|
/// <param name="itemId"></param>
|
/// <returns></returns>
|
public int GetDayUseCntByID(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 GetSumUseCntByID(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 SetWashAttrPointModel(string guid)
|
{
|
ItemModel itemModel = GetItemModelByGUID(guid);
|
if (itemModel == null) return;
|
|
WashAttrPointWin.itemModel = itemModel;
|
WindowCenter.Instance.Open<WashAttrPointWin>();
|
}
|
|
#region 红点逻辑判断
|
private Dictionary<int, Redpoint> roleEquipRedDict = new Dictionary<int, Redpoint>();
|
public void SetRoleEquipRedpoint()
|
{
|
roleEquipRedDict.Clear();
|
for (int i = 1; i < 13; i++)
|
{
|
int redKey = 102011003 + i;
|
Redpoint redpoint = new Redpoint(MainRedDot.RedPoint_BagFuncKey, redKey);
|
roleEquipRedDict.Add(i, redpoint);
|
}
|
}
|
|
public void UpdateRoleEquipRed()
|
{
|
foreach (var key in roleEquipRedDict.Keys)
|
{
|
ItemModel itemModel = GetItemModelByIndex(PackType.Equip, key);
|
switch ((RoleEquipType)key)
|
{
|
case RoleEquipType.FairyCan:
|
if (PlayerDatas.Instance.baseData.LV >= fairyRedPointLvlimt && !TryGetRoleEquipLocalSave(key)
|
&& itemModel == null && roleEquipRedDict[(int)RoleEquipType.FairyCan2].state == RedPointState.None)
|
{
|
roleEquipRedDict[key].state = RedPointState.Simple;
|
}
|
else
|
{
|
roleEquipRedDict[key].state = RedPointState.None;
|
}
|
break;
|
case RoleEquipType.FairyCan2:
|
if (PlayerDatas.Instance.baseData.LV >= fairyRedPointLvlimt && !TryGetRoleEquipLocalSave(key)
|
&& itemModel == null && roleEquipRedDict[(int)RoleEquipType.FairyCan].state == RedPointState.None)
|
{
|
roleEquipRedDict[key].state = RedPointState.Simple;
|
}
|
else
|
{
|
roleEquipRedDict[key].state = RedPointState.None;
|
}
|
break;
|
case RoleEquipType.Wing:
|
if (PlayerDatas.Instance.baseData.LV >= wingsRedpointLvlimt && !TryGetRoleEquipLocalSave(key)
|
&& itemModel == null)
|
{
|
roleEquipRedDict[key].state = RedPointState.Simple;
|
}
|
else
|
{
|
roleEquipRedDict[key].state = RedPointState.None;
|
}
|
break;
|
default:
|
roleEquipRedDict[key].state = RedPointState.None;
|
break;
|
}
|
}
|
}
|
|
private bool TryGetRoleEquipLocalSave(int equipPlace)
|
{
|
if (LocalSavePlaceArray != null)
|
{
|
for (int i = 0; i < LocalSavePlaceArray.Count; i++)
|
{
|
if (equipPlace == 9 || equipPlace == 10)
|
{
|
if (LocalSavePlaceArray[i] == 9 || LocalSavePlaceArray[i] == 10)
|
{
|
return true;
|
}
|
}
|
else
|
{
|
if (LocalSavePlaceArray[i] == equipPlace)
|
{
|
return true;
|
}
|
}
|
|
}
|
}
|
return false;
|
}
|
|
public const int ITEMPACK_REDKEY = 102011003;
|
public Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
|
private void RedPointPackCtrl(PackType type)
|
{
|
SinglePackModel singlePack = GetSinglePackModel(type);
|
if (singlePack == null) return;
|
|
switch (type)
|
{
|
case PackType.Item:
|
if (singlePack.GetRemainGridCount() <= 0)
|
{
|
redpointItemPack.state = RedPointState.Full;
|
SysNotifyMgr.Instance.ShowTip("BagFull");
|
}
|
else
|
{
|
redpointItemPack.state = RedPointState.None;
|
}
|
break;
|
|
case PackType.Warehouse:
|
if (singlePack.GetRemainGridCount() <= 0)
|
{
|
MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
|
}
|
else
|
{
|
MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
|
}
|
break;
|
}
|
}
|
|
//public const int PLAYERSUMSTR_REDKEY = 102011001;
|
public const int PLAYERSUMSTAR_REDKEY = 102011002;
|
// public Redpoint redpointSTR = new Redpoint(MainRedDot.RedPoint_BagFuncKey, PLAYERSUMSTR_REDKEY);
|
public Redpoint redpointSTAR = new Redpoint(MainRedDot.RedPoint_BagFuncKey, PLAYERSUMSTAR_REDKEY);
|
|
public event Action<int, bool> RefreshAttrActiveAct;
|
public void SetPlayerAttrActiveRedPoint()
|
{
|
if (IsActiveStarAttr())
|
{
|
|
if (redpointSTAR.state != RedPointState.Simple)
|
{
|
redpointSTAR.state = RedPointState.Simple;
|
if (RefreshAttrActiveAct != null)
|
{
|
RefreshAttrActiveAct(1, true);
|
}
|
}
|
}
|
else
|
{
|
if (redpointSTAR.state != RedPointState.None)
|
{
|
redpointSTAR.state = RedPointState.None;
|
if (RefreshAttrActiveAct != null)
|
{
|
RefreshAttrActiveAct(1, false);
|
}
|
}
|
}
|
}
|
|
public bool IsActiveStarAttr()
|
{
|
List<int> starslist = RoleEquipStarsConfig.GetEquipStarsCntlist();
|
SinglePackModel singlePack = GetSinglePackModel(PackType.Equip);
|
if (singlePack == null || starslist == null || starslist.Count < 1) return false;
|
|
Dictionary<int, ItemModel> _itemDict = singlePack.GetPackModelIndexDict();
|
int playerSumStars = 0;
|
foreach (var model in _itemDict.Values)
|
{
|
playerSumStars += model.config.StarLevel;
|
}
|
int cnt = GetActiveCntByType(1);
|
int nextActiveStars = 0;
|
for (int i = 0; i < starslist.Count; i++)
|
{
|
if (cnt == 0)
|
{
|
nextActiveStars = starslist[0];
|
break;
|
}
|
else
|
{
|
if (starslist[i] == cnt)
|
{
|
if (i < starslist.Count - 1)
|
{
|
nextActiveStars = starslist[i + 1];
|
}
|
break;
|
}
|
}
|
}
|
|
if (nextActiveStars != 0 && playerSumStars >= nextActiveStars)
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
public bool IsActiveSTRAttr()
|
{
|
List<string> strenlist = ItemPlusSumAttrConfig.GetKeys();
|
if (strenlist == null || strenlist.Count < 1) return false;
|
int playerSumSTR = 0;
|
Dictionary<int, EquipmentInitialization> strenInfoDict = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>()._EqInfo;
|
foreach (var value in strenInfoDict.Values)
|
{
|
ItemModel itemModel = GetItemModelByIndex(PackType.Equip, value.EquipIndex);
|
if (itemModel != null)
|
{
|
playerSumSTR += value.EquipPartStarLV;
|
}
|
}
|
int cnt = GetActiveCntByType(0);
|
int nextActiveSTR = 0;
|
for (int i = 0; i < strenlist.Count; i++)
|
{
|
if (cnt == 0)
|
{
|
nextActiveSTR = int.Parse(strenlist[0]);
|
break;
|
}
|
else
|
{
|
if (int.Parse(strenlist[i]) == cnt)
|
{
|
if (i < strenlist.Count - 1)
|
{
|
nextActiveSTR = int.Parse(strenlist[i + 1]);
|
}
|
break;
|
}
|
}
|
}
|
|
if (nextActiveSTR != 0 && playerSumSTR >= nextActiveSTR)
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
public const int EquipDecompose_RedKey = 10205;
|
public Redpoint redpointEquipDecom = new Redpoint(MainRedDot.RedPoint_MainPackKey, EquipDecompose_RedKey);
|
public void EquipDecomRedCtrl()
|
{
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.EquipDecompose)) return;
|
|
if (GetCanDevourModellist() != null && GetCanDevourModellist().Count >= minDevourEquipNum)
|
{
|
redpointEquipDecom.state = RedPointState.Simple;
|
}
|
else
|
{
|
redpointEquipDecom.state = RedPointState.None;
|
}
|
}
|
#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 = GetItemModelByGUID(guid).itemPlace;
|
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 使用物品的ID
|
private void OnStageLoadFinish()
|
{
|
itemUseTypeDict.Clear();
|
if (PlayerDatas.Instance.baseData.MapID == cacheMapId)
|
{
|
return;
|
}
|
|
cacheMapId = PlayerDatas.Instance.baseData.MapID;
|
UpdateDungeonDanUse();
|
UpdateDungeonUse();
|
SinglePackModel singlePack = GetSinglePackModel(PackType.Item);
|
foreach (int itemId in itemUseTypeDict.Values)
|
{
|
List<ItemModel> modellist = null;
|
singlePack.GetItemCountByID(itemId, out modellist);
|
if (modellist.Count > 0)
|
{
|
ItemModel itemModel = modellist[0];
|
bool isExist = StatusMgr.Instance.IsExist(PlayerDatas.Instance.hero.ServerInstID, itemModel.config.AddSkill1);
|
DebugEx.Log("Buff是否存在" + isExist);
|
if (itemUseAct != null && !isExist)
|
{
|
itemUseAct(PackType.Item, itemModel.itemInfo.ItemGUID);
|
}
|
}
|
}
|
}
|
|
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;
|
}
|
}
|
}
|
}
|
|
private void UpdateDungeonDanUse()
|
{
|
int mapId = PlayerDatas.Instance.baseData.MapID;
|
int[] useDrugs = GetDrugIDListByDungeonID(mapId);
|
if (useDrugs == null) return;
|
|
for (int i = 0; i < useDrugs.Length; i++)
|
{
|
int id = useDrugs[i];
|
AddItemUseTypeDict(id);
|
}
|
}
|
|
private void UpdateDungeonUse()
|
{
|
int mapId = PlayerDatas.Instance.baseData.MapID;
|
if (!dungeonUseDict.ContainsKey(mapId)) return;
|
|
List<int> useIdlist = dungeonUseDict[mapId];
|
for (int i = 0; i < useIdlist.Count; i++)
|
{
|
int id = useIdlist[i];
|
AddItemUseTypeDict(id);
|
}
|
}
|
|
public SkillConfig GetSkillConfig(int itemId)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
SkillConfig skillConfig = SkillConfig.Get(itemConfig.AddSkill1);
|
return skillConfig;
|
}
|
|
public int GetDungeonIDByDrugID(int drugID)
|
{
|
int dungeonID = 0;
|
DrugToDungeonDict.TryGetValue(drugID, out dungeonID);
|
return dungeonID;
|
}
|
|
public int[] GetDrugIDListByDungeonID(int dungeonID)
|
{
|
int[] drugIDlist = null;
|
DungeonToDrugDict.TryGetValue(dungeonID, out drugIDlist);
|
return drugIDlist;
|
}
|
#endregion
|
|
#region 判断物品是否达到使用上限
|
public bool IsReachUseLimit(string guid, out ulong count)
|
{
|
count = 0;
|
ItemModel itemModel = GetItemModelByGUID(guid);
|
if (itemModel == null) return false;
|
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId);
|
int haveUseCnt = GetDayUseCntByID(itemModel.itemId);
|
int sumHaveUseCnt = GetSumUseCntByID(itemModel.itemId);
|
count = (ulong)itemModel.itemInfo.ItemCount;
|
bool isReach = false;
|
int remainDayCnt = 0;
|
if (itemModel.config.MaxSkillCnt > 0)
|
{
|
remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt;
|
if (itemModel.itemInfo.ItemCount > remainDayCnt)
|
{
|
count = (ulong)remainDayCnt;
|
}
|
|
}
|
|
int remainSumCnt = 0;
|
if (fruitConfig != null)
|
{
|
remainSumCnt = fruitConfig.MaxUseCnt - sumHaveUseCnt;
|
if (remainSumCnt <= remainDayCnt && itemModel.itemInfo.ItemCount > remainSumCnt)
|
{
|
count = (ulong)remainSumCnt;
|
}
|
}
|
|
if (count < (ulong)itemModel.itemInfo.ItemCount)
|
{
|
isReach = true;
|
}
|
|
return isReach;
|
}
|
#endregion
|
|
#region 物品吞噬逻辑处理
|
public EquipColorType colorType { get; private set; }
|
public EquipLvType lvType { get; private set; }
|
public EquipStarType starType { get; private set; }
|
public event Action<EquipColorType> RefreshColorSelectAct;
|
public event Action<EquipLvType> RefreshLvSelectAct;
|
public event Action<EquipStarType> RefreshStarSelectAct;
|
public event Action RefreshEquipDecomNumAct;
|
public int[] defaultUnSelectlist { get; private set; }
|
|
public bool ContainPreciousItem(List<ItemModel> itemModels, out int betterEquipCnt, out int preciousCnt)
|
{
|
betterEquipCnt = 0;
|
preciousCnt = 0;
|
if (itemModels == null) return false;
|
|
for (int i = 0; i < itemModels.Count; i++)
|
{
|
if (defaultUnSelectlist.Contains(itemModels[i].itemId))
|
{
|
preciousCnt += itemModels[i].itemInfo.ItemCount;
|
}
|
else if (modelInterface.IsFightUp(itemModels[i].itemId, itemModels[i].equipScore) == 1)
|
{
|
betterEquipCnt += itemModels[i].itemInfo.ItemCount;
|
}
|
}
|
|
if (betterEquipCnt > 0 || preciousCnt > 0)
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
public bool ContainTwoStarEquip(List<ItemModel> itemModels, out int twoStarEquipCnt)
|
{
|
twoStarEquipCnt = 0;
|
if (itemModels == null) return false;
|
for (int i = 0; i < itemModels.Count; i++)
|
{
|
if (itemModels[i].config.StarLevel >= 2 && itemModels[i].config.ItemColor >= (int)E_ItemColor.Orange)
|
{
|
twoStarEquipCnt += itemModels[i].itemInfo.ItemCount;
|
}
|
}
|
if (twoStarEquipCnt > 0)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
public void SetColorSelect(EquipColorType type)
|
{
|
colorType = type;
|
if (colorType == EquipColorType.None)
|
{
|
if (lvType != EquipLvType.None)
|
{
|
SetLvSelect(EquipLvType.None);
|
}
|
}
|
else
|
{
|
if (lvType == EquipLvType.None)
|
{
|
SetLvSelect(EquipLvType.All);
|
}
|
}
|
|
if (RefreshColorSelectAct != null)
|
{
|
RefreshColorSelectAct(type);
|
}
|
SendEquipDevourRecordQuest();
|
EquipDecomRedCtrl();
|
}
|
|
public void SetLvSelect(EquipLvType type)
|
{
|
lvType = type;
|
if (lvType == EquipLvType.None)
|
{
|
if (colorType != EquipColorType.None)
|
{
|
SetColorSelect(EquipColorType.None);
|
}
|
}
|
else
|
{
|
if (colorType == EquipColorType.None)
|
{
|
SetColorSelect(EquipColorType.Purple);
|
}
|
}
|
if (RefreshLvSelectAct != null)
|
{
|
RefreshLvSelectAct(type);
|
}
|
SendEquipDevourRecordQuest();
|
EquipDecomRedCtrl();
|
}
|
|
public void SetStarSelect(EquipStarType type)
|
{
|
starType = type;
|
if (RefreshStarSelectAct != null)
|
{
|
RefreshStarSelectAct(type);
|
}
|
SendEquipDevourRecordQuest();
|
EquipDecomRedCtrl();
|
}
|
|
public List<int> devourPlacelist { get; private set; }
|
public int MaxDevourEquipNum { get; private set; }
|
public int minDevourEquipNum { get; private set; }
|
public void SetDevourEquipPlace()
|
{
|
devourPlacelist = new List<int>();
|
FuncConfigConfig funcConfig = FuncConfigConfig.Get("PetAbsorbType");
|
int[] placeArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
|
for (int i = 0; i < placeArray.Length; i++)
|
{
|
devourPlacelist.Add(placeArray[i]);
|
}
|
MaxDevourEquipNum = int.Parse(funcConfig.Numerical2);
|
minDevourEquipNum = int.Parse(funcConfig.Numerical3);
|
}
|
|
List<ItemModel> devourModellist = new List<ItemModel>();
|
List<ItemModel> orderDevourModellist = new List<ItemModel>();
|
public List<ItemModel> GetDevourModellist()
|
{
|
SinglePackModel singlePack = GetSinglePackModel(PackType.Item);
|
if (singlePack == null) return null;
|
|
devourModellist.Clear();
|
orderDevourModellist.Clear();
|
foreach (var model in singlePack.GetPackModelIndexDict().Values)
|
{
|
if (model.config.Type == 29)
|
{
|
devourModellist.Add(model);
|
}
|
else
|
{
|
if (devourPlacelist.Contains(model.config.EquipPlace))
|
{
|
if (model.config.ItemColor >= (int)E_ItemColor.Purple)
|
{
|
devourModellist.Add(model);
|
}
|
}
|
}
|
|
}
|
orderDevourModellist.AddRange(devourModellist);
|
orderDevourModellist.Sort(CompareByColor);
|
return orderDevourModellist;
|
}
|
|
public int CompareByColor(ItemModel start, ItemModel next)
|
{
|
bool typeX = start.config.Type == 29 ? true : false;
|
bool typeY = next.config.Type == 29 ? true : false;
|
|
if (typeX.CompareTo(typeY) != 0) return -typeX.CompareTo(typeY);
|
|
int colorX = start.config.ItemColor;
|
int colorY = next.config.ItemColor;
|
if (colorX.CompareTo(colorY) != 0) return colorX.CompareTo(colorY);
|
|
int startIndex = devourModellist.IndexOf(start);
|
int nextIndex = devourModellist.IndexOf(next);
|
if (startIndex.CompareTo(nextIndex) != 0) return startIndex.CompareTo(nextIndex);
|
|
return 0;
|
}
|
|
public List<ItemModel> GetCanDevourModellist()
|
{
|
List<ItemModel> canDevourModellist = new List<ItemModel>();
|
SinglePackModel singlePack = GetSinglePackModel(PackType.Item);
|
if (singlePack == null
|
|| colorType == EquipColorType.None
|
|| lvType == EquipLvType.None)
|
{
|
if (RefreshEquipDecomNumAct != null)
|
{
|
RefreshEquipDecomNumAct();
|
}
|
return null;
|
}
|
|
foreach (var model in singlePack.GetPackModelIndexDict().Values)
|
{
|
if (model.config.Type == 29)
|
{
|
if (!defaultUnSelectlist.Contains(model.itemId))
|
{
|
canDevourModellist.Add(model);
|
}
|
}
|
else
|
{
|
if (IsCanDevour(model))
|
{
|
canDevourModellist.Add(model);
|
}
|
|
}
|
}
|
if (RefreshEquipDecomNumAct != null)
|
{
|
RefreshEquipDecomNumAct();
|
}
|
return canDevourModellist;
|
}
|
|
public bool IsCanDevour(ItemModel model)
|
{
|
if (devourPlacelist.Contains(model.config.EquipPlace))
|
{
|
if (model.config.ItemColor >= (int)E_ItemColor.Purple)
|
{
|
PetEatEquipConfig eatEquipConfig = PetEatEquipConfig.GetEquipColorAndEquipClass(model.config.ItemColor, model.config.LV);
|
if (eatEquipConfig == null) return false;
|
|
if (modelInterface.IsFightUp(model.itemId, model.equipScore) != 1)
|
{
|
if (model.config.ItemColor <= (int)colorType
|
&& model.config.LV <= (int)lvType
|
&& model.config.StarLevel <= (int)starType)
|
{
|
return true;
|
}
|
}
|
}
|
}
|
|
return false;
|
}
|
|
public bool IsMaxDecomLv(int decomLv, out int realLv)
|
{
|
realLv = decomLv;
|
List<EquipDeComposeConfig> decomlist = EquipDeComposeConfig.GetValues();
|
if (decomLv > decomlist[decomlist.Count - 1].LV)
|
{
|
realLv = decomlist[decomlist.Count - 1].LV;
|
return true;
|
}
|
|
return false;
|
}
|
|
|
public List<ItemModel> selectDevourlist = new List<ItemModel>();
|
public void GetSelectDevourList()
|
{
|
selectDevourlist.Clear();
|
List<ItemModel> itemModels = GetCanDevourModellist();
|
if (itemModels != null)
|
{
|
selectDevourlist.AddRange(itemModels);
|
}
|
}
|
|
public void RefreshGetNewItem(ItemModel model)
|
{
|
if (model == null) return;
|
|
if (CheckIsReachDevourCondi(model))
|
{
|
selectDevourlist.Add(model);
|
if (RefreshEquipDecomNumAct != null)
|
{
|
RefreshEquipDecomNumAct();
|
}
|
}
|
}
|
|
public void AddSelectDevourModellist(ItemModel model)
|
{
|
selectDevourlist.Add(model);
|
if (RefreshEquipDecomNumAct != null)
|
{
|
RefreshEquipDecomNumAct();
|
}
|
}
|
|
public bool CheckIsReachDevourCondi(ItemModel model)
|
{
|
if (model.config.Type == 29)
|
{
|
if (!defaultUnSelectlist.Contains(model.itemId))
|
{
|
return true;
|
}
|
return false;
|
}
|
else
|
{
|
if (IsCanDevour(model))
|
{
|
return true;
|
}
|
|
}
|
return false;
|
}
|
|
public void RemoveSelectDevourModellist(ItemModel model)
|
{
|
if (selectDevourlist.Contains(model))
|
{
|
selectDevourlist.Remove(model);
|
}
|
if (RefreshEquipDecomNumAct != null)
|
{
|
RefreshEquipDecomNumAct();
|
}
|
}
|
|
public Dictionary<int, int> GetDecomAttrDictByLv(int decomLv)
|
{
|
if (decomposeAttrDict.ContainsKey(decomLv))
|
{
|
return decomposeAttrDict[decomLv];
|
}
|
|
return null;
|
}
|
|
public bool IsReachMinDecomposeNum()
|
{
|
List<ItemModel> itemModels = GetCanDevourModellist();
|
if (itemModels != null && itemModels.Count >= minDecomposeNum)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
public void SendEquipdevourQuest()
|
{
|
List<ItemModel> itemModels = GetCanDevourModellist();
|
if (itemModels == null || itemModels.Count < minDecomposeNum || !modelInterface.isPackResetOk || SettingEffectMgr.Instance.isStartDecompose) return;
|
|
SettingEffectMgr.Instance.isStartDecompose = true;
|
isAutoDecompose = true;
|
recordAutoDecomNum = itemModels.Count;
|
CA32C_tagCMEquipDecompose _petEat = new CA32C_tagCMEquipDecompose();
|
var _petIndex = new ushort[recordAutoDecomNum];
|
var idlist = new uint[recordAutoDecomNum];
|
for (int i = 0; i < recordAutoDecomNum; i++)
|
{
|
_petIndex[i] = (ushort)itemModels[i].itemPlace;
|
idlist[i] = (uint)itemModels[i].itemId;
|
if (itemModels[i].config.StarLevel >= 2
|
|| (itemModels[i].config.EquipPlace == 0 && itemModels[i].config.Type != 29))
|
{
|
return;
|
}
|
}
|
_petEat.Count = (byte)_petIndex.Length;
|
_petEat.IndexList = _petIndex;
|
_petEat.ItemIDList = idlist;
|
_petEat.IsAuto = 1;
|
GameNetSystem.Instance.SendInfo(_petEat);
|
}
|
|
public void SendEquipDevourRecordQuest()
|
{
|
string record = StringUtility.Contact((int)colorType + 1, (int)lvType + 1, (int)starType + 1);
|
CA32D_tagCMDecomposeSeting decomSet = new CA32D_tagCMDecomposeSeting();
|
decomSet.Seting = uint.Parse(record);
|
GameNetSystem.Instance.SendInfo(decomSet);
|
}
|
public int decomposeLv { get; private set; }
|
public int decomposeExp { get; private set; }
|
public int decomposeProgress { get; private set; }
|
public int addDecomposeExp { get; private set; }
|
public int minDecomposeNum { get; private set; }
|
public bool isAutoDecompose { get; set; }
|
public int recordAutoDecomNum { get; private set; }
|
public DecomposeGetMatInfo[] getItems { get; private set; }
|
|
public event Action RefreshDecomAttrAct;
|
public void GetServerDecomposeSet(HA31C_tagMCEquipDecomposeInfo info)
|
{
|
addDecomposeExp = 0;
|
int realLv = info.LV + 1;
|
bool isMax = IsMaxDecomLv(realLv, out realLv);
|
if (realLv == decomposeLv)
|
{
|
addDecomposeExp = (int)info.Exp - decomposeExp;
|
}
|
else
|
{
|
for (int i = decomposeLv; i <= realLv; i++)
|
{
|
EquipDeComposeConfig deComposeConfig = EquipDeComposeConfig.Get(i);
|
if (i == decomposeLv)
|
{
|
addDecomposeExp = deComposeConfig.UpNeedExp - decomposeExp;
|
}
|
else if (i == realLv)
|
{
|
addDecomposeExp += (int)info.Exp;
|
}
|
else
|
{
|
addDecomposeExp += deComposeConfig.UpNeedExp;
|
}
|
}
|
}
|
|
decomposeLv = realLv;
|
decomposeExp = (int)info.Exp;
|
decomposeProgress = info.DecomposeCnt;
|
getItems = JsonMapper.ToObject<DecomposeGetMatInfo[]>(info.GetItemData);
|
|
if (info.Seting != 0)
|
{
|
string decomSetStr = info.Seting.ToString();
|
string colorStr = decomSetStr.Substring(0, 1);
|
colorType = (EquipColorType)(int.Parse(colorStr) - 1);
|
starType = (EquipStarType)((int)info.Seting % 10 - 1);
|
string lvStr = decomSetStr.Substring(1, decomSetStr.Length - 2);
|
lvType = (EquipLvType)(int.Parse(lvStr) - 1);
|
}
|
if (RefreshDecomAttrAct != null)
|
{
|
RefreshDecomAttrAct();
|
}
|
}
|
/// <summary>
|
/// 设置获得炼丹材料的展示数据
|
/// </summary>
|
/// <param name="getMatInfos"></param>
|
/// <returns></returns>
|
private List<DecomposeGetMatInfo> getMatInfos = new List<DecomposeGetMatInfo>();
|
public List<DecomposeGetMatInfo> SetShowMatInfo()
|
{
|
getMatInfos.Clear();
|
int sumMatCnt = 0;
|
if (getItems != null)
|
{
|
for (int i = 0; i < getItems.Length; i++)
|
{
|
if (getItems[i].Count > 0)
|
{
|
sumMatCnt += getItems[i].Count;
|
}
|
else
|
{
|
sumMatCnt += 1;
|
}
|
}
|
}
|
|
if (sumMatCnt > 5)
|
{
|
for (int i = 0; i < getItems.Length; i++)
|
{
|
getMatInfos.Add(getItems[i]);
|
}
|
}
|
else
|
{
|
if (getItems != null)
|
{
|
for (int i = 0; i < getItems.Length; i++)
|
{
|
if (getItems[i].Count > 0)
|
{
|
for (int j = 0; j < getItems[i].Count; j++)
|
{
|
DecomposeGetMatInfo matInfo = new DecomposeGetMatInfo();
|
matInfo.ItemID = getItems[i].ItemID;
|
matInfo.Count = 1;
|
matInfo.IsBind = getItems[i].IsBind;
|
matInfo.IsSuite = getItems[i].IsSuite;
|
matInfo.UserData = getItems[i].UserData;
|
getMatInfos.Add(matInfo);
|
}
|
}
|
else
|
{
|
getMatInfos.Add(getItems[i]);
|
}
|
}
|
}
|
}
|
return getMatInfos;
|
}
|
|
public enum EquipColorType
|
{
|
None = 0,
|
Purple = 3,
|
Orange = 4,
|
Red = 5,
|
All = 10,
|
}
|
|
public enum EquipLvType
|
{
|
None = 0,
|
One,
|
Two,
|
Three,
|
Four,
|
Five,
|
Six,
|
Seven,
|
Eight,
|
Nine,
|
Ten,
|
Eleven,
|
Twelve,
|
Thirteen,
|
Fourteen,
|
Fifteen,
|
All,
|
}
|
|
public enum EquipStarType
|
{
|
None = 0,
|
One,
|
Two,
|
Three,
|
All,
|
}
|
|
public class DecomposeGetMatInfo
|
{
|
public int ItemID;
|
public int Count;
|
public int IsBind;
|
public int IsSuite;
|
public string UserData;
|
}
|
#endregion
|
|
#region 丹药逻辑处理
|
|
private int CompareMakeDrug(AttrFruitConfig start, AttrFruitConfig end)
|
{
|
ItemConfig configS = ItemConfig.Get(start.ID);
|
ItemConfig configE = ItemConfig.Get(end.ID);
|
if (configS.RealmLimit.CompareTo(configE.RealmLimit) != 0)
|
{
|
return configS.RealmLimit.CompareTo(configE.RealmLimit);
|
}
|
if (configS.LV.CompareTo(configE.LV) != 0)
|
{
|
return configS.LV.CompareTo(configE.LV);
|
}
|
|
int x = makeDruglist.IndexOf(start);
|
int y = makeDruglist.IndexOf(end);
|
if (x.CompareTo(y) != 0) x.CompareTo(y);
|
|
return 0;
|
}
|
|
List<AttrFruitConfig> drugOrderlist = new List<AttrFruitConfig>();
|
List<AttrFruitConfig> haveDruglist = new List<AttrFruitConfig>();
|
public List<AttrFruitConfig> GetDrugOrderByCnt()
|
{
|
drugOrderlist.Clear();
|
haveDruglist.Clear();
|
drugOrderlist.AddRange(makeDruglist);
|
drugOrderlist.Sort(CompareByIsHave);
|
for (int i = 0; i < drugOrderlist.Count; i++)
|
{
|
if (IsHaveDrugUse(drugOrderlist[i]))
|
{
|
haveDruglist.Add(drugOrderlist[i]);
|
}
|
}
|
haveDruglist.Sort(CompareMakeDrug);
|
for (int i = 0; i < haveDruglist.Count; i++)
|
{
|
drugOrderlist[i] = haveDruglist[i];
|
}
|
|
return drugOrderlist;
|
}
|
|
public bool CheckIsDrugById(int itemId)
|
{
|
for (int i = 0; i < makeDruglist.Count; i++)
|
{
|
if (makeDruglist[i].ID == itemId)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public int CompareByIsHave(AttrFruitConfig start, AttrFruitConfig end)
|
{
|
bool isHaveStart = IsHaveDrugUse(start);
|
bool isHaveEnd = IsHaveDrugUse(end);
|
if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
|
|
//isHaveStart = IsHaveDrugRecycle(start);
|
//isHaveEnd = IsHaveDrugRecycle(end);
|
//if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
|
|
isHaveStart = GetItemCountByID(PackType.Item, start.ID) > 0 ? true : false;
|
isHaveEnd = GetItemCountByID(PackType.Item, end.ID) > 0 ? true : false;
|
if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
|
|
isHaveStart = IsReachMaxUseDrug(start);
|
isHaveEnd = IsReachMaxUseDrug(end);
|
if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
|
|
int x = makeDruglist.IndexOf(start);
|
int y = makeDruglist.IndexOf(end);
|
if (x.CompareTo(y) != 0) return x.CompareTo(y);
|
return 0;
|
}
|
|
public bool IsHaveDrugUse(AttrFruitConfig fruitConfig)
|
{
|
if (!IsReachMaxUseDrug(fruitConfig))
|
{
|
return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
|
}
|
|
return false;
|
}
|
|
public bool IsHaveDrugRecycle(AttrFruitConfig fruitConfig)
|
{
|
if (IsReachMaxUseDrug(fruitConfig))
|
{
|
return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
|
}
|
return false;
|
}
|
|
public bool IsReachMaxUseDrug(AttrFruitConfig fruitConfig)
|
{
|
if (fruitConfig == null) return false;
|
|
int useNum = GetSumUseCntByID(fruitConfig.ID);
|
if (useNum >= fruitConfig.MaxUseCnt)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
List<AttrFruitConfig> limitlist = new List<AttrFruitConfig>();
|
public float GetAlchemyProgress(AlchemyConfig alchemy)
|
{
|
var previewDanlist = FurnaceModel.GetPreviewIdlist(alchemy);
|
float progress = 0;
|
limitlist.Clear();
|
for (int i = 0; i < previewDanlist.Count; i++)
|
{
|
AttrFruitConfig fruitConfig = AttrFruitConfig.Get(previewDanlist[i]);
|
if (fruitConfig != null)
|
{
|
limitlist.Add(fruitConfig);
|
}
|
}
|
|
for (int i = 0; i < limitlist.Count; i++)
|
{
|
progress += ((float)1 / limitlist.Count) * ((float)GetSumUseCntByID(limitlist[i].ID) / limitlist[i].MaxUseCnt);
|
}
|
return progress * 100;
|
}
|
#endregion
|
}
|
}
|