少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-04 7268a79e72f4029b9fa2ccd50de756659c3166a6
3555 新版装备功能开发
2个文件已修改
185 ■■■■ 已修改文件
Core/GameEngine/Model/TelPartialConfig/PartialEquipStarConfig.cs 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipStar/EquipStarWin.cs 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/TelPartialConfig/PartialEquipStarConfig.cs
@@ -5,17 +5,44 @@
public partial class EquipStarConfig : IConfigPostProcess
{
    static Dictionary<int, EquipStarConfig> equipStarConfigs = new Dictionary<int, EquipStarConfig>();
    static Dictionary<int, List<EquipStarConfig>> equipStarConfigs = new Dictionary<int, List<EquipStarConfig>>();
    public void OnConfigParseCompleted()
    {
        var key = Level * 10000 + EquipPlace * 100 + Star;
        equipStarConfigs[key] = this;
        var key = Level * 10000 + EquipPlace * 100;
        if (!equipStarConfigs.ContainsKey(key))
        {
            equipStarConfigs[key] = new List<EquipStarConfig>();
        }
        equipStarConfigs[key].Add(this);
    }
    public static EquipStarConfig Get(int level, int equipPlace, int star)
    {
        var key = level * 10000 + equipPlace * 100 + star;
        var key = level * 10000 + equipPlace * 100;
        if (equipStarConfigs.ContainsKey(key))
        {
            var configs = equipStarConfigs[key];
            foreach (var item in configs)
            {
                if (item.Star == star)
                {
                    return item;
                }
            }
            return null;
        }
        else
        {
            return null;
        }
    }
    public static List<EquipStarConfig> GetConfigs(int level, int equipPlace)
    {
        var key = level * 10000 + equipPlace * 100;
        if (equipStarConfigs.ContainsKey(key))
        {
            return equipStarConfigs[key];
System/EquipStar/EquipStarWin.cs
@@ -15,12 +15,12 @@
    public class EquipStarWin : Window
    {
        [SerializeField] CyclicScroll m_CandidateScroll;
        [SerializeField] Image[] m_Stars;
        [SerializeField] ImageCouple[] m_Stars;
        [SerializeField] ItemCell m_TargetEquip;
        [SerializeField] Materials m_Materials;
        [SerializeField] Text m_SuccessRate;
        [SerializeField] PropertyPreview[] m_PropertyPreviews;
        [SerializeField] Text m_NewProperty;
        [SerializeField] BaseProperty[] m_BasePropertys;
        [SerializeField] Text[] m_LevelUpPropertys;
        [SerializeField] Button m_StarUpgrade;
        EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
@@ -84,45 +84,9 @@
                m_TargetEquip.Init(equip);
                var currentStarLevel = model.GetEquipStarLevel(equip.config.LV, equip.config.EquipPlace);
                var maxStarLevel = model.GetMaxStarLevel(equip.config.LV);
                for (var i = 0; i < m_Stars.Length; i++)
                {
                    m_Stars[i].gameObject.SetActive(i < maxStarLevel);
                    if (i < maxStarLevel)
                    {
                        m_Stars[i].SetSprite(i < currentStarLevel ? "" : "");
                    }
                }
                var starConfig = EquipStarConfig.Get(equip.config.LV, equip.config.EquipPlace, currentStarLevel);
                var equalCount = Mathf.Min(starConfig.BaseAttrInfo.Length, starConfig.StarAttrInfo.Length);
                for (var i = 0; i < m_PropertyPreviews.Length; i++)
                {
                    var behaviour = m_PropertyPreviews[i];
                    if (i < equalCount)
                    {
                        behaviour.Display(starConfig.BaseAttrInfo[i].x, starConfig.BaseAttrInfo[i].y, starConfig.StarAttrInfo[i].y);
                    }
                    else
                    {
                        behaviour.Hide();
                    }
                }
                var newCount = starConfig.StarAttrInfo.Length - starConfig.BaseAttrInfo.Length;
                if (newCount > 0)
                {
                    var property = starConfig.StarAttrInfo[starConfig.StarAttrInfo.Length - 1];
                    var propertyConfig = PlayerPropertyConfig.Get(property.x);
                    var valueDescription = propertyConfig.ISPercentage == 1
                        ? StringUtility.Contact(Mathf.RoundToInt(property.y * 0.01f), "%") : property.y.ToString();
                    m_NewProperty.text = StringUtility.Contact(propertyConfig.Name, " +", valueDescription);
                    m_NewProperty.gameObject.SetActive(true);
                }
                else
                {
                    m_NewProperty.gameObject.SetActive(false);
                }
                DisplayStars(equip.config.LV, equip.config.EquipPlace, currentStarLevel);
                DisplayBaseProperty(equip.config.LV, equip.config.EquipPlace, currentStarLevel);
                DisplayLevelUpProperty(equip.config.LV, equip.config.EquipPlace, currentStarLevel);
            }
            if (force || model.starUpgradeProbability.dirty)
@@ -138,10 +102,101 @@
            }
        }
        private void DisplayStars(int level, int equipPlace, int currentStarLevel)
        {
            var maxStarLevel = model.GetMaxStarLevel(level);
            for (var i = 0; i < m_Stars.Length; i++)
            {
                if (i < maxStarLevel)
                {
                    m_Stars[i].Display(i < currentStarLevel);
                }
                else
                {
                    m_Stars[i].Hide();
                }
            }
        }
        private void DisplayBaseProperty(int level, int equipPlace, int currentStarLevel)
        {
            var nowConfig = EquipStarConfig.Get(level, equipPlace, currentStarLevel);
            var nextConfig = EquipStarConfig.Get(level, equipPlace, currentStarLevel + 1);
            var count = nextConfig.BaseAttrInfo.Length;
            for (var i = 0; i < m_BasePropertys.Length; i++)
            {
                var behaviour = m_BasePropertys[i];
                if (i < count)
                {
                    var current = nowConfig == null ? 0 : nowConfig.BaseAttrInfo[i].y;
                    var next = nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].y;
                    behaviour.Display(nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].x, current, next);
                }
                else
                {
                    behaviour.Hide();
                }
            }
        }
        private void DisplayLevelUpProperty(int level, int equipPlace, int currentStarLevel)
        {
            var configs = EquipStarConfig.GetConfigs(level, equipPlace);
            var levelUpProperties = new Dictionary<int, Int2>();
            var prePropertiesCount = 0;
            foreach (var config in configs)
            {
                if (config.StarAttrInfo.Length > prePropertiesCount)
                {
                    var length = config.StarAttrInfo.Length;
                    levelUpProperties[config.Star] = config.StarAttrInfo[length - 1];
                    prePropertiesCount = config.StarAttrInfo.Length;
                }
            }
            var keys = new List<int>(levelUpProperties.Keys);
            for (var i = 0; i < m_LevelUpPropertys.Length; i++)
            {
                var behaviour = m_LevelUpPropertys[i];
                if (i < keys.Count)
                {
                    var property = levelUpProperties[keys[i]];
                    var config = PlayerPropertyConfig.Get(property.x);
                    behaviour.gameObject.SetActive(true);
                    behaviour.text = string.Format("【{0}星】{1}+{2}", config.Name, PlayerPropertyConfig.GetPropertyDescription(property.x, property.y));
                    behaviour.color = UIHelper.GetUIColor(keys[i] == currentStarLevel + 1 ? TextColType.Green : TextColType.Gray);
                }
                else
                {
                    behaviour.gameObject.SetActive(false);
                }
            }
        }
        private void StarUpgrade()
        {
            var equip = packModel.GetItemByGuid(model.selectedEquip.value);
            model.DoStarUpgrade(equip.config.LV, equip.config.EquipPlace);
        }
        [System.Serializable]
        public class ImageCouple
        {
            public RectTransform container;
            public Image imageBase;
            public Image imageStar;
            public void Display(bool active)
            {
                container.gameObject.SetActive(true);
                imageStar.gameObject.SetActive(active);
            }
            public void Hide()
            {
                container.gameObject.SetActive(false);
            }
        }
        [System.Serializable]
@@ -179,10 +234,9 @@
        }
        [System.Serializable]
        public class PropertyPreview
        public class BaseProperty
        {
            public RectTransform container;
            public Text propertyName;
            public Text current;
            public Text next;
@@ -192,12 +246,8 @@
                var config = PlayerPropertyConfig.Get(propertyId);
                if (config != null)
                {
                    propertyName.text = config.Name;
                    this.current.text = config.ISPercentage == 1 ?
                        StringUtility.Contact(Mathf.RoundToInt(currentValue * 0.01f), "%") : currentValue.ToString();
                    this.next.text = config.ISPercentage == 1 ?
                        StringUtility.Contact(Mathf.RoundToInt(nextValue * 0.01f), "%") : nextValue.ToString();
                    this.current.text = StringUtility.Contact(config.Name, ":", PlayerPropertyConfig.GetPropertyDescription(propertyId, currentValue));
                    this.next.text = PlayerPropertyConfig.GetPropertyDescription(propertyId, nextValue);
                }
            }