Exemplo n.º 1
0
    public void TakeDamage(int damageTaken, GameObject objectThatDeltDamage)
    {
        if (this.m_Invulnerable)
        {
            return;
        }

        this.m_CurrentHealth -= damageTaken;
        if (this.m_CurrentHealth <= 0)
        {
            this.Die();
            this.StopCoroutine(Invulnerable());
            return;
        }

        //TODO make impact dynamic but also clamped
        if (objectThatDeltDamage.transform.position.x > transform.position.x)
        {
            m_PlayerMovement.AddToHorizontalMovement(-20f);
        }
        else
        {
            m_PlayerMovement.AddToHorizontalMovement(20f);
        }

        StartCoroutine(Invulnerable());
        this.UpdateHealthUI();
    }