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);
    }
    public static SwapPuzzleData LoadSwapPuzzle()
    {
        if (File.Exists(swapPuzzleSavePath))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(swapPuzzleSavePath, FileMode.Open);

            SwapPuzzleData data = formatter.Deserialize(stream) as SwapPuzzleData;
            stream.Close();
            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in" + swapPuzzleSavePath);
            return(null);
        }
    }
    public void LoadSwapPuzzle(SwapPuzzleData data)
    {
        SetCellsParentSprite();

        if (data.GetIsRotateEnable().Equals(true))
        {
            invertedCellCount = data.GetInvertedCount();
        }
        else
        {
            invertedCellCount = 0;
        }

        shiftedCellCount = data.GetShiftedCount();

        BuildCells(true, data.GetRandomPozitions(), data.GetRotations());

        SetSwapCellsAdjacents();

        selectedCell = cells[data.GetIndexOfSelectedPuzzle()];
        selectedCell.GetComponent <SwapCell>().SetPuzzlePieceGlow(true);
    }