Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //Debug.Log("colliding! - " + collision.transform);
        BugController bc = collision.transform.gameObject.GetComponent <BugController>();

        if (bc != null)
        {
            bc.KillMeWithoutAni();
        }
        else if (collision.gameObject.name == "butterfly_000")
        {
            Debug.Log("Eating Butterfly, Yum!");

            GameManager.gameManager.CoinsFeedback(collision.transform.position, 50);
            PowerUpManager.isPowerUpOnScene = false;
            CoccoonController.coccoonController.HideButterfly();

            // check goals
            foreach (Goal goal in PlayerController.player.level.goals.Values)
            {
                goal.checkEatButterfly();
            }
        }
        else if (collision.gameObject.name == "x2")
        {
            Debug.Log("Eating some x2, Yum!");
            PlayerController.player.BJamountSession *= 2;
            UIController.uIController.animateBJ();

            X2Controller.x2Controller.HideX2();

            // check goals
            foreach (Goal goal in PlayerController.player.level.goals.Values)
            {
                goal.checkEatX2();
            }
        }
        else
        {
            return;
        }

        if (_state.Equals(_State.ATTACK) || _state.Equals(_State.RETREAT))
        {
            _state = _State.ATTACK_BITE;
        }

        if (_state.Equals(_State.IDLE))
        {
            _state = _State.IDLE_BITE;
        }

        StopAllCoroutines();
        StartCoroutine(Bite());
    }