少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-11 a43ed92bd70275edb86e9372bee4d07848f519c2
3335 装备洗练功能开发。
2个文件已修改
190 ■■■■ 已修改文件
System/EquipTrain/EquipTrainModel.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipTrain/EquipTrainWin.cs 170 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipTrain/EquipTrainModel.cs
@@ -16,9 +16,8 @@
        public readonly LogicList<EquipTrainCandidate> candidatePlaces = new LogicList<EquipTrainCandidate>();
        public readonly LogicList<EquipTrainPropertyBar> propertyBars = new LogicList<EquipTrainPropertyBar>();
        Dictionary<int, EquipTrainSet> equipTrains = new Dictionary<int, EquipTrainSet>();
        static Dictionary<int, int> trainTypes = new Dictionary<int, int>();
        Dictionary<int, EquipTrainSet> equipTrains = new Dictionary<int, EquipTrainSet>();
        EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
@@ -186,8 +185,11 @@
        public int GetMaterialNeed(int level, int place)
        {
            var star = starModel.GetEquipStarLevel(level, place);
            var type = GetTrainType(place);
            var data = EquipWashConfig.Get(type, star + 1);
            return 5;
            return data.config.costCount;
        }
        public int GetMaxTrainLevel(int place)
@@ -303,14 +305,16 @@
        private int GetTrainMaterial(int level, int place)
        {
            var equipGuid = equipModel.GetEquip(level, place);
            var equip = packModel.GetItemByGuid(equipGuid);
            if (equip == null)
            if (IsEquipPlaceTrainable(equipGuid))
            {
                return 0;
                var star = starModel.GetEquipStarLevel(level, place);
                var type = GetTrainType(place);
                var data = EquipWashConfig.Get(type, star + 1);
                return data.config.costItem;
            }
            else
            {
                return 1;
                return 0;
            }
        }
@@ -329,7 +333,7 @@
        {
            var currentLevel = GetTrainLevel(level, place);
            var maxLevel = GetMaxTrainLevel(level, place);
            if (currentLevel >= maxLevel)
            if (maxLevel > 0 && currentLevel >= maxLevel)
            {
                return TrainOperateType.Max;
            }
System/EquipTrain/EquipTrainWin.cs
@@ -18,13 +18,12 @@
        [SerializeField] Text m_MaxTrainLevel;
        [SerializeField] ItemCell m_TargetEquip;
        [SerializeField] ItemBehaviour m_Material;
        [SerializeField] Text m_MaterialCount;
        [SerializeField] ItemBehaviour m_InevitableMaterial;
        [SerializeField] Text m_InevitableMaterialCount;
        [SerializeField] RectTransform m_DiamondContainer;
        [SerializeField] Text m_DiamondCount;
        [SerializeField] MaterialCell m_MaterialCell;
        [SerializeField] InevitableMaterialCell m_InevitableMaterial;
        [SerializeField] RectTransform m_UnTrainableContainer;
        [SerializeField] RectTransform m_TrainableContainer;
        [SerializeField] Text m_TrainLevel;
        [SerializeField] EquipTrainPropertyBarBehaviour[] m_PropertyBarBehaviours;
        [SerializeField] RectTransform m_MaxLevelContainer;
@@ -148,8 +147,15 @@
                var place = model.selectedPlace.value;
                var maxTrain = model.equipTrainMaxLevel.Fetch();
                var star = starModel.GetEquipStarLevel(level, place);
                m_MaxTrainLevel.text = string.Format("{0}星装备最高可洗练至{1}级", star, maxTrain);
                if (maxTrain > 0)
                {
                    var star = starModel.GetEquipStarLevel(level, place);
                    m_MaxTrainLevel.text = string.Format("{0}星装备最高可洗练至{1}级", star, maxTrain);
                }
                else
                {
                    m_MaxTrainLevel.text = "提升装备星级可洗练";
                }
            }
            if (force || model.material.dirty)
