Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (isFound || doorController == null)
        {
            return;
        }

        if (collision.gameObject.tag == "Player")
        {
            ColorController colorControllerTemp = collision.gameObject.GetComponent <ColorController>();
            if (colorControllerTemp.CountListColor() > 0 && colorControllerTemp.listColor[0] == colorController.listColor[0])
            {
                colorControllerTemp.ShowNextColor();
            }
            else
            {
                colorControllerTemp.listColor = colorController.listColor;
                colorControllerTemp.SetColorLevel(colorController.getCurrentColorLevel());
                colorControllerTemp.UpdateSpriteColor();
            }

            SetIsFound(true);
            MaxColorLevel();
            doorController.AskOpen();
            audioController.PlayAudio(soundInteract);
        }
    }