Exemple #1
0
    void ButtonPushed(EButton.ColorType color)
    {
        if (clickCount >= 3)
        {
            return;
        }

        clickCount++;

        if (phase == Phase.FIRST)
        {
            Piston piston = firstPistons[clickCount - 1];
            if (piston)
            {
                piston.color = color;
            }


            if (firstCombination[clickCount - 1] != color)
            {
                first_failed = true;
            }

            if (clickCount >= 3)
            {
                resetDelay.Start();
                if (!first_failed)
                {
                    OnFirstPhase.Invoke();
                }
            }
        }
        else if (phase == Phase.SECOND)
        {
            Piston piston = secondPistons[clickCount - 1];
            if (piston)
            {
                piston.color = color;
            }


            if (secondCombination[clickCount - 1] != color)
            {
                second_failed = true;
            }

            if (clickCount >= 3)
            {
                resetDelay.Start();
                if (!second_failed)
                {
                    OnSecondPhase.Invoke();
                }
            }
        }
    }
Exemple #2
0
    void Reset(Phase nextPhase)
    {
        EButton.ColorType resetColor = EButton.ColorType.White;

        if (phase == Phase.FIRST)
        {
            for (int i = 0; i < 3; i++)
            {
                firstPistons[i].color = first_failed ? resetColor : success_color;
            }

            if (!first_failed)
            {
                phase = nextPhase;
            }
            else
            {
                first_failed = false;
            }
        }
        else if (phase == Phase.SECOND)
        {
            for (int i = 0; i < 3; i++)
            {
                secondPistons[i].color = second_failed ? resetColor : success_color;
            }

            if (!second_failed)
            {
                phase = nextPhase;
            }
            else
            {
                second_failed = false;
            }
        }
        clickCount = 0;
    }