@@ -180,62 +186,61 @@
        private void DisplayMaterial(int level, int place, int itemId)
        {
            var own = 0;
            var need = 0;
            if (itemId > 0)
            {
                m_Material.gameObject.SetActive(true);
                m_MaterialCount.gameObject.SetActive(true);
                m_Material.SetItem(itemId, 1);
                var need = model.GetMaterialNeed(level, place);
                var own = packModel.GetItemCountByID(PackType.Item, itemId);
                var enough = own >= need;
                m_MaterialCount.text = string.Format("{0}/{1}", UIHelper.AppendStringColor(enough ? TextColType.White : TextColType.Red, own.ToString(), true), need);
                need = model.GetMaterialNeed(level, place);
                own = packModel.GetItemCountByID(PackType.Item, itemId);
            }
            else
            {
                m_Material.gameObject.SetActive(false);
                m_MaterialCount.gameObject.SetActive(false);
            }
            m_MaterialCell.Display(itemId, need, own);
        }
        private void DisplayInevitableMaterial(int level, int place, int need)
        {
            m_InevitableMaterial.SetItem(GeneralDefine.equipTrainMustItemId, 1);
            var own = packModel.GetItemCountByID(PackType.Item, GeneralDefine.equipTrainMustItemId);
            var enough = own >= need;
            m_InevitableMaterialCount.text = string.Format("{0}/{1}",
                UIHelper.AppendStringColor(enough ? TextColType.White : TextColType.Red, own.ToString(), true), need);
            if (enough)
            var equipGuid = equipModel.GetEquip(level, place);
            var trainable = model.IsEquipPlaceTrainable(equipGuid);
            if (trainable)
            {
                m_DiamondContainer.gameObject.SetActive(false);
            }
            else
            {
                m_DiamondContainer.gameObject.SetActive(true);
                var own = packModel.GetItemCountByID(PackType.Item, GeneralDefine.equipTrainMustItemId);
                var type = EquipTrainModel.GetTrainType(place);
                var trainLevel = model.GetTrainLevel(level, place);
                var config = EquipWashConfig.Get(type, trainLevel + 1);
                m_DiamondCount.text = config.mustCosts[need - 1].ToString();
                m_InevitableMaterial.Display(false, own, need, config.mustCosts[need - 1]);
            }
            else
            {
                m_InevitableMaterial.Display(true, 0, 0, 0);
            }
        }
        private void DisplayProperty(List<EquipTrainPropertyBar> propertyBars)
        {
            for (int i = 0; i < m_PropertyBarBehaviours.Length; i++)
            var isTrainable = !propertyBars.IsNullOrEmpty();
            if (isTrainable)
            {
                var behaviour = m_PropertyBarBehaviours[i];
                if (i < propertyBars.Count)
                m_UnTrainableContainer.gameObject.SetActive(false);
                m_TrainableContainer.gameObject.SetActive(true);
                for (int i = 0; i < m_PropertyBarBehaviours.Length; i++)
                {
                    behaviour.gameObject.SetActive(true);
                    behaviour.Display(propertyBars[i]);
                }
                else
                {
                    behaviour.gameObject.SetActive(false);
                    var behaviour = m_PropertyBarBehaviours[i];
                    if (i < propertyBars.Count)
                    {
                        behaviour.gameObject.SetActive(true);
                        behaviour.Display(propertyBars[i]);
                    }
                    else
                    {
                        behaviour.gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                m_UnTrainableContainer.gameObject.SetActive(true);
                m_TrainableContainer.gameObject.SetActive(false);
            }
        }
        private void DisplayOperateButton(EquipTrainModel.TrainOperateType opreateType)
@@ -243,6 +248,9 @@
            switch (opreateType)
            {
                case EquipTrainModel.TrainOperateType.None:
                    m_Train.gameObject.SetActive(false);
                    m_Save.gameObject.SetActive(false);
                    m_GiveUp.gameObject.SetActive(false);
                    break;
                case EquipTrainModel.TrainOperateType.Train:
                    m_Train.gameObject.SetActive(true);
@@ -257,6 +265,9 @@
                    m_GiveUp.gameObject.SetActive(false);
                    break;
                case EquipTrainModel.TrainOperateType.Max:
                    m_Train.gameObject.SetActive(false);
                    m_Save.gameObject.SetActive(false);
                    m_GiveUp.gameObject.SetActive(false);
                    break;
            }
@@ -317,6 +328,77 @@
            }
        }
        [Serializable]
        public class MaterialCell
        {
            public RectTransform m_LockContainer;
            public ItemBehaviour m_Material;
            public Text m_MaterialCount;
            public void Display(int itemId, int need, int own)
            {
                if (itemId > 0)
                {
                    m_LockContainer.gameObject.SetActive(false);
                    m_Material.gameObject.SetActive(true);
                    m_MaterialCount.gameObject.SetActive(true);
                    m_Material.SetItem(itemId, 1);
                    var enough = own >= need;
                    m_MaterialCount.text = string.Format("{0}/{1}", UIHelper.AppendStringColor(enough ? TextColType.White : TextColType.Red, own.ToString(), true), need);
                }
                else
                {
                    m_LockContainer.gameObject.SetActive(true);
                    m_Material.gameObject.SetActive(false);
                    m_MaterialCount.gameObject.SetActive(false);
                }
            }
        }
        [Serializable]
        public class InevitableMaterialCell
        {
            public RectTransform m_LockContainer;
            public ItemBehaviour m_InevitableMaterial;
            public Text m_InevitableMaterialCount;
            public RectTransform m_DiamondContainer;
            public Text m_DiamondCount;
            public void Display(bool locked, int need, int own, int diamond)
            {
                if (locked)
                {
                    m_LockContainer.gameObject.SetActive(true);
                    m_InevitableMaterial.gameObject.SetActive(false);
                    m_InevitableMaterialCount.gameObject.SetActive(false);
                    m_DiamondContainer.gameObject.SetActive(false);
                }
                else
                {
                    m_LockContainer.gameObject.SetActive(false);
                    m_InevitableMaterial.gameObject.SetActive(true);
                    m_InevitableMaterialCount.gameObject.SetActive(true);
                    m_InevitableMaterial.SetItem(GeneralDefine.equipTrainMustItemId, 1);
                    var enough = own >= need;
                    m_InevitableMaterialCount.text = string.Format("{0}/{1}",
                        UIHelper.AppendStringColor(enough ? TextColType.White : TextColType.Red, own.ToString(), true), need);
                    if (diamond > 0)
                    {
                        m_DiamondContainer.gameObject.SetActive(true);
                        m_DiamondCount.text = diamond.ToString();
                    }
                    else
                    {
                        m_DiamondContainer.gameObject.SetActive(false);
                    }
                }
            }
        }
    }
}