diff options
| author | chai <215380520@qq.com> | 2023-11-02 11:51:31 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2023-11-02 11:51:31 +0800 |
| commit | 7f493f682503f5186308de7b8f74b5b49233cfe4 (patch) | |
| tree | 8a91e2056bc79788ee4735dce88b8d516ba12beb /GameCode/HealBoostMA.cs | |
+init
Diffstat (limited to 'GameCode/HealBoostMA.cs')
| -rw-r--r-- | GameCode/HealBoostMA.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/GameCode/HealBoostMA.cs b/GameCode/HealBoostMA.cs new file mode 100644 index 0000000..48cdbbb --- /dev/null +++ b/GameCode/HealBoostMA.cs @@ -0,0 +1,55 @@ +using UnityEngine; + +public class HealBoostMA : ManualAttack +{ + public float attackSpeedBoost = 20f; + + public ManualAttack manualAttackToBoost; + + public ParticleSystem boostParticles; + + public float attackSpeedDuration = 2f; + + public float timeToFillUpHealth = 3f; + + public float attackSpeedDurationWhenLowHealth = 4f; + + private float disableBoostIn; + + private float attackSpeedOriginal; + + public override void Start() + { + base.Start(); + } + + public override void Attack() + { + attackSpeedOriginal = manualAttackToBoost.cooldownTime; + manualAttackToBoost.cooldownTime /= attackSpeedBoost; + ParticleSystem.EmissionModule emission = boostParticles.emission; + emission.enabled = true; + disableBoostIn = attackSpeedDuration; + if (hpPlayer.HpPercentage <= 0.33f) + { + disableBoostIn = attackSpeedDurationWhenLowHealth; + } + } + + public override void Update() + { + base.Update(); + disableBoostIn -= Time.deltaTime; + if (disableBoostIn > 0f) + { + hpPlayer.Heal(hpPlayer.maxHp * Time.deltaTime / timeToFillUpHealth); + cooldown = cooldownTime; + } + if (disableBoostIn + Time.deltaTime > 0f && disableBoostIn <= Time.deltaTime) + { + manualAttackToBoost.cooldownTime = attackSpeedOriginal; + ParticleSystem.EmissionModule emission = boostParticles.emission; + emission.enabled = false; + } + } +} |
