| | |
| | | using UnityEngine;
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class DogzModel : Model
|
| | | public class DogzModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
|
| | | {
|
| | | PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | | ParseConfig();
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | {
|
| | | addAssistCnt = 0;
|
| | | dogzAssistStateDict.Clear();
|
| | | }
|
| | |
|
| | | public void OnAfterPlayerDataInitialize()
|
| | | {
|
| | | |
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | SetDogzEquipInfo();
|
| | | playerPack.RefreshItemCountAct -= RefreshDogzEquipInfo;
|
| | | playerPack.RefreshItemCountAct += RefreshDogzEquipInfo;
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | |
|
| | |
| | | AddAssistItem = int.Parse(_funcCfg.Numerical2);
|
| | | AddAssistItemCnt = ConfigParse.GetMultipleStr<int>(_funcCfg.Numerical3);
|
| | | m_DogzEquipStrenLimit = ConfigParse.GetDic<int, int>(_funcCfg.Numerical4);
|
| | | dogzAssists = new List<int>();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | |
|
| | | #region 协议
|
| | | public List<int> dogzAssists { get; private set; } //当前助战神兽列表
|
| | | public event Action UpdateAssistDogzEvent;
|
| | | public void UpdateAssistDogz()
|
| | |
|
| | | public int addAssistCnt { get; private set; } //额外购买的助战数
|
| | | public void SetServerAddAssistDogzCnt(HA3C0_tagMCDogzInfo info)
|
| | | {
|
| | | dogzAssists.Clear();
|
| | | addAssistCnt = info.BuyHelpbattleCount;
|
| | | DogzAssistDefaultCnt += addAssistCnt;
|
| | | }
|
| | |
|
| | | public event Action UpdateAssistDogzEvent;
|
| | | Dictionary<int, int> dogzAssistStateDict = new Dictionary<int, int>(); //神兽助战
|
| | | 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();
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetAssistDogzCount()
|
| | | {
|
| | | int assistCnt = 0;
|
| | | foreach(var key in dogzAssistStateDict.Keys)
|
| | | {
|
| | | if(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);
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshDogzEquipInfo(PackType type, int index, int id)
|
| | | {
|
| | | if (type != PackType.rptDogzEquip) return;
|
| | |
|
| | | ItemModel itemModel = playerPack.GetItemModelByIndex(type, index);
|
| | | int dogzId = GetDogzIDByIndex(index);
|
| | | if (itemModel != null)
|
| | | {
|
| | | for (int i = 0; i < m_DogzEquipDict[dogzId].Count; i++)
|
| | | {
|
| | | if (m_DogzEquipDict[dogzId][i].itemInfo.ItemPlace == index)
|
| | | {
|
| | | m_DogzEquipDict[dogzId][i] = itemModel;
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < m_DogzEquipDict[dogzId].Count; i++)
|
| | | {
|
| | | if (m_DogzEquipDict[dogzId][i].itemInfo.ItemPlace == index)
|
| | | {
|
| | | m_DogzEquipDict[dogzId].RemoveAt(i);
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获得神兽穿戴的装备数据
|
| | | /// </summary>
|
| | | private Dictionary<int, List<DogzEquipData>> m_DogzEquipDict = new Dictionary<int, List<DogzEquipData>>();
|
| | | public List<DogzEquipData> GetDogzEquips(int _dogzId)
|
| | | private Dictionary<int, List<ItemModel>> m_DogzEquipDict = new Dictionary<int, List<ItemModel>>();
|
| | | public List<ItemModel> GetDogzEquips(int _dogzId)
|
| | | {
|
| | | List<DogzEquipData> _list = null;
|
| | | List<ItemModel> _list = null;
|
| | | m_DogzEquipDict.TryGetValue(_dogzId,out _list);
|
| | | return _list;
|
| | | }
|
| | |
|
| | | public int GetDogzEquipPlaceByIndex(int index)
|
| | | {
|
| | | return (index % 5) + 101;
|
| | | }
|
| | |
|
| | | public int GetDogzIDByIndex(int index)
|
| | | {
|
| | | return (index / 5) + 1;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="_index"></param>
|
| | | /// <param name="_equipData"></param>
|
| | | /// <returns></returns>
|
| | | public bool TryGetDogzEquip(int _dogzId, int _index, out DogzEquipData _equipData)
|
| | | public bool TryGetDogzEquip(int _dogzId, int _index, out ItemModel _equipData)
|
| | | {
|
| | | _equipData = default(DogzEquipData);
|
| | | List<DogzEquipData> _list = GetDogzEquips(_dogzId);
|
| | | _equipData = null;
|
| | | List<ItemModel> _list = GetDogzEquips(_dogzId);
|
| | | if (_list == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var index = _list.FindIndex((x) =>
|
| | | |
| | | for(int i = 0; i < _list.Count; i++)
|
| | | {
|
| | | return x.Index == _index;
|
| | | });
|
| | | if (index != -1)
|
| | | {
|
| | | _equipData = _list[index];
|
| | | return true;
|
| | | int index = (int)(_list[i].itemInfo.ItemPlace % 5);
|
| | | if(index == _index)
|
| | | {
|
| | | _equipData = _list[i];
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 装备详细信息
|
| | |
| | |
|
| | | public void ViewDetail(int _itemId, bool compare = false)
|
| | | {
|
| | | viewDetailData = new DogzEquipData(_itemId);
|
| | | viewDetailCompare = compare;
|
| | | if (!WindowCenter.Instance.CheckOpen<DogzDetailsWin>())
|
| | | {
|
| | | WindowCenter.Instance.Open<DogzDetailsWin>();
|
| | | }
|
| | | //viewDetailData = new DogzEquipData(_itemId);
|
| | | //viewDetailCompare = compare;
|
| | | //if (!WindowCenter.Instance.CheckOpen<DogzDetailsWin>())
|
| | | //{
|
| | | // WindowCenter.Instance.Open<DogzDetailsWin>();
|
| | | //}
|
| | | }
|
| | |
|
| | | public int DogzEquipScore(DogzEquipData data)
|