少年修仙传客户端代码仓库
Client_PangDeRong
2018-08-21 4c3f9dc75ca9ab8785c622a555a7454986f43ed4
System/Dogz/DogzModel.cs
@@ -21,7 +21,9 @@
            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()
@@ -58,7 +60,7 @@
                var _dict = new Dictionary<int, int>();
                for(int j = 0; j < _dogzCfgs[i].EquipPlaceColorList.Length; j++)
                {
                    _dict.Add(j+1, _dogzCfgs[i].EquipPlaceColorList[j]);
                    _dict.Add(j, _dogzCfgs[i].EquipPlaceColorList[j]);
                }
                m_DogzEquipLimit.Add(_dogzCfgs[i].ID, _dict);
            }
@@ -138,7 +140,7 @@
        public int GetAssistItemCnt()
        {
            return AddAssistItemCnt[0];
            return AddAssistItemCnt[addAssistCnt];
        }
        public int presentSelectDogz { get; set; } //当前选中的神兽id
@@ -189,7 +191,7 @@
            int assistCnt = 0;
            foreach(var key in dogzAssistStateDict.Keys)
            {
                if(key == 1)
                if(dogzAssistStateDict[key] == 1)
                {
                    assistCnt += 1;
                }
@@ -297,6 +299,53 @@
            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 = ConfigManager.Instance.GetTemplate<DogzConfig>(dogzId);
            int[] baseAttrIds = dogzConfig.BaseAttrTypes;
            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 = ConfigManager.Instance.GetTemplate<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;
                        }
                    }
                }
                m_DogzEquipAttrDict.Add(baseAttrIds[i], attrValue);
            }
            return m_DogzEquipAttrDict;
        }
        public int GetDogzEquipPlaceByIndex(int index)
        {
            return (index % 5) + 101;
@@ -335,6 +384,26 @@
            return false;
        }
        public void CheckPutOff(int equipPlace)
        {
            if (TryGetAssistDogzState(presentSelectDogz))
            {
                ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),"当前神兽助战中,卸下装备无法保持助战状态,确定继续?",
                    (bool isOk)=>
                    {
                        if(isOk)
                        {
                            SendPutOffEquip(equipPlace);
                        }
                        return;
                    });
            }
            else
            {
                SendPutOffEquip(equipPlace);
            }
        }
        public void SendPutOnEquip(int index)
        {
            CA5C0_tagCMDogzEquipItem dogzPutOn = new CA5C0_tagCMDogzEquipItem();
@@ -343,7 +412,7 @@
            GameNetSystem.Instance.SendInfo(dogzPutOn);
        }
        public void SendPutOffEquip(int equipPlace)
        private void SendPutOffEquip(int equipPlace)
        {
            CA5C1_tagCMDogzUnEquipItem dogzPutOff = new CA5C1_tagCMDogzUnEquipItem();
            dogzPutOff.DogzID = (byte)presentSelectDogz;
@@ -419,6 +488,43 @@
            return false;
        }
        public List<ItemModel> selectEquipPlacelist { get; private set; }
        public List<ItemModel> GetDogzItemListByIndex(int index)
        {
            SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptDogzItem);
            selectEquipPlacelist.Clear();
            if (singlePack == null) return selectEquipPlacelist;
            var _itemColor = GetDogzEquipLimitByIndex(presentSelectDogz, 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 装备详细信息
@@ -441,6 +547,24 @@
            return 0;
        }
        #endregion
        #region 默认选择逻辑处理
        public void SetDefaultSelectDogz()
        {
            var configs = ConfigManager.Instance.GetAllValues<DogzConfig>();
            presentSelectDogz = configs[0].ID;
            foreach (var key in dogzAssistStateDict.Keys)
            {
                if(dogzAssistStateDict[key] == 1)
                {
                    if(presentSelectDogz < key)
                    {
                        presentSelectDogz = key;
                    }
                }
            }
        }
        #endregion
    }
}