public GameUI(SpacePlayer [] players) { int nbPlayer = players.Length; minutes = 0; seconds = 0; milliseconds = 0; Vector2 scale = SpaceGame.GetScale(); _guiGroup = new YnGroup(2); _scoreText = new YnText("Fonts/ScoresUI", "0"); _scoreText.Color = Color.Wheat; Add(_scoreText); _timeText = new YnText("Fonts/ScoresUI", "00:00:000"); _timeText.Color = Color.Wheat; Add(_timeText); _playerWeaponBox = new PlayerWeaponBox[nbPlayer]; for (int i = 0; i < nbPlayer; i++) { // Si 2 joueurs on a un alignement en bas int x = (i * 1100) + 25; int y = 700; // Sinon les joueurs 1 et 2 sont en haut // Et les autres en bas if (nbPlayer > 2) { // Joueurs 1 et 2 if (i < 2) { y = 25; } // Joueurs 3 et 4 else { x = ((i - 2) * 1100) + 25; y = 700; } } _playerWeaponBox[i] = new PlayerWeaponBox(x, y, players[i], ref scale); Add(_playerWeaponBox[i]); } }
public SoloPlayerState(SpaceShipType type, LevelType levelType) : base("solostate", true) { _levelType = levelType; if (_levelType == LevelType.Interior) { background = new InteriorBackground(); } else { background = new SpaceBackground(); } Add(background); // Les bonus sont en dessous de tout bonusGroup = new YnGroup(); Add(bonusGroup); // Joueur _player = new SpacePlayer(PlayerIndex.One, Registry.SpaceShipDescriptions[(int)type]); _player.Viewport = background.PlayableViewport; _player.Killed += new EventHandler <EventArgs>(_player_Killed); _player.PlayerReallyDead += new EventHandler <EventArgs>(_player_PlayerReallyDead); Add(_player); Registry.Players = new SpacePlayer[] { _player }; Registry.ScoreManager.CurrentGameScore = _player.GameScore; // Gestionnaire d'ennemies _ennemyManager = new EnnemyManager(); _ennemyManager.EnnemyDied += new EventHandler <EnnemyDeadEventArgs>(alienManager_EnnemyDied); Add(_ennemyManager); // Interface gameUI = new GameUI(Registry.Players); Add(gameUI); // Gestionnaire de message messageBoxManager = new MessageBoxManager(); Add(messageBoxManager); messageBoxManager.MessageBoxStart.CloseRequested += messageBoxStart_CloseRequested; messageBoxManager.MessageBoxPause.CloseRequested += messageBoxPause_CloseRequested; messageBoxManager.MessageBoxEnd.CloseRequested += messageBoxEnd_CloseRequested; // Timers _startGameTimer = new YnTimer(2500, 0); _startGameTimer.Completed += startGameTimer_Completed; _startGameTimer.Start(); _looseTimer = new YnTimer(5000, 0); _looseTimer.Completed += endTimer_Completed; // FX fxManager = new FxManager(); Add(fxManager); // audio Registry.AudioManager.VocalRate = 0; // Registry Registry.GameStatus = gameStatus; Registry.ActiveState = this; Registry.Ennemies = _ennemyManager; Registry.GameUI = gameUI; Registry.Background = background; Registry.FX = fxManager; ChangeGameStatus(GameStatus.Starting); }