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);
            }
        }
    }
Ejemplo n.º 2
0
    // 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);
            }
        }
    }
Ejemplo n.º 3
0
    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);
                }
            }
        }
    }
Ejemplo n.º 4
0
 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
 }