Beispiel #1
0
    public static void OrignSave1(GameManagerOrign gameManagerOrign)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/Orign1.data";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        OrignSave1 data = new OrignSave1(gameManagerOrign);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Beispiel #2
0
    public static OrignSave1 OrignLoad1()
    {
        string path = Application.persistentDataPath + "/Orign1.data";

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

            OrignSave1 data = formatter.Deserialize(stream) as OrignSave1;
            stream.Close();
            return(data);
        }
        else
        {
            Debug.Log("Save File Cannot be found in " + path);
            return(null);
        }
    }
Beispiel #3
0
    public void LoadGame1(int index)
    {
        OrignSave1 data = SavingSystem.OrignLoad1();
        string     Tile = "Tiles";

        if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTimeO") == 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.posX1.Count; i++)
        {
            x = data.posX1[index];
            y = data.posY1[index];

            Grid[x, y] = (GameObject)Instantiate(Resources.Load(Tile), new Vector2(data.posX1[index] * 1.1f, data.posY1[index] * 1.1f), Quaternion.identity);
            if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTimeO") == 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.tileNumber1[index];
            index++;
        }
        theScore = data.score1;
    }