private void CastWithCost(GameObject caster, GameObject spell, bool movesWithCaster) { StatsHandler casterStats = caster.GetComponent <StatsHandler>(); //check for cooldown if (Time.time >= nextCast) { nextCast = Time.time + cooldownTime;//set nup next time for next cast //check if caster has enough mana and cast if they do, cast the spell if (casterStats.GetMana() >= manaCost) { //remove mana then cast casterStats.ChangeMana(-manaCost); InstatiateSpell(caster, spell, movesWithCaster); } else if (isBoodmagic && casterStats.GetHealth() + casterStats.GetMana() >= manaCost) { //remove mana and health then cast casterStats.ChangeHealth(-(manaCost - casterStats.GetMana()));//minus the extra needed casterStats.ChangeMana(-casterStats.GetMana()); InstatiateSpell(caster, spell, movesWithCaster); } } }
// Update is called once per frame void Update() { foreach (GameObject target in myTargeter.GetTargets()) { StatsHandler targetStats = target.GetComponent <StatsHandler>(); if (targetStats != null) { targetStats.ChangeHealth(hps * Time.deltaTime); } } }
void Update() //called when the component is disabled or set to be destroyed //Get all targets { List <GameObject> targets = targeter.GetTargets(); foreach (GameObject target in targets) { if (target != null) //if target exists //if target has stats, apply damage { StatsHandler targetStats = target.GetComponent <StatsHandler>(); if (targetStats != null) { targetStats.ChangeHealth(-damagePerSec * Time.deltaTime); } } } }
public void Damage(float damageAmount) { statsHandlerRef.ChangeHealth(-damageAmount); }
// Update is called once per frame protected virtual void Update() { stats.ChangeHealth(-1 * stacks * Time.deltaTime);//generic effect }