public void Cast(object sender, ClickedEventArgs args) { if (fireball == null) { return; } fireball.Launch(); cooldownTimer = cooldown; fireball = null; GameObject.FindGameObjectWithTag("Player").GetComponent <Caster>().Vibrate(2000); }
private void Update() { if (fireball != null) { return; } if (charging && cooldownTimer <= 0) { intensity = Mathf.Clamp01(intensity + Time.deltaTime * chargeRate); if (intensity >= 1f) { fireball = Instantiate(fireballObj, transform).GetComponent <FireballObj>(); } } else { intensity = Mathf.Clamp01(intensity - Time.deltaTime * 1f / cooldown); cooldownTimer -= Time.deltaTime; } }