Пример #1
0
        public void DeletePlayer(Player player)
        {
            if (player == null)
                throw new Exception("Cannot delete null player.");

            _players.Remove(player);
            string serializedParks = JsonConvert.SerializeObject(_players);
            _fileHandler.WriteAllText(_storagePath, serializedParks);
        }
Пример #2
0
 protected void AddPlayer(string playerName)
 {
     Player player = new Player();
     if (string.IsNullOrWhiteSpace(playerName))
         player.Name = "Player";
     else
         player.Name = playerName;
     GameData.PlayerService.SavePlayer(player);
 }
Пример #3
0
        public void SavePlayer(Player player)
        {
            Boolean newPlayer = false;
            if (!player.Id.HasValue) {
                player.Id = GetNextId ();
                newPlayer = true;
            }

            if (newPlayer)
                _players.Add(player);
            string playerString = JsonConvert.SerializeObject (_players);
            _fileHandler.WriteAllText (_storagePath, playerString);
        }