/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here gameUI.LoadContent(Content); }
public void setupPlay() { gameUI = new BoardUI(logic.B, BoardWidth, BoardHeight, 0, 0); //((Window.ClientBounds.Width / 2) + (.5 * BoardWidth)), ((Window.ClientBounds.Height / 2) + (.5 * BoardHeight))); plays.Clear(); //plays.Add(new Element { et = ElementTypes.Ghost, X = 1, Y = 1 }); ControllerScheme scheme = new ControllerScheme(ControllerTypes.Keyboard); scheme.Add(Keys.Up); scheme.Add(Keys.Down); scheme.Add(Keys.Left); scheme.Add(Keys.Right); scheme.Add(Keys.Enter); ControllerScheme scheme2 = new ControllerScheme(ControllerTypes.Keyboard); scheme2.Add(Keys.W); scheme2.Add(Keys.S); scheme2.Add(Keys.A); scheme2.Add(Keys.D); scheme2.Add(Keys.Enter); byte controllerNum = 0; byte keyboardNum = 0; for (int i = 0; i < playerSetup.players.Count(); i++) { //Keyboard controlled ghost if (playerSetup.players[i].controllerType == ControllerTypes.Keyboard && playerSetup.players[i].IsGhost) { keyboardNum++; Element e = new Element(); e.et = ElementTypes.Ghost; if (keyboardNum == 1) { e.Control = new KeyboardInput(scheme); } else if (keyboardNum == 2) { e.Control = new KeyboardInput(scheme2); } else if (keyboardNum > 2 && e.et == ElementTypes.PacPlayer) { e.Control = new PacAI(e); } else if (keyboardNum > 2 && e.et == ElementTypes.Ghost) { e.Control = new GhostAI(e); } plays.Add(e); } //Keyboard controlled pacman else if (playerSetup.players[i].controllerType == ControllerTypes.Keyboard && !(playerSetup.players[i].IsGhost)) { keyboardNum++; Element e = new Element(); e.et = ElementTypes.PacPlayer; if (keyboardNum == 1) { e.Control = new KeyboardInput(scheme); } else if (keyboardNum == 2) { e.Control = new KeyboardInput(scheme2); } else if (keyboardNum > 2 && e.et == ElementTypes.PacPlayer) { e.Control = new PacAI(e); } else if (keyboardNum > 2 && e.et == ElementTypes.Ghost) { e.Control = new GhostAI(e); } plays.Add(e); } //AI controlled ghost else if ((playerSetup.players[i].controllerType == ControllerTypes.PacAI || playerSetup.players[i].controllerType == ControllerTypes.GhostAI) && (playerSetup.players[i].IsGhost)) { Element e = new Element(); e.et = ElementTypes.Ghost; e.Control = new GhostAI(e); e.IsAlive = true; plays.Add(e); } //AI controlled pacman else if ((playerSetup.players[i].controllerType == ControllerTypes.PacAI || playerSetup.players[i].controllerType == ControllerTypes.GhostAI) && !(playerSetup.players[i].IsGhost)) { Element e = new Element(); e.et = ElementTypes.PacPlayer; e.Control = new PacAI(e); e.IsAlive = true; plays.Add(e); } //Controller controlled pacman else if (playerSetup.players[i].controllerType == ControllerTypes.Xbox && !(playerSetup.players[i].IsGhost)) { controllerNum++; Element e = new Element(); e.et = ElementTypes.PacPlayer; if (controllerNum == 1) { e.Control = new ControllerInput(PlayerIndex.One); } else if (controllerNum == 2) { e.Control = new ControllerInput(PlayerIndex.Two); } else if (controllerNum == 3) { e.Control = new ControllerInput(PlayerIndex.Three); } else if (controllerNum == 4) { e.Control = new ControllerInput(PlayerIndex.Four); } else if (controllerNum > 4 && e.et == ElementTypes.PacPlayer) { //e.Control = new PacAI(); } else if (controllerNum > 4 && e.et == ElementTypes.Ghost) { e.Control = new GhostAI(e); } plays.Add(e); } //Controller controlled ghost else if (playerSetup.players[i].controllerType == ControllerTypes.Xbox && (playerSetup.players[i].IsGhost)) { controllerNum++; Element e = new Element(); e.et = ElementTypes.Ghost; if (controllerNum == 1) { e.Control = new ControllerInput(PlayerIndex.One); } else if (controllerNum == 2) { e.Control = new ControllerInput(PlayerIndex.Two); } else if (controllerNum == 3) { e.Control = new ControllerInput(PlayerIndex.Three); } else if (controllerNum == 4) { e.Control = new ControllerInput(PlayerIndex.Four); } else if (controllerNum > 4 && e.et == ElementTypes.PacPlayer) { //e.Control = new PacAI(); } else if (controllerNum > 4 && e.et == ElementTypes.Ghost) { e.Control = new GhostAI(e); } plays.Add(e); } } if (setup.gameMode == Setup.GameModes.Classic) { logic = new GameLogicClassic(); } else if (setup.gameMode == Setup.GameModes.GhostHunt) { logic = new GameLogicGhostHunt(); } boardToShare = logic.GameLogicSetup(plays); new Node(boardToShare, gameUI); Node.Handle.GenerateMatrix(); List <Sprite> sprites = new List <Sprite>(); foreach (Element Element in boardToShare.Elements) { Sprite gameSprite = Sprite.getSprite(Element, logic.B, (int)Math.Min(BoardWidth / logic.B.Width, BoardHeight / logic.B.Height)); gameUI.RegisterSprite(gameSprite); //Assigning the elements within sprites names. if (gameSprite.Element.et == ElementTypes.Ghost) { if (gameSprite.getColor() == Color.HotPink) { gameSprite.Element.Name = "Pinky"; } else if (gameSprite.getColor() == Color.Cyan) { gameSprite.Element.Name = "Inky"; } else if (gameSprite.getColor() == Color.Red) { gameSprite.Element.Name = "Blinky"; } else if (gameSprite.getColor() == Color.Orange) { gameSprite.Element.Name = "Clyde"; } } else if (gameSprite.Element.et == ElementTypes.PacPlayer) { gameSprite.Element.Name = "PacPlayer " + PacPlayerID; PacPlayerID += 1; } if (gameSprite.Element.et == ElementTypes.Ghost || gameSprite.Element.et == ElementTypes.PacPlayer) { sprites.Add(gameSprite); } } scoreManager = new ScoreManager(sprites); gameUI.LoadContent(Content); var aliveSprites = from m in plays.ToArray() where m.IsAlive where m.et == ElementTypes.PacPlayer || m.et == ElementTypes.Ghost select m; scoreBoards = new SBoardManager(this, aliveSprites.ToArray()); }