public void Reset()
    {
        // reset all important variables
        initialLog                = true;
        gameHasBegun              = false;
        isBombAudioPlaying        = false;
        myHighestScoringWord      = "";
        myHighestScoringWordScore = 0;
        myRarestWord              = "";
        myRarestWordRarity        = 0;
        myHighScoreUpdated        = false;
        counter = 5;

        GameObject boxes = GameObject.Find("SpawnBoxes");

        foreach (Transform child in boxes.transform)
        {
            child.gameObject.GetComponent <SpawnBoxScript>().Reset();
        }

        // reset all important BoxScript variables
        BoxScript.Reset();
        ResetTimer();

        UpdatePlayButton();

        gameOverPanel.SetActive(false);

        int scene = SceneManager.GetActiveScene().buildIndex;

        SceneManager.LoadScene(scene); // eventually delete the key "currentPath"
                                       // PlayerPrefs.DeleteKey("currentPath");
    }
Example #2
0
 public void LoadGameState()
 {
     ResetGame();
     if (PlayerPrefs.HasKey("Board"))
     {
         string prefString = PlayerPrefs.GetString("Board");
         board = StringToIntList(prefString).ToArray();
         for (int i = 0; i < actualBoard.Length; i++)
         {
             BoxScript boardControl = actualBoard[i].GetComponent <BoxScript>();
             if (board[i] == -1)
             {
                 boardControl.TouchBox();
                 moveCount++;
             }
             else if (board[i] == 1)
             {
                 boardControl.ComputerTouch();
             }
             else
             {
                 boardControl.Reset();
             }
         }
     }
     else
     {
         print("No board to load!");
     }
 }