//Définition des éléments nécessaire à la création graphique du menu public Menu(Pong game) { this.game = game; buttons = new List<Button>(); leftChoices = new List<Button>(); rightChoices = new List<Button>(); menuSprites = new List<Sprite>(); // Position des boutons en fonction de la taille de la fenêtre int leftButtonsPositionX = (Conf.WINDOW_WIDTH/2 - Conf.BUTTON_WIDTH)/2; int rightButtonsPositionX = (Conf.WINDOW_WIDTH / 2) + leftButtonsPositionX; Vector2 leftButtonsPosition = new Vector2(leftButtonsPositionX, 200); // Création des boutons et ajout dans les listes adaptées buttons.Add(new Button(leftButtonsPosition, "1 player", 1, Conf.InteligenceType.HUMAN)); leftChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(leftButtonsPositionX, 300), "2 players", 2, Conf.InteligenceType.HUMAN)); leftChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(leftButtonsPositionX, 400), "AI", 1, Conf.InteligenceType.IA)); leftChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(rightButtonsPositionX, 200), "1 player", 1, Conf.InteligenceType.HUMAN)); rightChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(rightButtonsPositionX, 300), "2 players", 2, Conf.InteligenceType.HUMAN)); rightChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(rightButtonsPositionX, 400), "AI", 1, Conf.InteligenceType.IA)); rightChoices.Add(buttons.Last()); buttons.Add(new Button(new Vector2(375, 500), "GO !")); // Ajout des boutons dans la liste des sprites à dessier foreach (Button button in buttons) { menuSprites.Add(button); menuSprites.Add(button.labelSprite); } title = new SpriteTexture2D(new Vector2(350, 20), 300, 75); SpriteText leftTeamLabel = new SpriteText(new Vector2(145, 110), Color.White, "Left Side"); SpriteText rightTeamLabel = new SpriteText(new Vector2(640, 110), Color.White, "Right Side"); menuSprites.Add(title); menuSprites.Add(leftTeamLabel); menuSprites.Add(rightTeamLabel); }
private void setInital() { if (this.Team.Side.Equals(Conf.TeamSide.LEFT)) { if (this.PlayerPosition == Conf.PlayerPosition.BACK) { this.position = new Vector2(Conf.BACK_PLAYER_MARGIN, Conf.WINDOW_HEIGHT / 2 - Conf.BAT_HEIGHT/2); this.Controler = new KeyboardPlayerControler(Keys.A, Keys.Q,this); this.keyUp = "A"; this.keyDown = "Q"; this.keySprite = new SpriteTexture2D(new Vector2(Conf.BACK_PLAYER_MARGIN + Conf.KEY_CONTROL_PICTURE_MARGIN_LEFT, (Conf.WINDOW_HEIGHT / 2) - Conf.BAT_HEIGHT / 2 - Conf.KEY_CONTROL_PICTURE_MARGIN_TOP), 40, 120); this.Color = Conf.PlayerColor.BLUE; } else { this.position = new Vector2(Conf.FRONT_PLAYER_MARGIN, Conf.WINDOW_HEIGHT / 2 - Conf.BAT_HEIGHT / 2); this.Controler = new KeyboardPlayerControler(Keys.F, Keys.V, this); this.keyUp = "F"; this.keyDown = "V"; this.keySprite = new SpriteTexture2D(new Vector2(Conf.FRONT_PLAYER_MARGIN + Conf.KEY_CONTROL_PICTURE_MARGIN_LEFT, (Conf.WINDOW_HEIGHT / 2) - Conf.BAT_HEIGHT / 2 - Conf.KEY_CONTROL_PICTURE_MARGIN_TOP), 40, 120); this.Color = Conf.PlayerColor.RED; } } else { if (this.PlayerPosition == Conf.PlayerPosition.BACK) { this.position = new Vector2(Conf.WINDOW_WIDTH - Conf.BACK_PLAYER_MARGIN, Conf.WINDOW_HEIGHT / 2 - Conf.BAT_HEIGHT / 2); this.Controler = new KeyboardPlayerControler(Keys.Up, Keys.Down, this); this.keyUp = "Up"; this.keyDown = "Down"; this.keySprite = new SpriteTexture2D(new Vector2(Conf.WINDOW_WIDTH - Conf.BACK_PLAYER_MARGIN - Conf.KEY_CONTROL_PICTURE_MARGIN_RIGHT, (Conf.WINDOW_HEIGHT / 2) - Conf.BAT_HEIGHT / 2 - Conf.KEY_CONTROL_PICTURE_MARGIN_TOP), 40, 120); this.Color = Conf.PlayerColor.GREEN; } else { this.position = new Vector2(Conf.WINDOW_WIDTH - Conf.FRONT_PLAYER_MARGIN, Conf.WINDOW_HEIGHT / 2 - Conf.BAT_HEIGHT / 2); this.Controler = new KeyboardPlayerControler(Keys.J, Keys.N, this); this.keyUp = "J"; this.keyDown = "N"; this.keySprite = new SpriteTexture2D(new Vector2(Conf.WINDOW_WIDTH - Conf.FRONT_PLAYER_MARGIN - Conf.KEY_CONTROL_PICTURE_MARGIN_RIGHT, (Conf.WINDOW_HEIGHT / 2) - Conf.BAT_HEIGHT / 2 - Conf.KEY_CONTROL_PICTURE_MARGIN_TOP), 40, 120); this.Color = Conf.PlayerColor.YELLOW; } } if (this.Type == Conf.InteligenceType.IA) { this.Controler = new ArtificialPlayerControler(this); } }