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); } } }
void OnGUI() { if (target != null) //if not dead { text.text = "Health: " + target.GetHealth() + "\n"; text.text += "Mana: " + target.GetMana(); } else //if dead //try and find the player { FetchPlayer(); text.text = "Health: Dead\n"; text.text += "Mana: Dead"; } }