//----------------------------------------------------------------------------------------------------- // Reset current puzzle public void ResetPuzzle() { if (puzzle == null) { return; } Time.timeScale = 0; puzzle.ResetProgress(puzzle.name); remainingHints = hintLimit; timerTime = Time.time + timer; PlayerPrefs.SetInt(puzzle.name + "_hints", hintLimit); PlayerPrefs.SetFloat(puzzle.name + "_timer", timer); if (hintCounterUI) { hintCounterUI.gameObject.SetActive(remainingHints > 0); hintCounterUI.text = remainingHints.ToString(); } puzzle.DecomposePuzzle(); Time.timeScale = 1.0f; }
//----------------------------------------------------------------------------------------------------- // Prepare puzzle and Decompose it if needed public bool StartPuzzle(PuzzleController _puzzle) { if (!_puzzle) { _puzzle = gameObject.GetComponent <PuzzleController>(); } if (!_puzzle) { Debug.LogWarning("PuzzleController should be assigned to puzzle property of GameController - check " + gameObject.name); return(false); } if (puzzle && puzzle.gameObject != gameObject) { puzzle.gameObject.SetActive(false); } puzzle = _puzzle; puzzle.gameObject.SetActive(true); if (puzzle.pieces == null) { puzzle.Prepare(); } if (!PlayerPrefs.HasKey(puzzle.name + "_Positions") || !puzzle.enablePositionSaving) { if (!invertRules) { puzzle.DecomposePuzzle(); } else { puzzle.NonrandomPuzzle(); } } puzzle.invertedRules = invertRules; gameFinished = false; return(true); }