Exemplo n.º 1
0
    void Start()
    {
        string   path       = Application.streamingAssetsPath + "/AppleLogs.json"; // path to apple
        string   jsonString = File.ReadAllText(path);                              // read all text from json file
        gameData data       = JsonUtility.FromJson <gameData>(jsonString);         // store the json data into a gamedata variable

        Applelogs.Clear();
        if (!(data == null))                          // as long as there is more data
        {
            foreach (GameLog log in data.ApplePicker) // for each log in the data
            {
                Applelogs.Add(log);                   // add the log to Applelogs
            }
        }

        // This of these code segment are very similar for every game^^

        string      RPSpath       = Application.streamingAssetsPath + "/RPSLogs.json";
        string      RPSjsonString = File.ReadAllText(RPSpath);
        gameDataRPS RPSdata       = JsonUtility.FromJson <gameDataRPS>(RPSjsonString);

        RPSlogs.Clear();
        if (!(RPSdata == null))
        {
            foreach (GameLog log in RPSdata.RockPaperScissors)
            {
                RPSlogs.Add(log);
            }
        }

        string         Mempath       = Application.streamingAssetsPath + "/MemLogs.json";
        string         MemjsonString = File.ReadAllText(Mempath);
        gameDataMemory Memdata       = JsonUtility.FromJson <gameDataMemory>(MemjsonString);

        Memlogs.Clear();
        if (!(Memdata == null))
        {
            foreach (GameLog log in Memdata.MemoryGame)
            {
                Memlogs.Add(log);
            }
        }

        string          Spacepath       = Application.streamingAssetsPath + "/SpaceLogs.json";
        string          SpacejsonString = File.ReadAllText(Spacepath);
        gameDataShooter Spacedata       = JsonUtility.FromJson <gameDataShooter>(SpacejsonString);

        Spacelogs.Clear();
        if (!(Spacedata == null))
        {
            foreach (GameLog log in Spacedata.SpaceGame)
            {
                Spacelogs.Add(log);
            }
        }
    }
Exemplo n.º 2
0
    public static void SaveGameData()
    {
        gameDataMemory newData = new gameDataMemory();
        string         Mempath = Application.streamingAssetsPath + "/MemLogs.json";

        foreach (GameLog log in MainMenu.Memlogs)
        {
            newData.Add(log);
        }
        File.WriteAllText(Mempath, JsonUtility.ToJson(newData));
    }
Exemplo n.º 3
0
    // This is to save the game data
    public static void SaveGameData()
    {
        gameDataMemory newData = new gameDataMemory();
        string         path    = Application.streamingAssetsPath + "/memoryLogs.json";

        foreach (GameLog log in logs)
        {
            newData.Add(log);
        }
        Debug.Log(JsonUtility.ToJson(newData));
        File.WriteAllText(path, JsonUtility.ToJson(newData));
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    // This is just for obtaining existing records
    void Start()
    {
        string         path       = Application.streamingAssetsPath + "/memoryLogs.json";
        string         jsonString = File.ReadAllText(path);
        gameDataMemory data       = JsonUtility.FromJson <gameDataMemory>(jsonString);

        logs.Clear();
        if (!(data == null))
        {
            foreach (GameLog log in data.MemoryGame)
            {
                logs.Add(log);
            }
        }
    }