public ImprovementScreen(IViewportProvider viewport, GameStateManager manager, SoundEffect select, SoundEffect choose)
     : base(manager)
 {
     this.viewport = viewport;
     this.select   = select;
     this.choose   = choose;
 }
Example #2
0
        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));
        }
Example #3
0
        // 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);
            }
        }
Example #4
0
 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;
 }
Example #5
0
 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]"
            };
        }
Example #7
0
        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));
        }
Example #8
0
        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;
        }
Example #9
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);
        }
Example #10
0
 public GameProcessor(IViewportProvider viewport, Texture2D pixel)
 {
     this.viewport = viewport;
     this.pixel    = pixel;
 }
Example #11
0
 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";
 }