diff --git a/Assets/Modules/BattleSimulator/Scripts/Combat/Component/Systems/Weapons/ContinuousCannon.cs b/Assets/Modules/BattleSimulator/Scripts/Combat/Component/Systems/Weapons/ContinuousCannon.cs index 069ab382..494705e4 100644 --- a/Assets/Modules/BattleSimulator/Scripts/Combat/Component/Systems/Weapons/ContinuousCannon.cs +++ b/Assets/Modules/BattleSimulator/Scripts/Combat/Component/Systems/Weapons/ContinuousCannon.cs @@ -17,20 +17,21 @@ public ContinuousCannon(IWeaponPlatform platform, WeaponStats weaponStats, Facto _bulletFactory = bulletFactory; _platform = platform; _energyConsumption = bulletFactory.Stats.EnergyCost; + _activationCost = bulletFactory.Stats.ActivationCost; _spread = weaponStats.Spread; Info = new WeaponInfo(WeaponType.Continuous, _spread, bulletFactory, platform); } - public override bool CanBeActivated { get { return base.CanBeActivated && (HasActiveBullet || _platform.IsReady && _platform.EnergyPoints.Value > _energyConsumption * 0.5f); } } - public override float Cooldown { get { return Mathf.Max(base.Cooldown, _platform.Cooldown); } } + public override bool CanBeActivated => base.CanBeActivated && (HasActiveBullet || _platform.IsReady); + public override float Cooldown => Mathf.Max(base.Cooldown, _platform.Cooldown); - public WeaponInfo Info { get; private set; } - public IWeaponPlatform Platform { get { return _platform; } } - public float PowerLevel { get { return 1.0f; } } - public IBullet ActiveBullet { get { return HasActiveBullet ? _activeBullet : null; } } + public WeaponInfo Info { get; private set; } + public IWeaponPlatform Platform { get { return _platform; } } + public float PowerLevel { get { return 1.0f; } } + public IBullet ActiveBullet { get { return HasActiveBullet ? _activeBullet : null; } } - protected override void OnUpdateView(float elapsedTime) {} + protected override void OnUpdateView(float elapsedTime) {} protected override void OnUpdatePhysics(float elapsedTime) { @@ -49,7 +50,7 @@ protected override void OnUpdatePhysics(float elapsedTime) InvokeTriggers(ConditionType.OnDeactivate); } } - else if (Active && CanBeActivated) + else if (Active && CanBeActivated && _platform.EnergyPoints.TryGet(_activationCost)) { Shot(); InvokeTriggers(ConditionType.OnActivate); @@ -66,11 +67,12 @@ private void Shot() _activeBullet.Lifetime.Restore(); } - private bool HasActiveBullet { get { return _activeBullet.IsActive(); } } + private bool HasActiveBullet { get { return _activeBullet.IsActive(); } } - private IBullet _activeBullet; + private IBullet _activeBullet; private readonly float _spread; private readonly float _energyConsumption; + private readonly float _activationCost; private readonly IWeaponPlatform _platform; private readonly Factory.IBulletFactory _bulletFactory; } diff --git a/Assets/Modules/BattleSimulator/Scripts/Combat/Factory/Bullets/BulletStats.cs b/Assets/Modules/BattleSimulator/Scripts/Combat/Factory/Bullets/BulletStats.cs index e242ff13..0d38180f 100644 --- a/Assets/Modules/BattleSimulator/Scripts/Combat/Factory/Bullets/BulletStats.cs +++ b/Assets/Modules/BattleSimulator/Scripts/Combat/Factory/Bullets/BulletStats.cs @@ -15,8 +15,9 @@ public interface IBulletStats Color FlashColor { get; } float FlashTime { get; } - float EnergyCost { get; } - float BulletSpeed { get; } + float EnergyCost { get; } + float ActivationCost { get; } + float BulletSpeed { get; } float BulletHitRange { get; } float Recoil { get; } bool IgnoresShipSpeed { get; } @@ -81,9 +82,10 @@ public Component.Systems.Weapons.BulletEffectType EffectType public float BulletHitRange { get { return _ammunition.Body.Type == BulletType.Continuous ? Range : Range + BodySize; } } public float BulletSpeed { get { return _ammunition.Body.Velocity * _statModifier.VelocityMultiplier.Value; } } public float EnergyCost { get { return _ammunition.Body.EnergyCost * _statModifier.EnergyCostMultiplier.Value; } } - public bool IgnoresShipSpeed { get { return _ammunition.Body.Type == BulletType.Static; } } + public bool IgnoresShipSpeed { get { return _ammunition.Body.Type == BulletType.Static; } } + public float ActivationCost => _ammunition.Body.Type == BulletType.Continuous ? EnergyCost * _ammunition.Body.Lifetime : EnergyCost; - public float Recoil + public float Recoil { get { @@ -183,10 +185,11 @@ public BulletStatsObsolete(AmmunitionObsoleteStats ammunition) public float Recoil { get { return _stats.Recoil * SizeMultiplier; } } public float AreaOfEffect { get { return _stats.AreaOfEffect * SizeMultiplier; } } public float Velocity { get { return _stats.Velocity; } } - public float EnergyCost { get { return _stats.EnergyCost; } } - public bool IgnoresShipSpeed { get { return _stats.IgnoresShipVelocity; } } + public float EnergyCost { get { return _stats.EnergyCost; } } + public bool IgnoresShipSpeed { get { return _stats.IgnoresShipVelocity; } } + public float ActivationCost => _stats.AmmunitionClass.IsBeam() ? EnergyCost * _stats.LifeTime : EnergyCost; - public float BulletSpeed { get { return Velocity; } } + public float BulletSpeed { get { return Velocity; } } public float BulletHitRange { get { return Mathf.Max(Range, AreaOfEffect); } } private float RangeMultiplier { get { return PowerLevel > 0.1f ? PowerLevel : 0f; } }