Esempio n. 1
0
        public void SetupGames()
        {
            ExistingGames = new Dictionary <string, IGame>();
            GameBank bank = Storage.Load <GameBank>(GamesFile);

            for (int i = 0; i < bank?.Games.Count; i++)
            {
                GameItem item = bank.Games[i];
                if (GameFactories.TryCreate(item.Game, out IGame game))
                {
                    game.InternalTitle = item.InternalTitle;
                    game.Load(Storage);
                    ExistingGames.Add(game.InternalTitle, game);
                    if (bank.LastGame == i)
                    {
                        SetGame(game);
                    }
                }
            }
        }
Esempio n. 2
0
        public void Save()
        {
            GameBank bank     = new GameBank();
            int      lastGame = -1;
            int      curr     = 0;

            foreach (KeyValuePair <string, IGame> pair in ExistingGames)
            {
                if (pair.Value == CurrentGame)
                {
                    lastGame = curr;
                }
                bank.Games.Add(new GameItem()
                {
                    Game          = pair.Value.InternalName,
                    InternalTitle = pair.Key,
                    LastActivity  = pair.Value.Data.LastActivity
                });
                pair.Value.Save(Storage);
                curr++;
            }
            bank.LastGame = lastGame;
            Storage.Write(GamesFolder + "games", bank);
        }