Exemplo n.º 1
0
        public void load_pinned_games()
        {
            // fetch the pinned games,
            string path = Application.persistentDataPath + "pinned.json";

            if (System.IO.File.Exists(path))
            {
                // read from the file into _pinned
                System.IO.FileStream   fs = new System.IO.FileStream(path, System.IO.FileMode.Open);
                System.IO.StreamReader sr = new System.IO.StreamReader(fs);
                _pinned = JsonConvert.DeserializeObject <PinnedGames>(sr.ReadToEnd());
                sr.Close();
                fs.Close();
            }

            foreach (string game in _pinned.pinned)
            {
                string url = "https://www.speedrun.com/api/v1/games/" + game;
                StartCoroutine(get_game_request(url));
            }
        }
Exemplo n.º 2
0
        public bool toggle_pin_game(string id)
        {
            bool result = false;

            if (_pinned == null)
            {
                _pinned = new PinnedGames();
            }
            if (_pinned.pinned.Contains(id))
            {
                // unpin
                _pinned.pinned.Remove(id);
                result = false;
            }
            else
            {
                // pin
                _pinned.pinned.Add(id);
                result = true;
            }
            save_pinned_games();
            load_pinned_games();
            return(result);
        }