123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- using System.Collections;
- using System.Collections.Generic;
- using Core.Language;
- using Core.Utility;
- using Excel2Json;
- using Fort23.UTool;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Hero;
- using UnityEngine;
- using UnityEngine.Serialization;
- using Utility;
- [System.Serializable]
- public class CombatHeroInfo
- {
- public enum AttributeType
- {
- Hp,
- Att,
- Def,
- }
- public int modelID;
- public EncryptionLong hp = new EncryptionLong();
- public EncryptionLong defense = new EncryptionLong();
- public EncryptionLong attack = new EncryptionLong();
- /// <summary>
- /// 闪避 evasion
- /// </summary>
- public EncryptionInt shanbi = new EncryptionInt();
- /// <summary>
- /// 经验产出
- /// </summary>
- public EncryptionLong expGain = new EncryptionLong();
- public EncryptionFloat attSpeed = new EncryptionFloat();
- public EncryptionFloat crit = new EncryptionFloat();
- public EncryptionFloat critDamage = new EncryptionFloat();
- // public EncryptionFloat dodge = new EncryptionFloat();
- public EncryptionInt level;
- public EncryptionInt star;
- public HeroModelConfig modelConfig;
- public HeroPowerUpConfig powerUpConfig;
- public HeroPromoteConfig promoteConfig;
- public HeroBasicEquipConfig basicEquipConfig;
- /// <summary>
- /// 减少收到的暴击伤害
- /// </summary>
- public float reduceHitCritDamage;
- /// <summary>
- /// 减少收到的伤害
- /// </summary>
- public float reduceHitDamage;
- /// <summary>
- /// 技能暴击伤害
- /// </summary>
- public float skillCritDamage;
- /// <summary>
- /// 闪避 默认10%的几率
- /// </summary>
- public float dodge = 10;
- /// <summary>
- /// 1=英雄 2=小怪 3=精英怪 4=boss
- /// </summary>
- public int heroType;
- public string modelName;
- public float maxDis = 2;
- public float maxDisTo = 2 * 2;
- // public int[] skillId;
- // public List<SkillConfig> skillConfigs;
- /// <summary>
- /// 所有已解锁技能的ID
- /// </summary>
- public List<int> unLockSkills;
- public bool isGpu;
- public string heroName;
- public CombatHeroInfo()
- {
- }
- // public CombatHeroInfo(AccountFileInfo.HeroData heroData)
- // {
- // modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(heroData.heroModelId);
- // promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(heroData.heroPromoteId);
- // powerConfig = ConfigComponent.Instance.Get<HeroPowerConfig>(heroData.heroPowerId);
- // star = promoteConfig.starGrade;
- // lv = powerConfig.heroLevel;
- // }
- private float rarityFactor;
- private float starFactor;
- private float factor;
- protected Map<AttributeType, int> _AttributeCacheValue = new Map<AttributeType, int>();
- /// <summary>
- /// 计算影响基础属性的参数
- /// (稀有度、星级)
- /// </summary>
- protected void CalFactor()
- {
- rarityFactor = PlayerManager.Instance.gameConstantConfig.monsterRarityAttributeFactor[modelConfig.rarity - 1]
- / 100f;
- starFactor = promoteConfig.star_Power / 100f;
- factor = rarityFactor * starFactor;
- }
- public void AddAttributeValueToCache(AttributeType attributeType, int value)
- {
- if (_AttributeCacheValue.TryGetValue(attributeType, out int v))
- {
- value += v;
- }
- _AttributeCacheValue[attributeType] = value;
- }
- protected void CalBasicAttribute()
- {
- _AttributeCacheValue.Clear();
- hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor * factor);
- defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor * factor);
- attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor * factor);
- shanbi = (EncryptionInt)(modelConfig.shanbi * powerUpConfig.SHANBIFactor * factor);
- expGain = (EncryptionLong)(modelConfig.expGain * powerUpConfig.EXPFactor * factor);
- CalUnLockSkill();
- for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
- {
- switch (_AttributeCacheValue.Key)
- {
- case AttributeType.Hp:
- hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
- break;
- case AttributeType.Att:
- attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
- _AttributeCacheValue.Value);
- break;
- case AttributeType.Def:
- defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
- _AttributeCacheValue.Value);
- break;
- }
- }
- }
- public SkillConfig GetGroupSkillConfig(int idGroup)
- {
- if (unLockSkills == null)
- {
- return default;
- }
- for (int i = 0; i < unLockSkills.Count; i++)
- {
- SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
- if (skillConfig.IDGroup == idGroup)
- {
- return skillConfig;
- }
- }
- return default;
- }
- protected void CalAttribute()
- {
- CalBasicAttribute();
- attSpeed = (EncryptionFloat)modelConfig.speed_atk;
- crit = (EncryptionFloat)modelConfig.crit;
- // skillId = modelConfig.skillID;
- modelName = modelConfig.model;
- isGpu = modelConfig.isUseGpu;
- maxDis = modelConfig.range_atk;
- maxDisTo = maxDis * maxDis;
- heroType = modelConfig.heroType;
- }
- /// <summary>
- /// 计算解锁技能
- /// </summary>
- public void CalUnLockSkill()
- {
- unLockSkills = new List<int>();
- for (int i = 0; i < modelConfig.skillID.Length; i++)
- {
- SkillConfig skillConfig =
- PlayerManager.Instance.heroController.GetHighestLevelOr1(modelConfig.skillID[i], level.Value,
- star.Value, true);
- if (skillConfig.ID > 0)
- {
- unLockSkills.Add(skillConfig.ID);
- AddSkillAttribute(skillConfig);
- }
- }
- }
- protected void AddSkillAttribute(SkillConfig skillConfig)
- {
- if (skillConfig.addPropertyType == null)
- {
- return;
- }
- for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
- {
- int propertyType = skillConfig.addPropertyType[i];
- int value = skillConfig.addPropertyValue[i];
- switch (propertyType)
- {
- case 1:
- AddAttributeValueToCache(AttributeType.Hp, value);
- break;
- case 2:
- AddAttributeValueToCache(AttributeType.Att, value);
- break;
- case 3:
- AddAttributeValueToCache(AttributeType.Def, value);
- break;
- }
- }
- }
- protected void SetDataConfig(int modelID, int level, int star)
- {
- modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
- powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
- promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
- this.level = (EncryptionInt)level;
- this.star = (EncryptionInt)star;
- heroName = LanguageManager.Instance.Text(modelConfig.name);
- }
- public void InitMonster(int modelID, int level, int star = 1)
- {
- SetDataConfig(modelID, level, star);
- CalFactor();
- CalAttribute();
- // SkillData = new SkillData(this);
- // SkillData.InitSkills();
- }
- // public void InitMonster(int id,int level)
- // {
- // HeroModelConfig heroModelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(id);
- // HeroPowerUpConfig heroPowerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
- // hp = (EncryptionLong)(heroModelConfig.hp*heroPowerUpConfig.HPFactor);
- // defense=(EncryptionLong)(heroModelConfig.def*heroPowerUpConfig.DEFFactor);
- // attack=(EncryptionLong)(heroModelConfig.attack*heroPowerUpConfig.ATKFactor);
- // attSpeed=(EncryptionFloat)heroModelConfig.speed_atk;
- // crit=(EncryptionFloat)heroModelConfig.crit;
- // skillId = heroModelConfig.skillID;
- // modelName = heroModelConfig.model;
- // isGpu = heroModelConfig.isUseGpu;
- // maxDis=heroModelConfig.range_atk;
- // maxDisTo = maxDis * maxDis;
- // }
- public CombatHeroInfo Copy()
- {
- CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
- return combatHeroInfo;
- }
- }
|