Esempio n. 1
0
    public IEnumerator PerformAbility(string ability)
    {
        if (!m_energyManager.TryUseAbility(ability))
        {
            Debug.Log("Not enough energy!");
        }
        else
        {
            Debug.Log("performing ability");
            if (ability == "throw")
            {
                abilityAnimator.SetInteger("state", 1);
                yield return(new WaitForSeconds(0.25f));

                GameObject proj = Instantiate <GameObject>(m_basicProjectileAbility,
                                                           new Vector3(this.transform.position.x + 1.7f * m_direction, -3.3f, 0), Quaternion.identity);
                proj.GetComponent <Projectile>().m_direction = this.m_direction;
                proj.GetComponent <Projectile>().owner       = this.m_playerNumber;
            }
            else if (ability == "flick")
            {
                abilityAnimator.SetInteger("state", 1);
                yield return(new WaitForSeconds(0.25f));

                GameObject proj = Instantiate <GameObject>(m_superProjectileAbility,
                                                           new Vector3(this.transform.position.x + 1.7f * m_direction, -2.7f, 0), Quaternion.identity);
                proj.GetComponent <Projectile>().m_direction = this.m_direction;
                proj.GetComponent <Projectile>().owner       = this.m_playerNumber;
            }
            else if (ability == "shield")
            {
                m_shieldAbility.SetActive(true);
                StartCoroutine(m_shieldAbility.GetComponent <Shield>().ActivateShield());
                yield return(new WaitForSeconds(3f));

                StartCoroutine(m_shieldAbility.GetComponent <Shield>().DeactivateShield());
                yield return(new WaitForSeconds(1f));

                m_shieldAbility.SetActive(false);
            }
            yield return(null);
        }
    }