コード例 #1
0
ファイル: SaveSystem.cs プロジェクト: Chaos-And-Art/2048-Game
    public static void ExitGameSave3x3(GameManager3x3 gameManager3x3)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/Exit3x3.data";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ExitData3x3 data = new ExitData3x3(gameManager3x3);

        formatter.Serialize(stream, data);
        stream.Close();
    }
コード例 #2
0
ファイル: SaveSystem.cs プロジェクト: Chaos-And-Art/2048-Game
    public static ExitData3x3 ExitGameLoad3x3()
    {
        string path = Application.persistentDataPath + "/Exit3x3.data";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            ExitData3x3 data = formatter.Deserialize(stream) as ExitData3x3;
            stream.Close();
            return(data);
        }
        else
        {
            Debug.Log("Save File Cannot be found in " + path);
            return(null);
        }
    }
コード例 #3
0
    public void ExitLoad(int index)
    {
        ExitData3x3 data = SavingSystem.ExitGameLoad3x3();
        string      Tile = "Tiles";

        if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTimeL") == 1)
        {
            foreach (Transform tile in PlayGrid)
            {
                Destroy(tile.gameObject);
            }
        }
        else if (PlayerPrefs.GetInt("Theme") == 1)
        {
            foreach (Transform tile in PlayGrid)
            {
                Destroy(tile.gameObject);
            }
        }
        for (i = 0; i < data.exitX.Count; i++)
        {
            x          = data.exitX[index];
            y          = data.exitY[index];
            Grid[x, y] = (GameObject)Instantiate(Resources.Load(Tile), new Vector2(.18f + (1.48f * data.exitX[index]), .18f + (1.48f * data.exitY[index])), Quaternion.identity);
            if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTimeL") == 1)
            {
                Grid[x, y].transform.SetParent(PlayGrid);
            }
            else if (PlayerPrefs.GetInt("Theme") == 1)
            {
                Grid[x, y].transform.SetParent(PlayGrid);
            }
            Grid[x, y].GetComponent <Tiles>().Number = data.exitTileNumber[index];
            index++;
        }
        theScore = data.exitScore;
    }