Example #1
0
    public void SpendDetrizide()
    {
        if (!GetComponent <Unit>().IsDead())
        {
            if (healavailable)
            {
                lefthandanim.SetTrigger("Heal");

                Debug.Log("healthcost = " + healthcost);

                unit.SetHealth(unit.GetMaxHealth());
                statl.SetDetrizide(statl.GetDetrizide() - healthcost);
                aso.PlayOneShot(sl.GetDetriHeal());
                detrilight.CreateSpellEffect("Heal", spelleffect, spellpos);
            }
            else if (summonavailable)
            {
                lefthandanim.SetTrigger("Summon");
                aso.PlayOneShot(sl.GetDetriRes());
                detrilight.CreateSpellEffect("Summon", spelleffect, spellpos);

                for (int i = 0; i < altar.GetResMax(); i++)
                {
                    if (statl.GetDetrizide() > rescost && CountFriends("Friendlies") < altar.GetResMax())
                    {
                        Debug.Log("rescost = " + rescost);
                        statl.SetDetrizide(statl.GetDetrizide() - rescost);
                        altar.ResurrectUnit();
                    }
                }
            }
            else if (bankavailable)
            {
                lefthandanim.SetTrigger("Bank");
                statl.SetDetrizideBank(statl.GetDetrizideBank() + (fastmode? statl.GetDetrizide() * 4 : statl.GetDetrizide()));
                statl.SetDetrizide(0);
                aso.PlayOneShot(sl.GetDetriBank());
                detrilight.CreateSpellEffect("Bank", spelleffect, spellpos);
                GameObject tracer = Instantiate(spendtracer, transform.position, transform.rotation);
                tracer.GetComponent <HomingProjectile>().SetDefaultTarget(wb.transform);
            }
        }
    }