/// <summary> /// Constructor for the single player mode of the game /// </summary> /// <param name="content">Content manager of the game</param> public FirstMode(ContentManager content) { this.LoadContent(content); levelState = LevelState.WAITING_FOR_COMPUTER; isTimeToChoose = false; //messagePosition of the score of players on the screen playerScorePosition = new Vector2(GameConstants.SCORE_POSITION_PLAYER_X, GameConstants.SCORE_POSITION_PLAYER_Y); computerScorePosition = new Vector2(GameConstants.SCORE_POSITION_COMPUTER_X, GameConstants.SCORE_POSITION_COMPUTER_Y); //backGround this.backDrawRectandle = new Rectangle(-5, -20, backgroundPicture.Width, backgroundPicture.Height); //buttons this.returnButton = new Button(content, "Button_8", new Vector2(GameConstants.BUTTON_8_POSITION_X, GameConstants.BUTTON_8_POSITION_Y)); this.exitGameButton = new Button(content, "Button_9", new Vector2(GameConstants.BUTTON_9_POSITION_X, GameConstants.BUTTON_9_POSITION_Y)); this.nextButton = new Button(content, "Button_10", new Vector2(GameConstants.BUTTON_10_POSITION_X, GameConstants.BUTTON_10_POSITION_Y)); //elements of the player this.playerRock = new Element(content, Element.THREE_MODE, "Rock3", Element.ROCK, new Vector2(GameConstants.START_PLAYER3_ROCK_X, GameConstants.START_PLAYER3_ROCK_Y)); this.playerPaper = new Element(content, Element.THREE_MODE, "Paper3", Element.PAPER, new Vector2(GameConstants.START_PLAYER3_PAPER_X, GameConstants.START_PLAYER3_PAPER_Y)); this.playerScissors = new Element(content, Element.THREE_MODE, "Scissors3", Element.SCISSORS, new Vector2(GameConstants.START_PLAYER3_SCISSORS_X, GameConstants.START_PLAYER3_SCISSORS_Y)); //elements of the computer this.compRock = new CompElement(content, CompElement.THREE_MODE, "Rock2", CompElement.ROCK, new Vector2(GameConstants.START_COMPUTER_ROCK_X, GameConstants.START_COMPUTER_ROCK_Y)); this.compPaper = new CompElement(content, CompElement.THREE_MODE, "Paper2", CompElement.PAPER, new Vector2(GameConstants.START_COMPUTER_PAPER_X, GameConstants.START_COMPUTER_PAPER_Y)); this.compScissors = new CompElement(content, CompElement.THREE_MODE, "Scissors2", CompElement.SCISSORS, new Vector2(GameConstants.START_COMPUTER_SCISSORS_X, GameConstants.START_COMPUTER_SCISSORS_Y)); }
/// <summary> /// Updating single player mode /// </summary> /// <param name="gameTime">Game time manager</param> /// <param name="content">Content manager</param> /// <param name="keyboard">KeyBoard manager</param> public void Update(GameTime gameTime, ContentManager content, MouseState mouse) { // updating button, giving game stage needed to the main menu this.returnButton.Update(mouse, GameState.MAIN_MENU); this.exitGameButton.Update(mouse, GameState.EXIT_GAME); if (SecondMode.levelState == LevelState.RESULTS) // this button reloads the level { this.nextButton.Update(mouse, GameConstants.NEW_FIVE_OBJECTS_GAME); } //updating player elements this.playerRock.Update(gameTime, mouse); this.playerPaper.Update(gameTime, mouse); this.playerScissors.Update(gameTime, mouse); this.playerSpock.Update(gameTime, mouse); this.playerLizard.Update(gameTime, mouse); //updating computer elements this.compRock.Update(gameTime, mouse); this.compPaper.Update(gameTime, mouse); this.compScissors.Update(gameTime, mouse); this.compSpock.Update(gameTime, mouse); this.compLizard.Update(gameTime, mouse); // computer choise is calculated here when CompElement will say if (SecondMode.isTimeToChoose) { this.Choise(); SecondMode.isTimeToChoose = false; } // computer choise is calculated here when Element will say if (SecondMode.isTimeForResult) { SecondMode.isTimeForResult = false; //the main logic is here this.computeResults(); } //this code reloads level if (SecondMode.levelState == LevelState.RELOAD_LEVEL) { SecondMode.isTimeToChoose = false; SecondMode.isTimeForResult = false; //elements of the player this.playerRock = new Element(content, Element.FIVE_MODE, "Rock3", Element.ROCK, new Vector2(GameConstants.START_PLAYER5_ROCK_X, GameConstants.START_PLAYER5_ROCK_Y)); this.playerSpock = new Element(content, Element.FIVE_MODE, "Spock3", Element.SPOCK, new Vector2(GameConstants.START_PLAYER5_SPOCK_X, GameConstants.START_PLAYER5_SPOCK_Y)); this.playerPaper = new Element(content, Element.FIVE_MODE, "Paper3", Element.PAPER, new Vector2(GameConstants.START_PLAYER5_PAPER_X, GameConstants.START_PLAYER5_PAPER_Y)); this.playerLizard = new Element(content, Element.FIVE_MODE, "Lizard3", Element.LIZARD, new Vector2(GameConstants.START_PLAYER5_LIZARD_X, GameConstants.START_PLAYER5_LIZARD_Y)); this.playerScissors = new Element(content, Element.FIVE_MODE, "Scissors3", Element.SCISSORS, new Vector2(GameConstants.START_PLAYER5_SCISSORS_X, GameConstants.START_PLAYER5_SCISSORS_Y)); //elements of the computer this.compRock = new CompElement(content, CompElement.FIVE_MODE, "Rock2", CompElement.ROCK, new Vector2(GameConstants.START_COMPUTER_ROCK_X, GameConstants.START_COMPUTER_ROCK_Y)); this.compSpock = new CompElement(content, CompElement.FIVE_MODE, "Spock2", CompElement.SPOCK, new Vector2(GameConstants.START_COMPUTER_SPOCK_X, GameConstants.START_COMPUTER_SPOCK_Y)); this.compPaper = new CompElement(content, CompElement.FIVE_MODE, "Paper2", CompElement.PAPER, new Vector2(GameConstants.START_COMPUTER_PAPER_X, GameConstants.START_COMPUTER_PAPER_Y)); this.compLizard = new CompElement(content, CompElement.FIVE_MODE, "Lizard2", CompElement.LIZARD, new Vector2(GameConstants.START_COMPUTER_LIZARD_X, GameConstants.START_COMPUTER_LIZARD_Y)); this.compScissors = new CompElement(content, CompElement.FIVE_MODE, "Scissors2", CompElement.SCISSORS, new Vector2(GameConstants.START_COMPUTER_SCISSORS_X, GameConstants.START_COMPUTER_SCISSORS_Y)); //let computer make a move again SecondMode.levelState = LevelState.WAITING_FOR_COMPUTER; } //Background music support if (Game1.gameStage != GameState.FIVE_OBJECTS) { this.backgroundMusic.Stop(); this.isPlaying = false; } else if (!this.isPlaying) { this.backgroundMusic.Play(); this.isPlaying = true; } }