public BaseLevel(SpaceShipDescription [] spaceShipDescription, LevelDescription levelDescription) : base("level", true) { Registry.Clear(); _nbPlayer = spaceShipDescription.Length; _players = new SpacePlayer[_nbPlayer]; _spaceShipDescriptions = spaceShipDescription; for (int i = 0; i < _nbPlayer; i++) { _players[i] = new SpacePlayer((PlayerIndex)i, _spaceShipDescriptions[i]); _players[i].Killed += new EventHandler <EventArgs>(BaseLevel_Killed); _players[i].PlayerReallyDead += new EventHandler <EventArgs>(BaseLevel_PlayerReallyDead); } Registry.Players = _players; _enemyManager = new EnnemyManager(); Registry.Ennemies = _enemyManager; _levelDescription = levelDescription; _timerEndLevel = new YnTimer(_levelDescription.LevelTimeMax, 0); _timerEndLevel.Completed += _timerEndLevel_Completed; }
public WeaponManager(SpacePlayer player) { _player = player; _recycled = new Stack <int>(); _canShoot = true; _shootTimer = new YnTimer(100, 0); }
public SplashscreenState() : base("splash", true) { background = new YnEntity("Backgrounds/Splash"); Add(background); timer = new YnTimer(3000, 0); timer.Completed += timer_Completed; }
public SplashState(string name) : base(name) { splashScreen = new YnEntity(Assets.TextureSplashScreen); Add(splashScreen); waitTimer = new YnTimer(1500, 0); waitTimer.Completed += (s, e) => stateManager.SetActive("menu", true); waitTimer.Start(); Add(waitTimer); }
public EnnemyManager() { spawnTimer = new YnTimer(2300); spawnTimer.Completed += spawnTimer_ReStarted; int numberOfEnnemies = Enum.GetValues(typeof(EnnemyType)).Length; _recycled = new Stack <int> [numberOfEnnemies]; for (int i = 0; i < numberOfEnnemies; i++) { _recycled[i] = new Stack <int>(); } }
// TODO ajouter un PlayerBundle ou un PlayerInfo ou un truc dans ce genre public SpacePlayer(PlayerIndex playerIndex, SpaceShipDescription description) : base() { AssetName = description.AssetName; _playerIndex = playerIndex; _shipSpeed = description.ShipSpeed; _playerProfile = new PlayerProfile(String.Format("Player {0}", ((int)playerIndex) + 1), (int)playerIndex); _firstWeaponType = (WeaponType)description.PrimaryWeaponId; _secondWeaponType = (WeaponType)description.SecondaryWeaponId; _bonusLevel = BonusLevel.None; VelocityMax = 0.95f; ForceInsideScreen = true; _live = 3; // TODO : case _shields = new YnSprite("Ship/Shield/Shields"); _weaponManager = new WeaponManager(this); _weaponManager.Initialized = true; _weaponManager.AssetsLoaded = true; LayerDepth = 0.4f; _playerTouchedTimer = new YnTimer(1500, 0); _playerTouchedTimer.Completed += _playerTouchedTimer_Completed; #if COMPLETE kinect = KinectSensorController.Instance; if (_playerIndex == PlayerIndex.One) { _kinectPlayerIndex = KinectPlayerIndex.One; } else if (_playerIndex == PlayerIndex.Two) { _kinectPlayerIndex = KinectPlayerIndex.Two; } #endif LoadContent(); }
public GameHUD() { itemsCount = 0; nbItemsCollected = 0; itemsCounter = new YnText("Font/Desiree_20", "{0} / {1} Cristaux"); itemsCounter.Scale = new Vector2(1.2f); itemsCounter.Color = TextColor; Add(itemsCounter); scoreText = new YnText("Font/Desiree_20", "0 pt"); scoreText.Scale = new Vector2(1.4f); scoreText.Color = TextColor; Add(scoreText); scoreCounterEntity = new YnEntity("UI/needle"); Add(scoreCounterEntity); timeText = new YnText("Font/Desiree_30", "00 : 00"); timeText.Scale = new Vector2(2.0f); timeText.Color = TextColor; Add(timeText); itemsCounterEntity = new YnEntity("UI/needle"); Add(itemsCounterEntity); timeCounterWheelEntity = new YnEntity("UI/topWheel"); Add(timeCounterWheelEntity); timeCounterNeedleEntity = new YnEntity("UI/needle-watch"); Add(timeCounterNeedleEntity); miniMapLeftBorder = new YnEntity("UI/mapBorderLeft"); Add(miniMapLeftBorder); miniMapBottomBorder = new YnEntity("UI/mapBorderBottom"); Add(miniMapBottomBorder); bottomBar = new YnEntity(new Rectangle(0, 0, YnG.Width, (int)ScreenHelper.GetScaleY(40)), Color.Black); bottomBar.Alpha = 0.4f; Add(bottomBar); bottomLogo = new YnEntity("UI/bottomWheel"); Add(bottomLogo); highlightTimer = new YnTimer(1000); highlightTimer.Completed += highlightTimer_Completed; }
public LevelState(string name, int startLevel) : base(name) { Camera = new FirstPersonCamera(); Camera.BoundingRadius = 2.0f; Camera.UpdateBoundingVolumes(); YnG.ShowMouse = (GameConfiguration.EnabledMouse ? true : false); YnG.AudioManager.SoundEnabled = GameConfiguration.EnabledSound; YnG.AudioManager.MusicVolume = GameConfiguration.MusicVolume; groundPlayerBoundingSphere = new BoundingSphere(Camera.Position, Camera.BoundingRadius); _mazeLevel = new MazeLevel(startLevel); Add(_mazeLevel); _gameHUD = new GameHUD(); timeTimer = new MazeTimer(); score = new Score(startLevel); gameState = MazeGameState.Playing; elapsedPartyTime = 0; soundTimer = new YnTimer(1000, 0); if (YnG.AudioManager.SoundEnabled) { soundTimer.Completed += (s, e) => YnG.AudioManager.SoundEnabled = true; } else { soundTimer.Completed += (s, e) => { } }; control = new MazeController(Camera); Scene.SceneLight.AmbientIntensity = 0.85f; Scene.SceneLight.DirectionalLights[0].Enabled = true; Scene.SceneLight.DirectionalLights[0].Direction = new Vector3(-1, 0.75f, -1); Scene.SceneLight.DirectionalLights[0].DiffuseColor = Color.WhiteSmoke.ToVector3(); Scene.SceneLight.DirectionalLights[0].DiffuseIntensity = 1.0f; Scene.SceneLight.DirectionalLights[0].SpecularColor = new Vector3(233, 33, 33); }
public Ennemy(EnnemyDescription description) { _type = (EnnemyType)description.Id; _description = description; AssetName = description.AssetName; _framerate = description.Framerate; _animationSize = new Vector2(description.AnimationSize[0], description.AnimationSize[1]); _animationIndex = description.AnimationIndex; _speed = description.Speed; _health = description.Health; _shield = 0.0f; _scale = new Vector2(0.75f); _timerFired = new YnTimer(100); _timerFired.Completed += timerFired_Completed; _radius = 60.0f; _sinAngle = 0.0f; LoadContent(); }
protected bool _kinectValidedAction; // Indique si l'item a été validé après le temps d'activation #endif /// <summary> /// Représente un écran de menu standard avec un titre et des items /// </summary> public BaseMenu(string title, int numItems) : base("basemenu", true) { // 1 - Le titre _title = new YnText("Fonts/Menu", title); _title.Color = Color.GhostWhite; _title.Scale = new Vector2(1.5f, 1.5f); Add(_title); string pointerAssetName = Assets.MouseCursor; #if COMPLETE kinect = KinectSensorController.Instance; _lastKinectPosition = Vector3.Zero; // Aucune action validée pour le moment _kinectValidedAction = false; // Evenements kinect _timerKinectOver = new YnTimer(KinectTimerDuration, 0); _timerKinectOver.Completed += new EventHandler <EventArgs>(_timerKinectOver_Completed); _timerKinectOver.ReStarted += new EventHandler <EventArgs>(_timerKinectOver_ReStarted); _transitionKinectOver = new YnTransition(KinectTimerDuration); if (kinect.IsAvailable) { pointerAssetName = Assets.KinectCursor; } #endif items = new List <MenuItem>(numItems); // Le curseur de souris/Kinect _handSelector = new YnEntity(pointerAssetName); }
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); }
public SceneState(string name) : base(name, false) { _vocalSynthetizer = new VocalSynthetizer(); InitParcours(); _menuIsShown = false; _visitedScreens = new Dictionary <string, bool>(); // 18 écrans _itemsOnScreen = new List <YnEntity>(); _narationText = new YnText("Fonts/GameText", "Dummy"); _narationText.Color = Color.DarkBlue; _narationText.Scale = new Vector2(1.5f) * Yna.Engine.Helpers.ScreenHelper.GetScale().X; _narationTimer = new YnTimer(3500); _narationTimer.Completed += (s, e) => _narationText.Active = false; _leftSceneHitbox = new Rectangle(0, _arrowHitboxSize, _arrowHitboxSize, YnG.Height - (97 - 25) - 2 * _arrowHitboxSize); _topSceneHitbox = new Rectangle(_arrowHitboxSize, 0, YnG.Width - 2 * _arrowHitboxSize, _arrowHitboxSize); _rightSceneHitbox = new Rectangle(YnG.Width - _arrowHitboxSize, _arrowHitboxSize, _arrowHitboxSize, YnG.Height - (97 - 25) - 2 * _arrowHitboxSize); _bottomSceneHitbox = new Rectangle(_arrowHitboxSize, YnG.Height - (97 - 25) - _arrowHitboxSize, YnG.Width - 2 * _arrowHitboxSize, _arrowHitboxSize); _menuHitbox = new Rectangle(YnG.Width / 2 - _buttonWidth / 2, YnG.Height - _buttonHeight, _buttonWidth, _buttonHeight); int padding = 30; int imageHalfSize = 30; int imageSize = imageHalfSize * 2; _goLeft = new YnEntity("Textures/icone-fleche-gauche", new Vector2(padding, YnG.Height / 2 - imageHalfSize)); _goLeft.Visible = false; _goLeft.Name = "go_left"; _goLeft.MouseClicked += (s, e) => GoLeft(); _goUp = new YnEntity("Textures/icone-fleche-haut", new Vector2(YnG.Width / 2 - imageHalfSize, padding)); _goUp.Visible = false; _goUp.Name = "go_up"; _goUp.MouseClicked += (s, e) => GoUp(); _goRight = new YnEntity("Textures/icone-fleche-droite", new Vector2(YnG.Width - padding - imageSize, YnG.Height / 2 - imageHalfSize)); _goRight.Visible = false; _goRight.Name = "go_right"; _goRight.MouseClicked += (s, e) => GoRight(); _goDown = new YnEntity("Textures/icone-fleche-bas", new Vector2(YnG.Width / 2 - imageHalfSize, YnG.Height - padding - imageSize - 97 + 25)); _goDown.Visible = false; _goDown.Name = "go_down"; _goDown.MouseClicked += (e, s) => GoDown(); _menuClosedY = YnG.Height - 25; _menuOpenedY = YnG.Height - 97; _menuBackground = new YnEntity("Textures/liste-inventaire", new Vector2(0, _menuClosedY)); int iconPadding = 15; int x = iconPadding; int y = YnG.Height - 60; _menuIcon = new YnEntity("Textures/btn-menu", new Vector2(x, y)); _menuIcon.Visible = false; _menuIcon.MouseClicked += (e, s) => { if (!_menuIcon.Visible) { return; } }; y = YnG.Height - 69; x = YnG.Width - iconPadding - 80; _notesIcon = new YnEntity("Textures/btn-notes", new Vector2(x, y)); _notesIcon.Visible = false; _notesIcon.MouseClicked += (e, s) => { if (!_notesIcon.Visible) { return; } // TODO Afficher les notes if (ImlostGame.Debug) { Console.WriteLine("Clicked on NOTES"); } }; _inventory = new List <InventoryItem>(); _itemImages = new Dictionary <string, YnEntity>(); foreach (InventoryItem item in ImlostGame.InventoryItems.Values) { YnEntity img = new YnEntity(item.AssetName); img.Visible = false; _itemImages.Add(item.Code, img); } _ambianceManager = new AmbianceManager(); }