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); }
protected void AddPlayer(string playerName) { Player player = new Player(); if (string.IsNullOrWhiteSpace(playerName)) player.Name = "Player"; else player.Name = playerName; GameData.PlayerService.SavePlayer(player); }
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); }