using cfg.FightCfg; using Gameplay.Vehicle.Impl; namespace Gameplay.Character { using Common; using Weapon; using UnityEngine; public class CharacterRuntimeData { public readonly Character owner; public bool isShooting = false; public bool isReloading = false; public bool isFullControl = false; public bool canMoveShoot { get { return fightData.moveShootType > 0; } } public bool canNotBreakShoot { get { return configData.breakShootType == 0 && !canMoveShoot; } } /// /// 所属的载具 /// public NormalVehicle belongVehicle; /// /// 是否处于被压制状态 /// public bool isInSuppressed { get { return moraleState == EMoraleType.Suppressed; } } /// /// 锁定士气状态变化 /// // public bool lockMoraleStateChange = false; public EMoraleType moraleState = EMoraleType.Normal; // 此项数据一旦录入,不可修改 public CharacterConfigData configData; public readonly WeaponRuntimeData weaponData; public readonly CharacterAliveData aliveData; public readonly CharacterFightData fightData; public CharacterLevelData characterLevelData; public CharacterRuntimeData(Character owner) { this.owner = owner; aliveData = new CharacterAliveData(owner); weaponData = new WeaponRuntimeData(); fightData = new CharacterFightData(owner); } public void Init() { // 优先初始化父类数据 _ResetAliveData(true); _ResetFightData(); _ResetWeaponData(); belongVehicle = null; } public void ResetToPrepare() { _ResetAliveData(false); _ResetFightData(); _ResetWeaponData(); belongVehicle = null; } private void _ResetWeaponData() { weaponData.remainBulletCount = owner.fightData.maxBulletCount; } private void _ResetAliveData(bool fillHp) { owner.aliveData.maxHp = configData.maxHp; owner.aliveData.maxShield = configData.maxShield; owner.aliveData.maxMorale = configData.initMorale; owner.aliveData.Init(fillHp); } private void _ResetFightData() { owner.fightData.specialAttakcLogicId = 0; owner.fightData.attack = configData.attack; owner.fightData.baseAttack = configData.attack; owner.fightData.scaleForHuman = configData.damagePepoleScale; owner.fightData.scaleForVehicle = configData.damageCarsScale; owner.fightData.normalAttackDistance = configData.shootDistance; owner.fightData.baseAttackDistance = configData.shootDistance; owner.fightData.moveSpeed = configData.moveSpeed; owner.fightData.baseMoveSpeed = configData.moveSpeed; owner.fightData.retreatSpeed = configData.retreatSpeed; owner.fightData.baseRetreatSpeed = configData.retreatSpeed; owner.fightData.turnSpeed = configData.turnSpeed; owner.fightData.shootCd = configData.shootCD; owner.fightData.p_shootCd = configData.shootCD; owner.fightData.p_shootCdScale = 0f; owner.fightData.maxBulletCount = configData.maxBulletCount; owner.fightData.baseMaxBulletCount = configData.maxBulletCount; owner.fightData.perShootBulletCount = configData.perShootCount; owner.fightData.criticalRate = configData.criticalRate; owner.fightData.criticalScale = configData.criticalScale; owner.fightData.firstShootTime = configData.firstShootTime; owner.fightData.p_firstShootTime = configData.firstShootTime; owner.fightData.moraleAttack = configData.moraleAttack; owner.fightData.reloadTime = configData.reloadTime; owner.fightData.baseReloadTime = configData.reloadTime; owner.fightData.findEnemyRange = configData.findEnemyRange; owner.fightData.autoRecoverHPDealy = configData.hpRecoverDelay; owner.fightData.autoRecoverHPValueFixed = configData.hpRecoverFix; owner.fightData.autoRecoverHPValuePercent = configData.hpRecoverPercent; owner.fightData.autoRecoverShiledDealy = configData.shiledRecoverDelay; owner.fightData.autoRecoverShiledValueFixed = configData.shieldRecoverFix; owner.fightData.autoRecoverShiledValuePercent = configData.shiledRecoverPercent; owner.fightData.overflowShiledMaxValue = configData.overflowShield; owner.fightData.attackScaleForShiled = configData.attackShiledScale; owner.fightData.attackScaleForHp = configData.attackHpScale; owner.fightData.isAttackIgnoreBlock = configData.isAttackIgnoreBlock; fightData.moraleRecover = configData.moraleRecover; fightData.moveShootType = configData.moveShootType; } public void LogicUpdate(float dt) { // 更新士气相关数据 aliveData.LogicUpdate(dt); _UpdateFrameProps(); } private void _UpdateFrameProps() { // defense { var baseValue = owner.runtimeData.configData.defense; var isInDefense = !owner.statusData.isMoveing && !owner.runtimeData.isInSuppressed; if (isInDefense) { baseValue = Mathf.CeilToInt(baseValue * owner.runtimeData.configData.defenseScale); } owner.fightData.defense = baseValue; } } } }