Esempio n. 1
0
        /// <summary>
        /// 计算英雄属性(不包含装备)
        /// </summary>
        public static Dictionary <RoleAttributeType, RoleAttribute> CalcRoleAttributesDic(RoleInfo roleInfo)
        {
            PlayerInfo player = roleInfo as PlayerInfo;
            HeroInfo   hero   = roleInfo as HeroInfo;

            if (player != null)
            {
                return(PlayerUtil.CalcPlayerAttributesDic(player));
            }
            if (hero != null)
            {
                return(HeroUtil.CalcHeroAttributesDic(hero));
            }
            return(null);
        }
Esempio n. 2
0
        private void RefreshPlayerLevelAndAttributes()
        {
            PlayerInfo playerInfo     = GameProxy.instance.PlayerInfo;
            int        playerLevel    = playerInfo.level;
            int        playerMaxLevel = GlobalData.GetGlobalData().playerLevelMax;
            float      playerExpPercentToNextLevel = PlayerUtil.GetPlayerExpPercentToNextLevel(playerInfo);

            playerExpSlider.value       = playerExpPercentToNextLevel;
            playerExpPercentText.text   = string.Format(Localization.Get("common.percent"), ((int)(playerExpPercentToNextLevel * 100)));
            playerNameAndLevelText.text = string.Format(Localization.Get("ui.player_view.profession_name_and_level"), Localization.Get(playerInfo.heroData.name), playerLevel, playerMaxLevel);

            Dictionary <RoleAttributeType, RoleAttribute> playerAttributeDictionary = PlayerUtil.CalcPlayerAttributesDic(playerInfo);
            Dictionary <RoleAttributeType, RoleAttribute> playerAddAttrByEquipDic   = PlayerUtil.CalcPlayerAttributesDicByEquip(playerInfo);

            hpText.text = playerAttributeDictionary[RoleAttributeType.HP].ValueString;


            RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(playerInfo.heroData.roleType);
            int offence   = 0;
            int attackAdd = 0;

            if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack)
            {
                offence   = (int)playerAttributeDictionary[RoleAttributeType.NormalAtk].value;
                attackAdd = GetRoleAttrValue(playerAddAttrByEquipDic.GetValue(RoleAttributeType.NormalAtk));
            }
            else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack)
            {
                offence   = (int)playerAttributeDictionary[RoleAttributeType.MagicAtk].value;
                attackAdd = GetRoleAttrValue(playerAddAttrByEquipDic.GetValue(RoleAttributeType.MagicAtk));
            }
            offenceText.text = offence.ToString();

            defenceText.text = playerAttributeDictionary[RoleAttributeType.Normal_Def].ValueString;
            speedText.text   = playerAttributeDictionary[RoleAttributeType.Speed].ValueString;

            float crit  = playerAttributeDictionary.ContainsKey(RoleAttributeType.Crit) ? playerAttributeDictionary[RoleAttributeType.Crit].value : 0;
            float dodge = playerAttributeDictionary.ContainsKey(RoleAttributeType.Dodge) ? playerAttributeDictionary[RoleAttributeType.Dodge].value : 0;
            float block = playerAttributeDictionary.ContainsKey(RoleAttributeType.Block) ? playerAttributeDictionary[RoleAttributeType.Block].value : 0;
            float hit   = playerAttributeDictionary.ContainsKey(RoleAttributeType.Hit) ? playerAttributeDictionary[RoleAttributeType.Hit].value : 0;

            critText.text  = string.Format(Localization.Get("common.percent"), crit);
            dodgeText.text = string.Format(Localization.Get("common.percent"), dodge);
            blockText.text = string.Format(Localization.Get("common.percent"), block);
            hitText.text   = string.Format(Localization.Get("common.percent"), hit);

            hpAddText.text          = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.HP) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.HP].ValueString) : string.Empty;
            attackAddText.text      = attackAdd == 0 ? string.Empty : string.Format("(+{0})", attackAdd);
            defenceAddText.text     = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Normal_Def) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.Normal_Def].ValueString) : string.Empty;
            actionPointAddText.text = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Speed) ? string.Format("(+{0})", playerAddAttrByEquipDic[RoleAttributeType.Speed].ValueString) : string.Empty;
            float critAdd  = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Crit) ? playerAddAttrByEquipDic[RoleAttributeType.Crit].value : 0;
            float dodgeAdd = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Dodge) ? playerAddAttrByEquipDic[RoleAttributeType.Dodge].value : 0;
            float blockAdd = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Block) ? playerAddAttrByEquipDic[RoleAttributeType.Block].value : 0;
            float hitAdd   = playerAddAttrByEquipDic.ContainsKey(RoleAttributeType.Hit) ? playerAddAttrByEquipDic[RoleAttributeType.Hit].value : 0;

            critAddText.text  = critAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", critAdd));
            dodgeAddText.text = dodgeAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", dodgeAdd));
            blockAddText.text = blockAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", blockAdd));
            hitAddText.text   = hitAdd == 0 ? string.Empty : string.Format(Localization.Get("common.percent"), string.Format("(+{0})", hitAdd));
        }
        private void RefreshPlayerLevelAndAttributes(PlayerInfo playerInfo)
        {
            int   playerLevel    = playerInfo.level;
            int   playerMaxLevel = GlobalData.GetGlobalData().playerLevelMax;
            float playerExpPercentToNextLevel = PlayerUtil.GetPlayerExpPercentToNextLevel(playerInfo);

            playerLevelText.text      = playerLevel.ToString();
            playerLevelMaxText.text   = playerMaxLevel.ToString();;
            playerExpSlider.value     = playerExpPercentToNextLevel;
            playerExpPercentText.text = string.Format(Localization.Get("common.percent"), ((int)(playerExpPercentToNextLevel * 100)));

            Dictionary <RoleAttributeType, RoleAttribute> playerAttributeDictionary = PlayerUtil.CalcPlayerAttributesDic(playerInfo);

            hpText.text = playerAttributeDictionary[RoleAttributeType.HP].ValueString;

            RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(playerInfo.heroData.roleType);
            int offence = 0;

            if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack)
            {
                offence = (int)playerAttributeDictionary[RoleAttributeType.NormalAtk].value;
            }
            else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack)
            {
                offence = (int)playerAttributeDictionary[RoleAttributeType.MagicAtk].value;
            }
            attackText.text = offence.ToString();

            defenceText.text = playerAttributeDictionary[RoleAttributeType.Normal_Def].ValueString;
            speedText.text   = playerAttributeDictionary[RoleAttributeType.Speed].ValueString;

            float crit  = playerAttributeDictionary.ContainsKey(RoleAttributeType.Crit) ? playerAttributeDictionary[RoleAttributeType.Crit].value : 0;
            float dodge = playerAttributeDictionary.ContainsKey(RoleAttributeType.Dodge) ? playerAttributeDictionary[RoleAttributeType.Dodge].value : 0;
            float block = playerAttributeDictionary.ContainsKey(RoleAttributeType.Block) ? playerAttributeDictionary[RoleAttributeType.Block].value : 0;
            float hit   = playerAttributeDictionary.ContainsKey(RoleAttributeType.Hit) ? playerAttributeDictionary[RoleAttributeType.Hit].value : 0;

            critText.text  = string.Format(Localization.Get("common.percent"), crit);
            dodgeText.text = string.Format(Localization.Get("common.percent"), dodge);
            blockText.text = string.Format(Localization.Get("common.percent"), block);
            hitText.text   = string.Format(Localization.Get("common.percent"), hit);
        }