Example #1
0
    void Update()
    {
        Color colorBox1 = puzzleController.SelectionBox1.GetComponent <Renderer>().material.color;
        Color colorBox2 = puzzleController.SelectionBox2.GetComponent <Renderer>().material.color;

        if (puzzleSolutionColor.Equals(Orange))
        {
            if ((colorBox1.Equals(Color.red) && colorBox2.Equals(Color.yellow)) ||
                (colorBox1.Equals(Color.yellow) && colorBox2.Equals(Color.red)))
            {
                puzzleSolved = true;
            }
        }

        else if (puzzleSolutionColor.Equals(Purple))
        {
            if ((colorBox1.Equals(Color.red) && colorBox2.Equals(Color.blue)) ||
                (colorBox1.Equals(Color.blue) && colorBox2.Equals(Color.red)))
            {
                puzzleSolved = true;
            }
        }

        else if (puzzleSolutionColor.Equals(Color.green))
        {
            if ((colorBox1.Equals(Color.yellow) && colorBox2.Equals(Color.blue)) ||
                (colorBox1.Equals(Color.blue) && colorBox2.Equals(Color.yellow)))
            {
                puzzleSolved = true;
            }
        }

        if (puzzleSolved)
        {
            // TODO: Ensure that puzzle was solved
            clean();
            Terminal.GetComponent <Renderer>().enabled = false;
            colorsPuzzleActivator.activate();
        }
        else if (!colorBox1.Equals(puzzleController.getDefaultColor()) &&
                 !colorBox2.Equals(puzzleController.getDefaultColor()))
        {
            restartPuzzle();
            puzzleController.setCurrentBox(puzzleController.SelectionBox1);
        }
    }
Example #2
0
 void FixedUpdate()
 {
     if (IsActive)
     {
         updateSphereColor();
         if (puzzleSolved)
         {
             ColorPanel.GetComponent <Renderer>().enabled = false;
             HeroUtil.ChangeHero();
             colorsPuzzleActivator.activate();
         }
         if (puzzleFail)
         {
             restartPuzzle();
             puzzleController.setCurrentBox(puzzleController.SelectionBox1);
             puzzleFail = false;
         }
     }
 }