public static void SaveSwapPuzzle(SwapPuzzle swapPuzzle)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      stream    = new FileStream(swapPuzzleSavePath, FileMode.Create);

        SwapPuzzleData data = new SwapPuzzleData(swapPuzzle);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Example #2
0
    private void LoadPuzzle()
    {
        SwapPuzzleData data = SaveSystem.LoadSwapPuzzle();

        pieceCount      = data.GetPieceCount();
        paintingIndex   = data.GetPaintIndex();
        isRotateEnabled = data.GetIsRotateEnable();
        complexity      = data.GetComplexityFactor();
        swapPuzzle      = new SwapPuzzle(complexity, isRotateEnabled, paintingIndex, pieceCount, cellsParent, glowShader);
        swapPuzzle.LoadSwapPuzzle(data);
    }
Example #3
0
    private void BuildPuzzle()
    {
        pieceCount = MainMenuManager.pieceCount;

        paintingIndex = MainMenuManager.paintIndex;

        isRotateEnabled = MainMenuManager.isRotateOn;
        complexity      = MainMenuManager.complexityFactor;
        swapPuzzle      = new SwapPuzzle(complexity, isRotateEnabled, paintingIndex, pieceCount, cellsParent, glowShader);
        swapPuzzle.BuildSwapPuzzle();
    }
Example #4
0
    public SwapPuzzleData(SwapPuzzle swapPuzzle)
    {
        invertedCount  = SwapPuzzle.invertedCellCount;
        shiftedCount   = SwapPuzzle.shiftedCellCount;
        isRotateEnable = SwapPuzzle.isRotateEnabled;

        paintIndex = swapPuzzle.GetPaintingIndex();
        pieceCount = swapPuzzle.GetPieceCount();

        GameObject[] cells = swapPuzzle.GetCells();
        randomPozitions  = new float[cells.Length, 2];
        truePozitions    = new float[cells.Length, 2];
        rotations        = new float[cells.Length];
        complexityFactor = swapPuzzle.GetComplexityFactor();

        for (int i = 0; i < cells.Length; i++)
        {
            GameObject cell = cells[i];

            float positionX = cell.GetComponent <RectTransform>().anchoredPosition.x;
            float positionY = cell.GetComponent <RectTransform>().anchoredPosition.y;

            randomPozitions[i, 0] = positionX;
            randomPozitions[i, 1] = positionY;

            float truePositionY = cell.GetComponent <SwapCell>().GetTruePosition().y;
            float truePositionX = cell.GetComponent <SwapCell>().GetTruePosition().x;

            truePozitions[i, 0] = truePositionX;
            truePozitions[i, 1] = truePositionY;

            rotations[i] = cell.transform.rotation.z;

            if (cell.GetComponent <RectTransform>().anchoredPosition.Equals(
                    SwapPuzzle.selectedCell.GetComponent <RectTransform>().anchoredPosition))
            {
                indexOfSelectedPuzzle = i;
            }
        }
    }