/// <summary> /// saves the entire game to XML /// </summary> public void loadGameFromXml() { XmlSerializer xs = new XmlSerializer(typeof(GameViewModel)); if (File.Exists(Config.SAVE_GAMES_FILE)) { StreamReader objReader = new StreamReader(Config.SAVE_GAMES_FILE); GameViewModel game = (GameViewModel)xs.Deserialize(objReader); instance = game; } }
/// <summary> /// creates a new instance and overall a brand new roller derby game. /// </summary> public void createNewGame(GameTypeEnum gameType) { instance = new GameViewModel(); instance.GameId = Guid.NewGuid(); //instance.Periods = Config.WFTDA_DEFAULT_PERIODS; instance.Team1.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; instance.Team2.TimeOutsLeft = PolicyViewModel.Instance.TimeOutsPerPeriod; GameViewModel.Instance.CurrentPeriod = 0; //TODO: Team names should be different? instance.Team1.TeamName = "Home"; instance.CurrentTeam1Score = 0; instance.ScoresTeam1 = new List<ScoreViewModel>(); instance.Team1.TeamId = Guid.NewGuid(); instance.Team2.TeamName = "Away"; instance.CurrentTeam2Score = 0; instance.ScoresTeam2 = new List<ScoreViewModel>(); instance.Team2.TeamId = Guid.NewGuid(); instance.GameDate = DateTime.UtcNow; instance.TimeOuts = new List<TimeOutViewModel>(); createNewPeriod(); createNewJam(); createLineUpClock(); instance.Advertisements = new List<AdvertisementViewModel>(); AdvertisementViewModel.getAdvertsFromDirectory(); setupAdvertisements(); setCurrentAdvertisement(); this.NewGame(this, null); }