using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using TableConfig;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
public class DogzModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
|
{
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
GodBeastModel beastModel { get { return ModelCenter.Instance.GetModel<GodBeastModel>(); } }
|
|
public override void Init()
|
{
|
ParseConfig();
|
SetDogzAndEquipPlaceRedKey();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
addAssistCnt = 0;
|
SelectDogzItemQuality = 0;
|
SelectDogzItemStart = 0;
|
dogzItemList = new List<ItemModel>();
|
selectEquipPlacelist = new List<ItemModel>();
|
dogzAssistStateDict = new Dictionary<int, int>();
|
m_DogzEquipAttrDict = new Dictionary<int, int>();
|
}
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
SetDogzEquipInfo();
|
playerPack.RefreshItemCountAct -= RefreshDogzEquipInfo;
|
playerPack.RefreshItemCountAct += RefreshDogzEquipInfo;
|
UpdateDogzAssistRed();
|
UpdateDogzEquipPlaceRed();
|
UpdateAssistNumRed();
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
#region 配置
|
private Dictionary<int, Dictionary<int, int>> m_DogzEquipLimit = new Dictionary<int, Dictionary<int, int>>(); //装备位 品质限制
|
public int DogzAssistDefaultCnt { get; private set; } //助战神兽总数
|
public int DogzAssistMaxCnt { get; private set; }//助战神兽最大数
|
public int AddAssistItem { get; private set; } //增加助战神兽总数的物品Id
|
public int DogzPackGridCnt { get; private set; } //神兽物品背包格子数
|
public int[] AddAssistItemCnt { get; private set; } //增加助战神兽总数的物品数量
|
public Dictionary<int, int> m_DogzEquipStrenLimit { get; private set;} //神兽装备强化上限 品质 强化等级
|
|
void ParseConfig()
|
{
|
var _dogzCfgs = Config.Instance.GetAllValues<DogzConfig>();
|
for (int i = 0; i < _dogzCfgs.Count; i++)
|
{
|
var _dict = new Dictionary<int, int>();
|
for(int j = 0; j < _dogzCfgs[i].EquipPlaceColorList.Length; j++)
|
{
|
_dict.Add(j, _dogzCfgs[i].EquipPlaceColorList[j]);
|
}
|
m_DogzEquipLimit.Add(_dogzCfgs[i].ID, _dict);
|
}
|
var _funcCfg = Config.Instance.Get<FuncConfigConfig>("DogzAssist");
|
int[] assistDogz = ConfigParse.GetMultipleStr<int>(_funcCfg.Numerical1);
|
DogzAssistDefaultCnt = assistDogz[0];
|
DogzAssistMaxCnt = assistDogz[1];
|
AddAssistItem = int.Parse(_funcCfg.Numerical2);
|
AddAssistItemCnt = ConfigParse.GetMultipleStr<int>(_funcCfg.Numerical3);
|
m_DogzEquipStrenLimit = ConfigParse.GetDic<int, int>(_funcCfg.Numerical4);
|
_funcCfg = Config.Instance.Get<FuncConfigConfig>("DogzPack");
|
DogzPackGridCnt = int.Parse(_funcCfg.Numerical1);
|
}
|
/// <summary>
|
/// 获得格子可以穿戴的装备限制 神兽Id 格子索引
|
/// </summary>
|
/// <param name="_dogzId"></param>
|
/// <param name="_index"></param>
|
/// <returns></returns>
|
public int GetDogzEquipLimitByIndex(int _dogzId, int _index)
|
{
|
if (m_DogzEquipLimit.ContainsKey(_dogzId))
|
{
|
var _dict = m_DogzEquipLimit[_dogzId];
|
if (_dict.ContainsKey(_index))
|
{
|
return _dict[_index];
|
}
|
}
|
return 0;
|
}
|
|
/// <summary>
|
/// 得到神兽格子对应的装备部位
|
/// </summary>
|
/// <param name="_index"></param>
|
/// <returns></returns>
|
public static string GetDogzPartNameByIndex(int _index)
|
{
|
switch (_index)
|
{
|
case 0:
|
return Language.Get("DogzEquip1");
|
case 1:
|
return Language.Get("DogzEquip2");
|
case 2:
|
return Language.Get("DogzEquip3");
|
case 3:
|
return Language.Get("DogzEquip4");
|
case 4:
|
return Language.Get("DogzEquip5");
|
default:
|
return string.Empty;
|
}
|
}
|
|
public static string GetItemColorName(int _itemColor)
|
{
|
switch (_itemColor)
|
{
|
case 0:
|
case 1:
|
return Language.Get("DogzWhite");
|
case 2:
|
return Language.Get("DogzBlue");
|
case 3:
|
return Language.Get("DogzPurple");
|
case 4:
|
return Language.Get("DogzOrange");
|
case 5:
|
return Language.Get("DogzRed");
|
case 6:
|
return Language.Get("DogzPink");
|
default:
|
return string.Empty;
|
}
|
}
|
#endregion
|
|
public int GetAssistItemCnt()
|
{
|
return AddAssistItemCnt[addAssistCnt];
|
}
|
|
public int presentSelectDogz { get; set; } //当前选中的神兽id
|
public event Action UpdateSelectDogzEvent;
|
public void SetSelectDogz(int _id)
|
{
|
presentSelectDogz = _id;
|
if (UpdateSelectDogzEvent != null)
|
{
|
UpdateSelectDogzEvent();
|
}
|
}
|
|
public event Action<int,int> OpenFuncEvent;
|
public void OpenDogzFuncEvent(int functionOrder,int equipIndex)
|
{
|
if(OpenFuncEvent != null)
|
{
|
OpenFuncEvent(functionOrder,equipIndex);
|
}
|
}
|
|
public bool CheckIsAddAssistNum()
|
{
|
var _itemConfig = Config.Instance.Get<ItemConfig>(AddAssistItem);
|
if(GetAssistItemCnt() <= playerPack.GetItemCountByID(PackType.rptItem, AddAssistItem))
|
{
|
return true;
|
}
|
return false;
|
}
|
|
#region 协议
|
|
public int addAssistCnt { get; private set; } //额外购买的助战数
|
public void SetServerAddAssistDogzCnt(HA3C0_tagMCDogzInfo info)
|
{
|
addAssistCnt = info.BuyHelpbattleCount;
|
DogzAssistDefaultCnt += addAssistCnt;
|
if (UpdateAssistDogzEvent != null)
|
{
|
UpdateAssistDogzEvent();
|
}
|
UpdateDogzAssistRed();
|
UpdateDogzEquipPlaceRed();
|
}
|
|
public event Action UpdateAssistDogzEvent;
|
public Dictionary<int, int> dogzAssistStateDict { get; private set; } //神兽助战
|
public void SetServerAssistDogzState(HA3C1_tagMCDogzHelpbattleState info)
|
{
|
if(!dogzAssistStateDict.ContainsKey(info.DogzID))
|
{
|
dogzAssistStateDict.Add(info.DogzID,info.BatteState);
|
}
|
else
|
{
|
dogzAssistStateDict[info.DogzID] = info.BatteState;
|
}
|
|
if (UpdateAssistDogzEvent != null)
|
{
|
UpdateAssistDogzEvent();
|
}
|
|
UpdateDogzAssistRed();
|
UpdateDogzEquipPlaceRed();
|
}
|
|
public int GetAssistDogzCount()
|
{
|
int assistCnt = 0;
|
foreach(var key in dogzAssistStateDict.Keys)
|
{
|
if(dogzAssistStateDict[key] == 1)
|
{
|
assistCnt += 1;
|
}
|
}
|
return assistCnt;
|
}
|
|
public bool TryGetAssistDogzState(int dogzId)
|
{
|
int state = 0;
|
dogzAssistStateDict.TryGetValue(dogzId,out state);
|
return state == 0 ? false : true;
|
}
|
|
public void SetDogzEquipInfo()
|
{
|
m_DogzEquipDict.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptDogzEquip);
|
if (singlePack == null) return;
|
|
Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
|
foreach(var index in pairs.Keys)
|
{
|
ItemModel itemModel = pairs[index];
|
int dogzId = GetDogzIDByIndex(index);
|
if (!m_DogzEquipDict.ContainsKey(dogzId))
|
{
|
List<ItemModel> equipDatas = new List<ItemModel>();
|
equipDatas.Add(itemModel);
|
m_DogzEquipDict.Add(dogzId, equipDatas);
|
}
|
else
|
{
|
m_DogzEquipDict[dogzId].Add(itemModel);
|
}
|
|
}
|
}
|
|
public Action<int> RefreshDogzEquipAct;
|
private void RefreshDogzEquipInfo(PackType type, int index, int id)
|
{
|
if(type == PackType.rptItem && id == AddAssistItem)
|
{
|
UpdateAssistNumRed();
|
}
|
else if(type == PackType.rptDogzItem)
|
{
|
UpdateDogzAssistRed();
|
UpdateDogzEquipPlaceRed();
|
}
|
else if(type == PackType.rptDogzEquip)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(type, index);
|
int dogzId = GetDogzIDByIndex(index);
|
List<ItemModel> modellist = GetDogzEquips(dogzId);
|
if (modellist != null)
|
{
|
if (itemModel != null)
|
{
|
bool isAdd = true;
|
for (int i = 0; i < modellist.Count; i++)
|
{
|
if (modellist[i].itemInfo.ItemPlace == index)
|
{
|
isAdd = false;
|
modellist[i] = itemModel;
|
break;
|
}
|
}
|
if (isAdd)
|
{
|
modellist.Add(itemModel);
|
}
|
}
|
else
|
{
|
for (int i = 0; i < modellist.Count; i++)
|
{
|
if (modellist[i].itemInfo.ItemPlace == index)
|
{
|
modellist.RemoveAt(i);
|
break;
|
}
|
}
|
}
|
}
|
else
|
{
|
if (itemModel != null)
|
{
|
List<ItemModel> equipDatas = new List<ItemModel>();
|
equipDatas.Add(itemModel);
|
m_DogzEquipDict.Add(dogzId, equipDatas);
|
}
|
}
|
|
if (RefreshDogzEquipAct != null)
|
{
|
RefreshDogzEquipAct(dogzId);
|
}
|
|
UpdateDogzAssistRed();
|
UpdateDogzEquipPlaceRed();
|
}
|
}
|
|
/// <summary>
|
/// 获得神兽穿戴的装备数据
|
/// </summary>
|
private Dictionary<int, List<ItemModel>> m_DogzEquipDict = new Dictionary<int, List<ItemModel>>();
|
|
public List<ItemModel> GetDogzEquips(int _dogzId)
|
{
|
List<ItemModel> _list = null;
|
m_DogzEquipDict.TryGetValue(_dogzId,out _list);
|
return _list;
|
}
|
|
/// <summary>
|
/// 获得助战属性加成
|
/// </summary>
|
public Dictionary<int,int> m_DogzEquipAttrDict { get; private set; }
|
public Dictionary<int,int> GetDogzEquipAddAttr(int dogzId)
|
{
|
m_DogzEquipAttrDict.Clear();
|
DogzConfig dogzConfig = Config.Instance.Get<DogzConfig>(dogzId);
|
int[] baseAttrIds = dogzConfig.BaseAttrTypes;
|
Dictionary<int, int> dogzStrenDict = beastModel.AllEnhancedProperties(dogzId);
|
for (int i = 0; i < baseAttrIds.Length; i++)
|
{
|
int attrValue = 0;
|
List<ItemModel> itemModels = GetDogzEquips(dogzId);
|
if(itemModels != null)
|
{
|
for(int j = 0; j < itemModels.Count; j++)
|
{
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemModels[j].itemId);
|
|
if(itemConfig.Effect1 == baseAttrIds[i])
|
{
|
attrValue += itemConfig.EffectValueA1;
|
}
|
if (itemConfig.Effect2 == baseAttrIds[i])
|
{
|
attrValue += itemConfig.EffectValueA2;
|
}
|
if (itemConfig.Effect3 == baseAttrIds[i])
|
{
|
attrValue += itemConfig.EffectValueA3;
|
}
|
if (itemConfig.Effect4 == baseAttrIds[i])
|
{
|
attrValue += itemConfig.EffectValueA4;
|
}
|
if (itemConfig.Effect5 == baseAttrIds[i])
|
{
|
attrValue += itemConfig.EffectValueA5;
|
}
|
}
|
}
|
if(dogzStrenDict.ContainsKey(baseAttrIds[i]))
|
{
|
attrValue += dogzStrenDict[baseAttrIds[i]];
|
}
|
m_DogzEquipAttrDict.Add(baseAttrIds[i], attrValue);
|
}
|
return m_DogzEquipAttrDict;
|
}
|
|
public int GetDogzEquipPlaceByIndex(int index)
|
{
|
return (index % 5) + 101;
|
}
|
|
public int GetDogzIDByIndex(int index)
|
{
|
return (index / 5) + 1;
|
}
|
|
/// <summary>
|
/// 获得当前格子穿戴的装备
|
/// </summary>
|
/// <param name="_dogzId"></param>
|
/// <param name="_index"></param>
|
/// <param name="_equipData"></param>
|
/// <returns></returns>
|
public bool TryGetDogzEquip(int _dogzId, int _equipPlace, out ItemModel _equipData)
|
{
|
_equipData = null;
|
List<ItemModel> _list = GetDogzEquips(_dogzId);
|
if (_list == null)
|
{
|
return false;
|
}
|
|
for(int i = 0; i < _list.Count; i++)
|
{
|
int equipPlace = GetDogzEquipPlaceByIndex(_list[i].itemInfo.ItemPlace);
|
if(equipPlace == _equipPlace)
|
{
|
_equipData = _list[i];
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public void CheckPutOff(int equipPlace)
|
{
|
if (TryGetAssistDogzState(presentSelectDogz))
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("DogzFunc103"),
|
(bool isOk)=>
|
{
|
if(isOk)
|
{
|
SendPutOffEquip(equipPlace);
|
}
|
return;
|
});
|
}
|
else
|
{
|
SendPutOffEquip(equipPlace);
|
}
|
}
|
|
public void SendPutOnEquip(int index)
|
{
|
CA5C0_tagCMDogzEquipItem dogzPutOn = new CA5C0_tagCMDogzEquipItem();
|
dogzPutOn.DogzID = (byte)presentSelectDogz;
|
dogzPutOn.EquipIndex = (byte)index;
|
GameNetSystem.Instance.SendInfo(dogzPutOn);
|
}
|
|
private void SendPutOffEquip(int equipPlace)
|
{
|
CA5C1_tagCMDogzUnEquipItem dogzPutOff = new CA5C1_tagCMDogzUnEquipItem();
|
dogzPutOff.DogzID = (byte)presentSelectDogz;
|
dogzPutOff.EquipPlace = (byte)equipPlace;
|
GameNetSystem.Instance.SendInfo(dogzPutOff);
|
}
|
|
public void SendChangeDogzAssist(int assistState)
|
{
|
CA5C2_tagCMDogzBattleStateChange stateChange = new CA5C2_tagCMDogzBattleStateChange();
|
stateChange.DogzID = (byte)presentSelectDogz;
|
stateChange.BatteState = (byte)assistState;
|
GameNetSystem.Instance.SendInfo(stateChange);
|
}
|
|
public void SendBuyAssistCnt()
|
{
|
CA5C3_tagCMDogzBuyBatteCount buyCnt = new CA5C3_tagCMDogzBuyBatteCount();
|
GameNetSystem.Instance.SendInfo(buyCnt);
|
}
|
|
public void SendDogzEquipStrength(int index,List<int>indexlist,List<int> IndexUseCountList, int isDouble)
|
{
|
CA5C4_tagCMDogzEquipPlus dogzStren = new CA5C4_tagCMDogzEquipPlus();
|
dogzStren.EquipIndex = (byte)index;
|
dogzStren.IndexCount = (byte)indexlist.Count;
|
byte[] indexByte = new byte[indexlist.Count];
|
uint[] indexUseCountList = new uint[indexlist.Count];
|
for (int i = 0; i < indexByte.Length; i++)
|
{
|
indexByte[i] = (byte)indexlist[i];
|
}
|
for (int i = 0; i < indexUseCountList.Length; i++)
|
{
|
indexUseCountList[i] = (uint)IndexUseCountList[i];
|
}
|
dogzStren.IndexUseCountList = indexUseCountList;
|
dogzStren.IndexList = indexByte;
|
dogzStren.IsDouble = (byte)isDouble;
|
GameNetSystem.Instance.SendInfo(dogzStren);
|
}
|
|
#endregion
|
|
#region 神兽背包物品
|
public int SelectDogzItemQuality { get; set; }
|
public int SelectDogzItemStart { get; set; }
|
public List<ItemModel> dogzItemList { get; private set; }
|
public List<ItemModel> GetDogzItemList()
|
{
|
dogzItemList.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptDogzItem);
|
if (singlePack == null) return dogzItemList;
|
|
Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
|
foreach(var value in pairs.Values)
|
{
|
if(IsReachSelectCondi(value.itemId))
|
{
|
dogzItemList.Add(value);
|
}
|
}
|
|
return dogzItemList;
|
}
|
|
public bool IsReachSelectCondi(int itemId)
|
{
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemId);
|
if (itemConfig == null || itemConfig.EquipPlace == 0) return false;
|
|
if (SelectDogzItemQuality == 0 && SelectDogzItemStart == 0) return true;
|
|
if (SelectDogzItemQuality == 0 && itemConfig.StarLevel == SelectDogzItemStart) return true;
|
|
if (SelectDogzItemQuality == itemConfig.ItemColor && SelectDogzItemStart == 0) return true;
|
|
if (SelectDogzItemQuality == itemConfig.ItemColor && SelectDogzItemStart == itemConfig.StarLevel) return true;
|
|
return false;
|
}
|
|
public List<ItemModel> selectEquipPlacelist { get; private set; }
|
public List<ItemModel> GetDogzItemListByIndex(int dogzId,int index)
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptDogzItem);
|
selectEquipPlacelist.Clear();
|
if (singlePack == null) return selectEquipPlacelist;
|
|
var _itemColor = GetDogzEquipLimitByIndex(dogzId, index);
|
var _equipPlace = GetDogzEquipPlaceByIndex(index);
|
Dictionary<int, ItemModel> pairs = singlePack.GetPackModelIndexDict();
|
foreach (var value in pairs.Values)
|
{
|
if(value.chinItemModel.EquipPlace == _equipPlace
|
&& value.chinItemModel.ItemColor >= _itemColor)
|
{
|
selectEquipPlacelist.Add(value);
|
}
|
}
|
selectEquipPlacelist.Sort(CompareByDogzItem);
|
return selectEquipPlacelist;
|
}
|
|
private int CompareByDogzItem(ItemModel start,ItemModel end)
|
{
|
int x = start.chinItemModel.ItemColor;
|
int y = end.chinItemModel.ItemColor;
|
if (x.CompareTo(y) != 0) return -x.CompareTo(y);
|
x = start.chinItemModel.StarLevel;
|
y = end.chinItemModel.StarLevel;
|
if (x.CompareTo(y) != 0) return -x.CompareTo(y);
|
x = start.equipScore;
|
y = end.equipScore;
|
if (x.CompareTo(y) != 0) return -x.CompareTo(y);
|
|
return 0;
|
}
|
#endregion
|
|
#region 默认选择逻辑处理
|
public void SetDefaultSelectDogz()
|
{
|
var configs = Config.Instance.GetAllValues<DogzConfig>();
|
presentSelectDogz = configs[0].ID;
|
foreach (var key in m_DogzEquipLimit.Keys)
|
{
|
Redpoint redpoint = GetSingleDogzRedpointById(key);
|
if (redpoint.state == RedPointState.Simple)
|
{
|
presentSelectDogz = key;
|
break;
|
}
|
}
|
}
|
#endregion
|
|
#region 红点逻辑处理
|
public const int MAINDOGZ_REDKEY = 112;
|
public const int DOGZFUNC_REDKEY = 11201;
|
public const int ADDASSISTDOGZ_REDKEY = 1120100002;
|
public Redpoint mainDogzRedpoint = new Redpoint(MainRedDot.RedPoint_key, MAINDOGZ_REDKEY);
|
public Redpoint dogzFuncRedpoint = new Redpoint(MAINDOGZ_REDKEY,DOGZFUNC_REDKEY);
|
public Redpoint addAssistDogzRedpoint = new Redpoint(DOGZFUNC_REDKEY,ADDASSISTDOGZ_REDKEY);
|
private Dictionary<int, Redpoint> singleDogzRedDict = new Dictionary<int, Redpoint>();
|
private Dictionary<int, Redpoint> dogzAssistRedDict = new Dictionary<int, Redpoint>();
|
private Dictionary<int, Dictionary<int, Redpoint>> dogzEquipPlaceRedDict = new Dictionary<int, Dictionary<int, Redpoint>>();
|
public void SetDogzAndEquipPlaceRedKey()
|
{
|
singleDogzRedDict.Clear();
|
dogzEquipPlaceRedDict.Clear();
|
dogzAssistRedDict.Clear();
|
int i = 0;
|
foreach(var dogzId in m_DogzEquipLimit.Keys)
|
{
|
i += 1;
|
int dogzRedKey = DOGZFUNC_REDKEY * 100 + i;
|
Redpoint dogzRedPoint = new Redpoint(DOGZFUNC_REDKEY,dogzRedKey);
|
singleDogzRedDict.Add(dogzId, dogzRedPoint);
|
int dogzAssistRedKey = dogzRedKey * 100 + i;
|
Redpoint dogzAssistRedPoint = new Redpoint(dogzRedKey, dogzAssistRedKey);
|
dogzAssistRedDict.Add(dogzId,dogzAssistRedPoint);
|
Dictionary<int, Redpoint> equipPlaceRedDict = new Dictionary<int, Redpoint>();
|
dogzEquipPlaceRedDict.Add(dogzId,equipPlaceRedDict);
|
int equipPlaceNum = m_DogzEquipLimit[dogzId].Count;
|
for (int j = 0; j < equipPlaceNum; j++)
|
{
|
int equipPlaceRedKey = dogzRedKey * 10 + j;
|
Redpoint equipPlaceRedpoint = new Redpoint(dogzRedKey,equipPlaceRedKey);
|
equipPlaceRedDict.Add(j, equipPlaceRedpoint);
|
}
|
|
}
|
}
|
|
public Redpoint GetSingleDogzRedpointById(int dogzId)
|
{
|
Redpoint redpoint = null;
|
singleDogzRedDict.TryGetValue(dogzId, out redpoint);
|
return redpoint;
|
}
|
|
public Redpoint GetDogzAssistRedpointById(int dogzId)
|
{
|
Redpoint redpoint = null;
|
dogzAssistRedDict.TryGetValue(dogzId,out redpoint);
|
return redpoint;
|
}
|
|
public Redpoint GetDogzEquipPlaceRedpointById(int dogzId,int index)
|
{
|
Redpoint redpoint = null;
|
if(dogzEquipPlaceRedDict.ContainsKey(dogzId))
|
{
|
dogzEquipPlaceRedDict[dogzId].TryGetValue(index, out redpoint);
|
}
|
return redpoint;
|
}
|
|
public void UpdateDogzAssistRed()
|
{
|
foreach(var value in dogzAssistRedDict.Values)
|
{
|
value.state = RedPointState.None;
|
}
|
bool isMaxAssistNum = GetAssistDogzCount() >= DogzAssistDefaultCnt ? true : false;
|
if(!isMaxAssistNum)
|
{
|
int maxDogzId = 0;
|
foreach(var dogzId in m_DogzEquipLimit.Keys)
|
{
|
var equips = GetDogzEquips(dogzId);
|
int equipNum = equips == null ? 0 : equips.Count;
|
if(equipNum >= 5 && maxDogzId < dogzId
|
&& !TryGetAssistDogzState(dogzId))
|
{
|
maxDogzId = dogzId;
|
}
|
}
|
if(maxDogzId > 0)
|
{
|
Redpoint assistRedpoint = GetDogzAssistRedpointById(maxDogzId);
|
if(assistRedpoint.state == RedPointState.None)
|
{
|
assistRedpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
else
|
{
|
foreach (var dogzId in m_DogzEquipLimit.Keys)
|
{
|
var equips = GetDogzEquips(dogzId);
|
int equipNum = equips == null ? 0 : equips.Count;
|
if(!TryGetAssistDogzState(dogzId) && equipNum == 5)
|
{
|
Redpoint assistRedpoint = GetDogzAssistRedpointById(dogzId);
|
if (assistRedpoint.state == RedPointState.None)
|
{
|
assistRedpoint.state = RedPointState.Simple;
|
}
|
break;
|
}
|
}
|
}
|
}
|
|
public void UpdateDogzEquipPlaceRed()
|
{
|
foreach(var value in dogzEquipPlaceRedDict.Values)
|
{
|
foreach(var value2 in value.Values)
|
{
|
value2.state = RedPointState.None;
|
}
|
}
|
|
foreach(var value in dogzAssistRedDict.Values)
|
{
|
if(value.state == RedPointState.Simple)
|
{
|
return;
|
}
|
}
|
bool isMaxAssistNum = GetAssistDogzCount() >= DogzAssistDefaultCnt ? true : false;
|
if (!isMaxAssistNum)
|
{
|
int maxEquipNum = 0;
|
int spaceDogzId = 0;
|
foreach (var dogzId in m_DogzEquipLimit.Keys)
|
{
|
var equips = GetDogzEquips(dogzId);
|
int equipNum = equips == null ? 0 : equips.Count;
|
if (equipNum < 5)
|
{
|
if (spaceDogzId == 0)
|
{
|
if (maxEquipNum <= equipNum)
|
{
|
maxEquipNum = equipNum;
|
spaceDogzId = dogzId;
|
}
|
}
|
else
|
{
|
if (maxEquipNum < equipNum)
|
{
|
maxEquipNum = equipNum;
|
spaceDogzId = dogzId;
|
}
|
}
|
}
|
}
|
|
if(spaceDogzId != 0)
|
{
|
for(int i = 0; i < 5; i++)
|
{
|
ItemModel _data;
|
bool _equiped = TryGetDogzEquip(spaceDogzId, i + 101, out _data);
|
if(!_equiped)
|
{
|
GetDogzItemListByIndex(spaceDogzId,i);
|
if (selectEquipPlacelist.Count > 0)
|
{
|
Redpoint equipPlaceRedpoint = GetDogzEquipPlaceRedpointById(spaceDogzId,i);
|
if(equipPlaceRedpoint.state == RedPointState.None)
|
{
|
equipPlaceRedpoint.state = RedPointState.Simple;
|
}
|
break;
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
int minAlreadyAssistId = 0;
|
foreach (var dogzId in m_DogzEquipLimit.Keys)
|
{
|
if(TryGetAssistDogzState(dogzId)
|
&& minAlreadyAssistId != 0
|
&& minAlreadyAssistId < dogzId)
|
{
|
minAlreadyAssistId = dogzId;
|
}
|
}
|
|
foreach (var dogzId in m_DogzEquipLimit.Keys)
|
{
|
var equips = GetDogzEquips(dogzId);
|
int equipNum = equips == null ? 0 : equips.Count;
|
bool isBetterDogz = true;
|
if(!TryGetAssistDogzState(dogzId) && dogzId > minAlreadyAssistId && equipNum < 5)
|
{
|
for (int i = 0; i < 5; i++)
|
{
|
ItemModel _data;
|
bool _equiped = TryGetDogzEquip(dogzId, i + 101, out _data);
|
if (!_equiped)
|
{
|
GetDogzItemListByIndex(dogzId,i);
|
if (selectEquipPlacelist.Count < 1)
|
{
|
isBetterDogz = false;
|
break;
|
}
|
}
|
}
|
}
|
else
|
{
|
isBetterDogz = false;
|
}
|
|
if(isBetterDogz)
|
{
|
for (int i = 0; i < 5; i++)
|
{
|
ItemModel _data;
|
bool _equiped = TryGetDogzEquip(dogzId, i + 101, out _data);
|
if (!_equiped)
|
{
|
Redpoint equipPlaceRedpoint = GetDogzEquipPlaceRedpointById(dogzId, i);
|
if (equipPlaceRedpoint.state == RedPointState.None)
|
{
|
equipPlaceRedpoint.state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
break;
|
}
|
}
|
}
|
}
|
|
public void UpdateAssistNumRed()
|
{
|
if(CheckIsAddAssistNum())
|
{
|
if(addAssistDogzRedpoint.state == RedPointState.None)
|
{
|
addAssistDogzRedpoint.state = RedPointState.Simple;
|
}
|
}
|
else
|
{
|
addAssistDogzRedpoint.state = RedPointState.None;
|
}
|
}
|
#endregion
|
}
|
}
|
|