少年修仙传客户端代码仓库
client_linchunjie
2018-09-19 1fe0e04da8cfaafac55c0785a3a9e901f2527831
3058【前端】我要变强取消变强模块的条件,优化战力状态显示
2个文件已修改
370 ■■■■ 已修改文件
System/RolePromote/RolePromoteModel.cs 280 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/RolePromote/RoleStrongerCell.cs 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/RolePromote/RolePromoteModel.cs
@@ -137,6 +137,7 @@
        #region 配置
        public Dictionary<int, int> wingLv2GenerDict = new Dictionary<int, int>();
        public Dictionary<int, List<RoleStrongerConfig>> roleStrongerDic = new Dictionary<int, List<RoleStrongerConfig>>();
        List<int> promotePercents = new List<int>();
        void ParseConfig()
        {
            var dict = Config.Instance.GetAllValues<RoleStrongerConfig>();
@@ -151,290 +152,51 @@
                }
                list.Add(cfg);
            }
            var _funcCfg = Config.Instance.Get<FuncConfigConfig>("WingLV");
            LitJson.JsonData _json = LitJson.JsonMapper.ToObject(_funcCfg.Numerical1);
            var funcConfig = Config.Instance.Get<FuncConfigConfig>("WingLV");
            LitJson.JsonData _json = LitJson.JsonMapper.ToObject(funcConfig.Numerical1);
            foreach (var _wingLv in _json.Keys)
            {
                wingLv2GenerDict.Add(int.Parse(_wingLv), int.Parse(_json[_wingLv].ToString()));
            }
            funcConfig = Config.Instance.Get<FuncConfigConfig>("FightpowerUp");
            promotePercents.AddRange(ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1));
        }
        public List<RoleStrongerConfig> GetRoleStrongerList(int funcType)
        public List<RoleStrongerConfig> GetStrongerConfigs(int funcType)
        {
            List<RoleStrongerConfig> list = null;
            roleStrongerDic.TryGetValue(funcType, out list);
            return list;
        }
        public bool IsHighestStage(int funcType, int id)
        public int GetPromoteState(int percent)
        {
            List<RoleStrongerConfig> list = GetRoleStrongerList(funcType);
            if (list != null && list.Count > 0)
            for (int i = 0; i < promotePercents.Count; i++)
            {
                if (id == list[list.Count - 1].id)
                if (percent <= promotePercents[i])
                {
                    return true;
                    return i;
                }
            }
            return false;
            return promotePercents.Count - 1;
        }
        #endregion
        public RoleStrongerConfig GetPresentRoleStronger(int funcType, out int presentValue, out bool reached)
        public RoleStrongerConfig GetPresentRoleStronger(int funcType)
        {
            presentValue = 0;
            List<RoleStrongerConfig> list = GetRoleStrongerList(funcType);
            reached = false;
            List<RoleStrongerConfig> list = GetStrongerConfigs(funcType);
            int i = 0;
            int presentLevel = PlayerDatas.Instance.baseData.LV;
            if (list != null && list.Count > 0)
            {
                switch ((FuncPowerType)list[0].funcType)
                for (i = 0; i < list.Count; i++)
                {
                    case FuncPowerType.Equip:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = GetEquipCnt(list[i].conditions[0]
                                    , list[i].conditions.Length > 1 ? list[i].conditions[1] : 0
                                    , list[i].conditions.Length > 2 ? list[i].conditions[2] : 0);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Plus:
                        {
                            var packTypeModel = playerPack.GetSinglePackModel(PackType.rptEquip);
                            if (packTypeModel == null || packTypeModel.GetPackModelIndexDict() == null || packTypeModel.GetPackModelIndexDict().Count == 0)
                            {
                                return list[0];
                            }
                            foreach (var itemPlace in packTypeModel.GetPackModelIndexDict().Keys)
                            {
                                presentValue += strengthengmodel.StrengthenTheCeiling(itemPlace);
                            }
                            for (i = 0; i < list.Count; i++)
                            {
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Rune:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                bool _satisfy = GetRuneCnt(list[i].conditions[0], out presentValue);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (!_satisfy || presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.GodWeapon:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                var magicianData = magicianModel.GetMagicianData(list[i].conditions[0]);
                                if (magicianData == null)
                                {
                                    return list[i];
                                }
                                presentValue = magicianData.level;
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Horse:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                int _itemColor = list[i].conditions.Length > 1 ? list[i].conditions[1] : 0;
                                int _lv = list[i].conditions.Length > 0 ? list[i].conditions[0] : 0;
                                presentValue = GetMountCnt(_itemColor, _lv);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Wing:
                        {
                            var itemModel = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
                            if (itemModel == null)
                            {
                                presentValue = 0;
                                break;
                            }
                            ItemConfig _tagChinItemModel = Config.Instance.Get<ItemConfig>((int)itemModel.itemInfo.ItemID);
                            presentValue = wingLv2GenerDict[_tagChinItemModel.LV];
                            for (i = 0; i < list.Count; i++)
                            {
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].conditions[0])
                                {
                                    presentValue = 0;
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Stone:
                        {
                            presentValue = allStoneLv;
                            for (i = 0; i < list.Count; i++)
                            {
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Suit:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = SuitModel.GetSameSuitCntByType((SuitType)list[i].conditions[0]);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Wash:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = GetWashCnt(list[i].conditions[0]);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Prestige:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = PlayerDatas.Instance.baseData.realmLevel;
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Pet:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = GetPetCnt(list[i].conditions.Length > 1 ? list[i].conditions[1] : list[i].conditions[0]);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    case FuncPowerType.Demon:
                    case FuncPowerType.Fairy:
                    case FuncPowerType.Human:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                Treasure treasure = null;
                                presentValue = 0;
                                if (treasureModel.TryGetTreasure(list[i].targetValue, out treasure))
                                {
                                    if (treasure.state == TreasureState.Collected)
                                    {
                                        presentValue = 1;
                                        continue;
                                    }
                                }
                                return list[i];
                            }
                        }
                        break;
                    case FuncPowerType.BlastFurnace:
                        {
                            for (i = 0; i < list.Count; i++)
                            {
                                presentValue = GetBlastFurnaceDragUseCount(list[i].conditions.Length > 0 ? list[i].conditions[0] : 1);
                                if (presentLevel < list[i].LV)
                                {
                                    break;
                                }
                                if (presentValue < list[i].targetValue)
                                {
                                    return list[i];
                                }
                            }
                        }
                        break;
                    if (presentLevel < list[i].LV)
                    {
                        return list[i];
                    }
                }
                reached = true;
                i = Mathf.Max(0, i - 1);
                i = Mathf.Min(list.Count - 1, i);
                return list[i];
                return list[list.Count - 1];
            }
            return null;
        }
System/RolePromote/RoleStrongerCell.cs
@@ -11,76 +11,60 @@
        RolePromoteModel m_Model;
        RolePromoteModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RolePromoteModel>());
            }
            get { return ModelCenter.Instance.GetModel<RolePromoteModel>(); }
        }
        RoleParticularModel m_RoleParticularModel;
        RoleParticularModel roleParticularModel
        {
            get
            {
                return m_RoleParticularModel ?? (m_RoleParticularModel = ModelCenter.Instance.GetModel<RoleParticularModel>());
            }
            get { return ModelCenter.Instance.GetModel<RoleParticularModel>(); }
        }
        [SerializeField] Image funcIcon;
        [SerializeField] Text presentFightPowerTxt;
        [SerializeField] Transform m_ContainerStrongerLabel;
        [SerializeField] Text strongerFightPowerTxt;
        [SerializeField] Text targetTxt;
        [SerializeField] Text m_FuncTxt;
        [SerializeField] Button strongerBtn;
        [SerializeField] GameObject reachTxtObj;
        [SerializeField] GameObject reachImgObj;
        [SerializeField] Image m_FuncIcon;
        [SerializeField] Text m_FightPower;
        [SerializeField] Text m_FuncName;
        [SerializeField] Image m_State;
        [SerializeField] Slider m_Slider;
        [SerializeField] Text m_Progress;
        [SerializeField] Button m_Goto;
        public override void Refresh(CellView cell)
        {
            int funcType = cell.index;
            int presentTargetValue = 0;
            bool reached = false;
            var cfg = model.GetPresentRoleStronger(funcType, out presentTargetValue, out reached);
            strongerBtn.onClick.RemoveAllListeners();
            if (cfg != null)
            var config = model.GetPresentRoleStronger(funcType);
            m_Goto.onClick.RemoveAllListeners();
            if (config != null)
            {
                var highestStage = model.IsHighestStage(funcType, cfg.id) && reached;
                funcIcon.SetSprite(cfg.Icon);
                m_FuncTxt.text = cfg.Name;
                ulong _presentFightPower = 0;
                _presentFightPower = roleParticularModel.GetFuncFightPower(funcType);
                presentFightPowerTxt.text = Language.Get("RolePromoteNowFight", _presentFightPower);
                m_FuncIcon.SetSprite(config.Icon);
                m_FuncName.text = config.Name;
                ulong fightPower = roleParticularModel.GetFuncFightPower(funcType);
                var highestStage = fightPower >= (ulong)config.recommendFightPower;
                m_FightPower.text = Language.Get("RolePromoteNowFight", fightPower);
                strongerFightPowerTxt.text = StringUtility.Contact(_presentFightPower >= (ulong)cfg.recommendFightPower ? Language.Get("RolePromoteMoreFight") : Language.Get("RolePromoteBetterFight"),
                    _presentFightPower >= (ulong)cfg.recommendFightPower ? cfg.strongerFightPower : cfg.recommendFightPower);
                strongerFightPowerTxt.color = _presentFightPower >= (ulong)cfg.recommendFightPower ?
                    UIHelper.GetUIColor(TextColType.Red) : UIHelper.GetUIColor(TextColType.Green, true);
                if (!highestStage)
                var progress = Mathf.Clamp01((float)fightPower / config.recommendFightPower);
                var percent = (int)(progress * 100);
                m_Slider.value = progress;
                m_Progress.text = StringUtility.Contact(percent, "%");
                var state = model.GetPromoteState(percent);
                switch (state)
                {
                    if (funcType == (int)FuncPowerType.Human
                        || funcType == (int)FuncPowerType.Demon
                        || funcType == (int)FuncPowerType.Fairy)
                    {
                        targetTxt.text = StringUtility.Contact(cfg.desc, "(", UIHelper.GetTextColorByItemColor(presentTargetValue > 0 ? TextColType.Green : TextColType.Red,
                            presentTargetValue.ToString()), "/", 1, ")");
                    }
                    else
                    {
                        targetTxt.text = StringUtility.Contact(cfg.desc, "(", UIHelper.GetTextColorByItemColor(presentTargetValue >= cfg.targetValue ? TextColType.Green : TextColType.Red,
                            presentTargetValue.ToString()), "/", cfg.targetValue, ")");
                    }
                    case 0:
                        m_State.SetSprite("XT_WYBQ_3");
                        break;
                    case 1:
                        m_State.SetSprite("XT_WYBQ_2");
                        break;
                    case 2:
                        m_State.SetSprite("XT_WYBQ_1");
                        break;
                }
                m_State.SetNativeSize();
                reachTxtObj.SetActive(highestStage);
                reachImgObj.SetActive(highestStage);
                targetTxt.gameObject.SetActive(!highestStage);
                strongerBtn.gameObject.SetActive(!highestStage);
                m_ContainerStrongerLabel.gameObject.SetActive(!highestStage);
                strongerBtn.onClick.AddListener(() =>
                m_Goto.onClick.AddListener(() =>
                {
                    WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)cfg.OpenUI);
                    WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.OpenUI);
                });
            }