Пример #1
0
    //-----------------------------------------------------------------------------------------------------
    // 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);
    }