public ImprovementScreen(IViewportProvider viewport, GameStateManager manager, SoundEffect select, SoundEffect choose) : base(manager) { this.viewport = viewport; this.select = select; this.choose = choose; }
private static InputData ReadInputFromKeyboard(IViewportProvider _viewport) { var forward = InputHandler.MouseState.RightButton == ButtonState.Pressed; var fire = InputHandler.MouseState.LeftButton == ButtonState.Pressed; var direction = Vector2.Zero; if (InputHandler.KeyDown(Config.PlayerKeyboardInputs["Up"])) { direction.Y = -1; } if (InputHandler.KeyDown(Config.PlayerKeyboardInputs["Right"])) { direction.X = 1; } if (InputHandler.KeyDown(Config.PlayerKeyboardInputs["Down"])) { direction.Y = 1; } if (InputHandler.KeyDown(Config.PlayerKeyboardInputs["Left"])) { direction.X = -1; } var distanceX = (_viewport.Width / 2f) - InputHandler.MouseState.X; var distanceY = (_viewport.Height / 2f) - InputHandler.MouseState.Y; var rotation = (float)Math.Atan2(distanceY, distanceX) - MathHelper.PiOver2; return(new InputData(fire, direction, rotation, new Vector2(distanceX, distanceY), forward)); }
// public void Update(GameTime gameTime, IViewportProvider viewport, SpriteBatch spriteBatch, ParticleManager<ParticleState> particleManager) public void Update(GameTime gameTime, IViewportProvider viewport) { if (_lives <= 0) { IsAlive = false; } var inputState = ReadInput(_controller, _viewport); Ship.MoveCommand(inputState.Forward, inputState.Rotation); BulletTime = (PlayerData.BulletTimeEnabled && (!_bulletTimeReloading)) ? true : false; if (inputState.Fire) { Fire(gameTime); } if (inputState.Fire) { _focusMode = true; } else if (_focusMode) { _focusMode = false; } if (BulletTime) { _bulletTimeTimer -= gameTime.ElapsedGameTime; if (_bulletTimeTimer <= TimeSpan.Zero) { _bulletTimeReloading = true; _bulletTimeTimer = TimeSpan.Zero; } } if (_bulletTimeReloading) { _bulletTimeTimer += gameTime.ElapsedGameTime; if (_bulletTimeTimer >= Config.DefaultBulletTimeTimer) { _bulletTimeReloading = false; _bulletTimeTimer = Config.DefaultBulletTimeTimer; } } Ship.Update(gameTime); foreach (var bullet in Bullets) { bullet.Update(gameTime); } }
public Player(IViewportProvider viewport, Config.Controller controller, Vector2 position, Camera2D camera) { _viewport = viewport; _controller = controller; _originPosition = position; _random = new Random(); this._camera = camera; _focusMode = false; _timeBeforeRespawn = TimeSpan.Zero; }
public Camera2D(IViewportProvider viewport) { _zoom = 1; _rotation = 0.0f; _pos = Vector2.Zero; _viewportWidth = viewport.Width; _viewportHeight = viewport.Height; _worldWidth = NewConfig.GameAreaX; _worldHeight = NewConfig.GameAreaY; }
public GamepadInputsScreen(IViewportProvider viewport, GameStateManager manager) : base(manager) { this.viewport = viewport; _title = "Gamepad"; _messages = new string[] { "This functionnality is not implemented yet !", "[Press Escape to go back to the title screen]" }; }
private static InputData ReadInput(Config.Controller controller, IViewportProvider viewport) { if (controller == Config.Controller.Keyboard) { return(ReadInputFromKeyboard(viewport)); } if (controller == Config.Controller.GamePad) { return(ReadInputFromPad()); } throw new ArgumentException(nameof(controller)); }
public TitleScreen(IViewportProvider viewport, GameStateManager manager, SoundEffect select, SoundEffect choose, InputHandler inputHandler) : base(manager) { this.viewport = viewport; this.select = select; this.choose = choose; this.inputHandler = inputHandler; _menuText = new string[] { "Start", "Shop", "Options", "Exit" }; _menuDescription = new string[] { "Playing game with only one player", "Get new abilities to crush more enemies", "You can change inputs here", "Warning: I've never tested this button !", }; _menuIndex = 0; }
public OptionsScreen(IViewportProvider viewport, GameStateManager manager, Texture2D pixel, SoundEffect select) : base(manager) { this.viewport = viewport; this.pixel = pixel; this.select = select; _title = "Options"; _menuText = new string[] { "1P Control", "2P Control", "Sound volume", "Music volume" }; _menuStartCoord = new Point( viewport.Width / 2, viewport.Height / 2 - 100); }
public GameProcessor(IViewportProvider viewport, Texture2D pixel) { this.viewport = viewport; this.pixel = pixel; }
public GameOverScreen(IViewportProvider viewport, GameStateManager manager) : base(manager) { _content = new List <string>(); this.viewport = viewport; }
public GameConfigurationScreen(IViewportProvider viewport, GameStateManager manager) : base(manager) { this.viewport = viewport; }
public GameplayScreen(IViewportProvider viewport, GameStateManager manager, Camera2D camera) : base(manager) { this.viewport = viewport; this.camera = camera; }
public KeyboardInputsScreen(IViewportProvider viewport, GameStateManager manager) : base(manager) { this.viewport = viewport; _title = "Keyboard"; }