Пример #1
0
    void Awake()
    {
        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);
            }
        }

        int   GetWin  = PlayerPrefs.GetInt("SpaceBGWin");
        float GetWinV = PlayerPrefs.GetFloat("SpaceBGWinV");

        winSFX.volume = GetWinV;
        winSFX.clip   = SpaceWinBG[GetWin];
        winSFX.Play();
        if (Users.CurrentUser.username == "admin")
        {
            Main.Spacelogs.Add(new GameLog("admin", System.DateTime.Now.ToString(), Main.score.ToString(), Main.lvl));
        }

        else
        {
            Main.Spacelogs.Add(new GameLog(Users.CurrentUser.username, System.DateTime.Now.ToString(), Main.score.ToString(), Main.lvl));
        }

        Main.SaveGameData();
    }
Пример #2
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);
            }
        }
    }
Пример #3
0
    public static void SaveGameData()
    {
        gameDataShooter newData = new gameDataShooter();
        string          path    = Application.streamingAssetsPath + "/SpaceLogs.json";

        foreach (GameLog log in Spacelogs)
        {
            newData.Add(log);
        }
        File.WriteAllText(path, JsonUtility.ToJson(newData));
    }
Пример #4
0
    // Start is called before the first frame update
    // This is where the history of users are loaded from the json file
    void Start()
    {
        string          path       = Application.streamingAssetsPath + "/spaceLogs.json";
        string          jsonString = File.ReadAllText(path);
        gameDataShooter data       = JsonUtility.FromJson <gameDataShooter>(jsonString);

        logs.Clear();
        if (!(data == null))
        {
            foreach (GameLog log in data.ShooterGame)
            {
                logs.Add(log);
            }
        }
    }
Пример #5
0
    void Start()
    {
        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);
            }
        }
    }
Пример #6
0
    void Start()
    {
        if (S == null)
        {
            S = this;
        }
        ClearWeapons();
        weapons[0].SetType(WeaponType.blaster);

        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);
            }
        }
    }