Ejemplo n.º 1
0
    // Checks for the completion of the puzzle
    public void CheckCompletion()
    {
        bool correctCheck = true;

        //Loop through all the pieces
        for (int i = 0; i < pieces.Length; i++)
        {
            //Check that the piece is placed
            if (!pieces[i].isPlaced)
            {
                //If not placed exit the check
                return;
            }

            //Check if the piece is in the right place
            correctCheck = correctCheck && pieces[i].CheckCorrect();
        }
        print(correctCheck);

        //If they are all correct call a puzzle competion event
        if (correctCheck)
        {
            if (OnCompletion != null)
            {
                OnCompletion();
                //Load the back menu
                backMenu.LoadBackMenu();
                //Stop timer
                timer.ToggleActive(false);
                //Save the timer
                //For next puzzle use
                StaticClass.Timer = timer.GetElapsed();
                //for write use
                SavePuzzleTime();
                StaticClass.puzzleProgression++;
            }
        }
        //If not correct send pieces to original position
        else
        {
            if (OnFailure != null)
            {
                OnFailure();
            }
        }
    }
Ejemplo n.º 2
0
 //Start timer
 public void StartTimer()
 {
     timer.ToggleActive(true);
 }