Example #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        HeroRabbit rabbit = collider.GetComponent <HeroRabbit>();

        if (rabbit != null)
        {
            if (rabbit.isBig)
            {
                rabbit.DecreaseRabbitSize();
            }
            LevelController.current.onRabitDeath(rabbit);
        }
    }
Example #2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        HeroRabbit rabbit = collider.GetComponent <HeroRabbit>();

        if (rabbit.invulnerableTime <= 0)
        {
            if (rabbit.isBig)
            {
                rabbit.DecreaseRabbitSize();
                rabbit.invulnerableTime = 4;
            }
            else
            {
                rabbit.isAlive = false;
            }
        }
    }
Example #3
0
    protected override void OnRabbitHit(HeroRabbit rabbit)
    {
        if (rabbit.invulnerableTime <= 0)
        {
            if (rabbit.isBig)
            {
                rabbit.DecreaseRabbitSize();
                rabbit.invulnerableTime = 4;
            }
            else
            {
                rabbit.isAlive = false;
            }

            this.CollectedHide();
        }
    }
Example #4
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        HeroRabbit rabbit = collider.GetComponent <HeroRabbit>();

        if (rabbit != null)
        {
            // angle check
            Vector3 dir = collider.transform.position - transform.position;
            dir = collider.transform.InverseTransformDirection(dir);
            float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;

            if (angle < 60 || angle > 120)
            {
                if (rabbit.invulnerableTime <= 0)
                {
                    if (rabbit.isBig)
                    {
                        animator.SetTrigger("attack");
                        rabbit.DecreaseRabbitSize();
                        rabbit.invulnerableTime = 4;
                    }
                    else
                    {
                        animator.SetTrigger("attack");
                        rabbit.isAlive = false;
                    }
                }
            }
            else
            {
                // orc dies
                animator.SetTrigger("die");
                isAlive = false;
                rabbit.TossRabbitUp();
                StartCoroutine(dieLater());
            }
        }
    }