少年修仙传客户端代码仓库
6567 子 【2.0】【开发】强化、镶嵌、洗炼、升星排序规则、红点规则、选中规则 / 【2.0】【前端】强化、镶嵌、洗炼、升星排序规则、红点规则、选中规则
4个文件已修改
259 ■■■■■ 已修改文件
System/EquipGem/EquipStrengthHeadBehaviour.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipGem/EquipStrengthModel.cs 238 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipGem/EquipStrengthSelectBehaviour.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipGem/EquipStrengthWin.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/EquipGem/EquipStrengthHeadBehaviour.cs
@@ -48,7 +48,8 @@
            m_Select.SetListener(OnSelect);
            Redpoint redpoint;
            m_Redpoint.redpointId = 0;
            strengthModel.TryGetRedpoint(level, out redpoint);
            m_Redpoint.redpointId = redpoint.id;
        }
        private void OnSelect()
System/EquipGem/EquipStrengthModel.cs
@@ -94,6 +94,17 @@
    public Int2 jumpEquipPosition { get; set; }
    public bool isServerPrepare { get; private set; }
    public readonly Redpoint redpoint = new Redpoint(106, 10601);
    public static int REDPOINTBASE = 106010000;
    Dictionary<int, Redpoint> m_EquipSetRedpoints = new Dictionary<int, Redpoint>();
    Dictionary<int, EquipStrengthRedpoint> m_EquipStrengthRedpoints = new Dictionary<int, EquipStrengthRedpoint>();
    Dictionary<Int2, Redpoint> equipPositionRed = new Dictionary<Int2, Redpoint>();
    PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
    EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
    EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
@@ -110,21 +121,87 @@
        {
            equipPlaces.Add(i);
        }
        var configs = EquipControlConfig.GetValues();
        var totalEquipLevels = new List<int>();
        foreach (var item in configs)
        {
            var level = item.level;
            if (!totalEquipLevels.Contains(level))
            {
                totalEquipLevels.Add(level);
            }
        }
        foreach (var level in totalEquipLevels)
        {
            var equipSetRedpointBase = REDPOINTBASE++;
            m_EquipSetRedpoints[level] = new Redpoint(redpoint.id, equipSetRedpointBase);
            foreach (var place in equipPlaces)
            {
                var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
                if (!m_EquipStrengthRedpoints.ContainsKey(packIndex))
                {
                    EquipStrengthRedpoint _redpoint = new EquipStrengthRedpoint(equipSetRedpointBase);
                    m_EquipStrengthRedpoints.Add(packIndex, _redpoint);
                }
            }
        }
        packModel.refreshItemCountEvent += RefreshItemCountEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
    }
    public void OnBeforePlayerDataInitialize()
    {
        isServerPrepare = false;
    }
    public void OnPlayerLoginOk()
    {
        UpdateRedpoint();
        isServerPrepare = true;
    }
    public override void UnInit()
    {
        packModel.refreshItemCountEvent -= RefreshItemCountEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
    }
    private void PlayerDataRefreshEvent(PlayerDataType dataType)
    {
        if (dataType == PlayerDataType.Silver)
        {
            if (isServerPrepare)
            {
                UpdateRedpoint();
            }
        }
    }
    private void OnFuncStateChangeEvent(int id)
    {
        if (id == (int)FuncOpenEnum.Strength)
        {
            if (isServerPrepare)
            {
                UpdateRedpoint();
            }
        }
    }
    private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
    {
        if (packType == PackType.Item)
        {
            if (isServerPrepare)
            {
                UpdateRedpoint();
            }
        }
    }
    public void UpdateEuipPartPlusInfo(HA3B3_tagMCEquipPartPlusInfo info)
@@ -159,6 +236,11 @@
        if (EquipStrengthUpdate != null)
        {
            EquipStrengthUpdate();
        }
        if (isServerPrepare)
        {
            UpdateRedpoint();
        }
    }
