public ComputerPong() { myLatestSave = new SaveGame(); mySaveGameXML = new XMLHelper<SaveGame>(); myGameTime = DateTime.Now; //Transition Time TransitionOnTime = TimeSpan.FromSeconds(mySettings.TransitionOnTime); TransitionOffTime = TimeSpan.FromSeconds(mySettings.TransitionOffTime); //Load Player Info myPlayers = new GamePlayers(); myPlayersXML = new XMLHelper<GamePlayers>(); myPlayersXML.Load(ref myPlayers); //Load GameHistory myGameHistoryXML = new XMLHelper<GameHistory>(); myGameList = new GameHistory(); myGameHistoryXML.Load(ref myGameList); //Load Game Objects ObstaclePosition = new Obstacle(mySettings.MaxWidth / 2 - 10, mySettings.MaxHeight / 2 - 80); BallPosition = new Ball(mySettings.MaxWidth / 2 - 10, mySettings.MaxHeight / 2 - 10); RightPaddlePosition = new Paddle(mySettings.MaxWidth - 25, mySettings.MaxHeight / 2 - 40, mySettings.PaddleMoveFactor); LeftPaddlePosition = new Paddle(10, mySettings.MaxHeight / 2 - 40, mySettings.PaddleMoveFactor); playerPosition = new Vector2(mySettings.InitPosX, mySettings.InitPosY); enemyPosition = new Vector2(mySettings.InitPosX, mySettings.InitPosY); //Check if Both Users are In System or if Quick Play is Enabled if (myPlayers.myPlayers.Length != mySettings.NumberOfPlayers && !mySettings.QuickPlay) throw new Exception("There Need to be " + mySettings.NumberOfPlayers + " Active users in the system"); }
public Boolean AddItem(SaveGame mySaveGame) { try { mySaveGameList.Add(mySaveGame); return true; } catch (Exception ex) { throw new Exception("Error in Adding Game: " + ex.Message.ToString()); return false; } }
/// <summary> /// This is Fired when the Save Message Box is Fired /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void confirmSaveMessageBoxAccepted(object sender, PlayerIndexEventArgs e) { //Transfer SaveTempGame (saveGame.xml) to SaveGameList SaveGame myTempGame = new SaveGame(); XMLHelper<SaveGame> TempXML = new XMLHelper<SaveGame>(); TempXML.Load(ref myTempGame); SaveGameList mySaveGameList = new SaveGameList(); XMLHelper<SaveGameList> SaveGameXML = new XMLHelper<SaveGameList>(); SaveGameXML.Load(ref mySaveGameList); mySaveGameList.AddItem(myTempGame); SaveGameXML.Save(mySaveGameList); LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen()); }