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)); }
/// <summary> ///获取主属性 /// </summary> public static List <RoleAttribute> CalcHeroMainAttributesList(HeroInfo hero) { List <RoleAttribute> mainAttriList = new List <RoleAttribute>(); List <RoleAttribute> attriList = CalcHeroAttributes(hero); RoleAttribute attribute; RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(hero.heroData.roleType); for (int i = 0, count = attriList.Count; i < count; i++) { attribute = attriList[i]; if (attribute.type == RoleAttributeType.HP) { mainAttriList.Add(attribute); } else if (attribute.type == RoleAttributeType.MagicAtk && roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack) { mainAttriList.Add(attribute); } else if (attribute.type == RoleAttributeType.NormalAtk && roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { mainAttriList.Add(attribute); } else if (attribute.type == RoleAttributeType.Normal_Def) { mainAttriList.Add(attribute); } } return(mainAttriList); }
public static EquipmentType GetRoleCorrespondingWeaponType(RoleInfo roleInfo) { RoleAttackAttributeType roleAttackAttributeType = RoleAttackAttributeType.Invalid; EquipmentType equipmentType = EquipmentType.None; if (roleInfo is PlayerInfo) { PlayerInfo playerInfo = roleInfo as PlayerInfo; roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(playerInfo.heroData.roleType); } else if (roleInfo is HeroInfo) { HeroInfo heroInfo = roleInfo as HeroInfo; roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(heroInfo.heroData.roleType); } if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { equipmentType = EquipmentType.PhysicalWeapon; } else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack) { equipmentType = EquipmentType.MagicalWeapon; } return(equipmentType); }
private void RefreshAttributes() { Dictionary <RoleAttributeType, RoleAttribute> roleAttributesDic = RoleUtil.CalcRoleAttributesDic(_playerInfo); Dictionary <RoleAttributeType, RoleAttribute> roleAttributeAddByEquipmentDic = RoleUtil.CalcRoleAttributesDicByEquip(_playerInfo); RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(_playerInfo.heroData.roleType); int hpValue = (int)roleAttributesDic[RoleAttributeType.HP].value; int offenceValue = 0; int defenceValue = 0; int speedValue = (int)roleAttributesDic[RoleAttributeType.Speed].value; int criticalValue = roleAttributesDic.ContainsKey(RoleAttributeType.Crit) ? (int)roleAttributesDic[RoleAttributeType.Crit].value : 0; int dodgeValue = roleAttributesDic.ContainsKey(RoleAttributeType.Dodge) ? (int)roleAttributesDic[RoleAttributeType.Dodge].value : 0; int blockValue = roleAttributesDic.ContainsKey(RoleAttributeType.Block) ? (int)roleAttributesDic[RoleAttributeType.Block].value : 0; int hitValue = roleAttributesDic.ContainsKey(RoleAttributeType.Hit) ? (int)roleAttributesDic[RoleAttributeType.Hit].value : 0; int hpAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.HP) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.HP].value : 0; int offenceAddValue = 0; int defenceAddValue = 0; int speedAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Speed) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.Speed].value : 0; int criticalAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Crit) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.Crit].value : 0; int dodgeAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Dodge) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.Dodge].value : 0; int blockAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Block) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.Block].value : 0; int hitAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Hit) ? (int)roleAttributeAddByEquipmentDic[RoleAttributeType.Hit].value : 0; if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { offenceValue = (int)roleAttributesDic[RoleAttributeType.NormalAtk].value; offenceAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.NormalAtk) ? (int)roleAttributeAddByEquipmentDic.GetValue(RoleAttributeType.NormalAtk).value : 0; } else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack) { offenceValue = (int)roleAttributesDic[RoleAttributeType.MagicAtk].value; offenceAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.MagicAtk) ? (int)roleAttributeAddByEquipmentDic.GetValue(RoleAttributeType.MagicAtk).value : 0; } defenceValue = (int)roleAttributesDic[RoleAttributeType.Normal_Def].value; defenceAddValue = roleAttributeAddByEquipmentDic.ContainsKey(RoleAttributeType.Normal_Def) ? (int)roleAttributeAddByEquipmentDic.GetValue(RoleAttributeType.Normal_Def).value : 0; hpItem.SetValue(hpValue); hpItem.SetAddValue(hpAddValue); offenceItem.SetValue(offenceValue); offenceItem.SetAddValue(offenceAddValue); defenceItem.SetValue(defenceValue); defenceItem.SetAddValue(defenceAddValue); speedItem.SetValue(speedValue); speedItem.SetAddValue(speedAddValue); criticalItem.SetValue(criticalValue); criticalItem.SetAddValue(criticalAddValue); dodgeItem.SetValue(dodgeValue); dodgeItem.SetAddValue(dodgeAddValue); blockItem.SetValue(blockValue); blockItem.SetAddValue(blockAddValue); hitItem.SetValue(hitValue); hitItem.SetAddValue(hitAddValue); }
private void InitAttribute() { _attrDic.Clear(); _attrDic.Add(RoleAttributeType.HP, 1); RoleType roleType = _roleInfo.heroData.roleType; RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(roleType); if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { _attrDic.Add(RoleAttributeType.NormalAtk, 1); } else { _attrDic.Add(RoleAttributeType.MagicAtk, 1); } _attrDic.Add(RoleAttributeType.Normal_Def, 1); _attrDic.Add(RoleAttributeType.Speed, 1); }
public void ClickWeaponHandler() { if (!FunctionOpen.Model.FunctionOpenProxy.instance.IsFunctionOpen(FunctionOpenType.MainView_Equipment, true)) { return; } RoleEquipmentsView roleEquipmentsView = UIMgr.instance.Open <RoleEquipmentsView>(RoleEquipmentsView.PREFAB_PATH); roleEquipmentsView.SetPlayerInfo(GameProxy.instance.PlayerInfo); RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(GameProxy.instance.PlayerInfo.heroData.roleType); if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { roleEquipmentsView.SetCurrentSelectEquipmentType(EquipmentType.PhysicalWeapon); } else if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack) { roleEquipmentsView.SetCurrentSelectEquipmentType(EquipmentType.MagicalWeapon); } }
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); }
/// <summary> ///获取属性(给定type列表) /// </summary> public static List <RoleAttribute> CalcPlayerAttributesList(PlayerInfo player, List <RoleAttributeType> needTypes) { List <RoleAttribute> mainAttriList = new List <RoleAttribute>(); List <RoleAttribute> attriList = CalcPlayerAttributesDic(player).GetValues(); RoleAttribute attribute; RoleAttackAttributeType roleAttackAttributeType = CharacterUtil.GetRoleAttackAttributeType(player.heroData.roleType); for (int i = 0, count = attriList.Count; i < count; i++) { attribute = attriList[i]; if (needTypes.Contains(attribute.type)) { if (attribute.type == RoleAttributeType.MagicAtk) { if (roleAttackAttributeType == RoleAttackAttributeType.MagicalAttack) { mainAttriList.Add(attribute); } } else if (attribute.type == RoleAttributeType.NormalAtk) { if (roleAttackAttributeType == RoleAttackAttributeType.PhysicalAttack) { mainAttriList.Add(attribute); } } else if (attribute.type == RoleAttributeType.Normal_Def) { mainAttriList.Add(attribute); } else { mainAttriList.Add(attribute); } } } return(mainAttriList); }