@@ -405,6 +487,158 @@
        }
        return 0;
    }
    public bool SatisfyEquipAdvance(Int2 position)
    {
        int equipLv = 0;
        int advancedLv = 0;
        int itemCount = 0;
        int equipIndex = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
        if (EquipStrengthDic.ContainsKey(equipIndex))//获取当前强化等级
        {
            equipLv = EquipStrengthDic[equipIndex].StrengthLevel;
            advancedLv = EquipStrengthDic[equipIndex].EvolveLV;
        }
        var equipPlusEvolve = GetEquipPlusEvolve(position.y, advancedLv + 1);
        if (equipPlusEvolve == null)
        {
            return false;
        }
        if (equipPlusEvolve.NeedPlusLV > equipLv)
        {
            return false;
        }
        itemCount = packModel.GetItemCountByID(PackType.Item, equipPlusEvolve.CostItemID);
        if (equipPlusEvolve.CostItemCount > itemCount)
        {
            return false;
        }
        return true;
    }
    public bool HasEnoughMoney(Int2 position)
    {
        var config = GetEquipConfig(position.x, position.y);
        if (config == null)
        {
            return false;
        }
        ulong money = UIHelper.GetMoneyCnt(3);
        ulong requireMoney = (ulong)config.costCount;
        return requireMoney < money;
    }
    public bool TryGetRedpoint(int level, out Redpoint _redpoint)
    {
        return m_EquipSetRedpoints.TryGetValue(level, out _redpoint);
    }
    public bool TryGetRedpoint(int level, int place, out EquipStrengthRedpoint _redpoint)
    {
        var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
        return m_EquipStrengthRedpoints.TryGetValue(packIndex, out _redpoint);
    }
    void UpdateRedpoint()
    {
        if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Strength))
        {
            RefreshRedpoint(Int2.zero, 0);
            return;
        }
        var equipSets = equipModel.GetAllEquipSets();
        foreach (var level in equipSets)
        {
            foreach (var place in equipPlaces)
            {
                var position = new Int2(level, place);
                var equipGuid = equipModel.GetEquip(position);
                if (string.IsNullOrEmpty(equipGuid))
                {
                    continue;
                }
                if (SatisfyEquipAdvance(position))
                {
                    RefreshRedpoint(position, 2);
                    return;
                }
            }
        }
        var satisfyPosition = Int2.zero;
        var minStage = int.MaxValue;
        foreach (var level in equipSets)
        {
            foreach (var place in equipPlaces)
            {
                var position = new Int2(level, place);
                var equipGuid = equipModel.GetEquip(position);
                if (string.IsNullOrEmpty(equipGuid))
                {
                    continue;
                }
                var state = GetEquipStrengthState(position);
                if (state != 0)
                {
                    continue;
                }
                if (!HasEnoughMoney(position))
                {
                    continue;
                }
                var serverPlace = EquipPlaceMapConfig.GetServerPlace(position.x, position.y);
                var strengthLevel = EquipStrengthDic[serverPlace].StrengthLevel;
                var stage = strengthLevel / 20;
                if (minStage > stage)
                {
                    minStage = stage;
                    satisfyPosition = position;
                }
            }
        }
        RefreshRedpoint(satisfyPosition, 1);
    }
    void RefreshRedpoint(Int2 position, int type)
    {
        var equipSets = equipModel.GetAllEquipSets();
        foreach (var level in equipSets)
        {
            foreach (var place in equipPlaces)
            {
                var packIndex = EquipPlaceMapConfig.GetServerPlace(level, place);
                EquipStrengthRedpoint redpoint;
                TryGetRedpoint(level, place, out redpoint);
                redpoint.strengthRedpoint.state =
                    position.x == level && position.y == place && type == 1 ? RedPointState.Simple : RedPointState.None;
                redpoint.advanceRedpoint.state =
                    position.x == level && position.y == place && type == 2 ? RedPointState.Simple : RedPointState.None;
            }
        }
    }
    public class EquipStrengthRedpoint
    {
        public readonly Redpoint redpoint;
        public readonly Redpoint strengthRedpoint;
        public readonly Redpoint advanceRedpoint;
        public EquipStrengthRedpoint(int baseId)
        {
            redpoint = new Redpoint(baseId, EquipStrengthModel.REDPOINTBASE++);
            strengthRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
            advanceRedpoint = new Redpoint(redpoint.id, EquipStrengthModel.REDPOINTBASE++);
        }
    }
}
System/EquipGem/EquipStrengthSelectBehaviour.cs
@@ -22,7 +22,6 @@
        [SerializeField] Button m_Select;
        [SerializeField] RedpointBehaviour m_Redpoint;
        EquipGemModel model { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }      
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } }
@@ -49,8 +48,11 @@
            if (equiped)
            {
                DisplayBase();
                EquipGemRedpoint equipGemRedpoint;
                m_Redpoint.redpointId = 0;
                EquipStrengthModel.EquipStrengthRedpoint redpoint;
                if (strengthModel.TryGetRedpoint(level, place, out redpoint))
                {
                    m_Redpoint.redpointId = redpoint.redpoint.id;
                }
            }
            else
            {
System/EquipGem/EquipStrengthWin.cs
@@ -29,6 +29,9 @@
        [SerializeField] Button m_AutomaticBtn;
        [SerializeField] Button m_StopBtn;
        [SerializeField] RedpointBehaviour m_AdvanceRedpoint;
        [SerializeField] RedpointBehaviour m_StrengthRedpoint;
        [SerializeField] UIEffect m_UIEffect1A;
        [SerializeField] UIEffect m_UIEffect1B;
        [SerializeField] UIEffect m_UIEffect1C;
@@ -303,6 +306,13 @@
            m_ContainerEmpty.gameObject.SetActive(false);
            m_ContainerStrength.gameObject.SetActive(true);
            EquipStrengthModel.EquipStrengthRedpoint redpoint;
            if (model.TryGetRedpoint(model.SelectLevel, model.SelectEquipPlace, out redpoint))
            {
                m_AdvanceRedpoint.redpointId = redpoint.advanceRedpoint.id;
                m_StrengthRedpoint.redpointId = redpoint.strengthRedpoint.id;
            }
            var equipGuid = equipModel.GetEquip(new Int2(model.SelectLevel, model.SelectEquipPlace));
            var state = model.GetEquipStrengthState(new Int2(model.SelectLevel, model.SelectEquipPlace));