/// <summary>
 /// Konstruktor
 /// </summary>
 public ScreenManager(Game game, GraphicsDeviceManager graphics)
     : base(game)
 {
     this.graphics = graphics;
     input = new InputState();
     this.Settings = this.Settings;
 }
        /// <summary>
        /// Handle Input
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            KeyboardState keyboardState = input.CurrentKeyboardState;

            if (input.IsPauseGame())
            {
                MessageBoxScreen ExitGame = new MessageBoxScreen("Wyjść z gry?");
                ExitGame.Accepted += delegate(object sender, EventArgs e)
                {
                    LoadingScreen.Load(ScreenManager, false, new BackgroundScreen(@"Menu\background"), new MainMenuScreen());
                };
                ScreenManager.AddScreen(ExitGame);
            }
            else
            {
                gameManager.HandleInput(input);
            }
        }
        /// <summary>
        /// HandleInput
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuUp())
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

            if (input.IsMenuDown())
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            int select;

            if (IsMenuHovered(input, out select))
            {
                selectedEntry = select;
            }

            // Sprawdzanie czy wcisnieta została akceptacja jakiejś pozycji w menu

            if (input.IsMenuKeySelect())
            {
                OnSelectEntry(selectedEntry);
            }
            else if (IsMenuMouseSelect(input, out select))
            {
                selectedEntry = select;
                OnSelectEntry(selectedEntry);
            }
            else if (input.IsMenuCancel())
            {
                OnCancel();
            }
            System.Diagnostics.Trace.Write(selectedEntry);
        }
 /// <summary>
 /// IsMenuMouseSelect
 /// </summary>
 private bool IsMenuMouseSelect(InputState input, out int selected)
 {
     Vector2 Coord;
     selected = 0;
     if (input.IsNewMouseLeftClick(out Coord))
     {
         foreach (MenuEntry M in MenuEntries)
         {
             if (M.IsContained(Coord, this.ScreenManager.Font))
             {
                 return true;
             }
             selected++;
         }
     }
     return false;
 }
 /// <summary>
 /// IsMenuHovered
 /// </summary>
 private bool IsMenuHovered(InputState input, out int selected)
 {
     Vector2 Coord;
     selected = 0;
     if (input.IsNewMouseMove(out Coord))
     {
         foreach (MenuEntry M in MenuEntries)
         {
             if (M.IsContained(Coord, this.ScreenManager.Font))
             {
                 if (!M.IsContained(new Vector2(input.LastMouseState.X, input.LastMouseState.Y), this.ScreenManager.Font) && ScreenManager.Settings.SoundEffects && selected != selectedEntry)
                 {
                     soundEffect.Play();
                 }
                 return true;
             }
             selected++;
         }
     }
     return false;
 }
 public void HandleInput(InputState input)
 {
 }
        /// <summary>
        /// HandleInput
        /// </summary>
        public override void HandleInput(InputState input)
        {
            choices[0].Selected += Accepted;

            if (input.IsMenuLeft())
            {
            selected--;

            if (selected < 0)
            selected = choices.Count - 1;
            }

            if (input.IsMenuRight())
            {
            selected++;

            if (selected >= choices.Count)
            selected = 0;
            }

            int select;

            if (IsMenuHovered(input, out select))
            {
            selected = select;
            }

            // Sprawdzanie czy wcisnieta została akceptacja jakiejś pozycji w menu

            if (input.IsMenuKeySelect())
            {
            OnSelectEntry(selected);
            }
            else if (IsMenuMouseSelect(input, out select))
            {
            selected = select;
            OnSelectEntry(selected);
            }
        }
 /// <summary>
 /// Pozwala warstwie obsługiwać Input użytkownika. 
 /// Działa tylko jeśli warstwa jest w stanie Active.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }
        public void HandleInput(InputState input)
        {
            if (input.IsNewMouseLeftClick(out MouseCord) || input.IsNewMouseRightClick(out MouseCord) || input.IsMouseLeftClickHold())
            {
                // Myszka na interfejsie
                if (input.CurrentMouseState.X < GameInterface.Width)
                {
                    GameInterface.HandleInput(input);
                }
                // Myszka w grze
                else
                {
                    if (input.IsNewMouseRightClick(out MouseCord))
                    {
                        foreach (Fighter f in Fighters)
                        {
                            if ((!f.IsAlive && f.isDying) || f.IsAlive)
                                f.Move(screenManager.Settings.Resolution, GameMap, Fighters, Enemies, input);
                        }
                    }
                    if (input.IsMouseLeftClickHold())
                    {
                        foreach (Fighter f in Fighters)
                        {
                            if ((!f.IsAlive && f.isDying) || f.IsAlive)
                                f.Shoot(screenManager, input, Weapon.Gun, screenManager.GameTime, Missiles);
                        }
                    }
                }

            }

            if (input.IsNewKeyPress(Keys.Z))
            {
                if (Fighters.Count>0)
                Fighters[0].Die(Fighters);
                if (Fighters.Count>2)
                Fighters[2].Die(Fighters);
            }
        }
Beispiel #10
0
 public void Shoot(ScreenManager screenManager, InputState input, Weapon weapon, GameTime gameTime, List<Missile> missiles)
 {
     if (gameTime.TotalGameTime.TotalSeconds - timeLastShot.TotalSeconds > Unit.shotFrequency && !isDying)
     {
         timeLastShot = new TimeSpan(gameTime.TotalGameTime.Days, gameTime.TotalGameTime.Hours, gameTime.TotalGameTime.Minutes, gameTime.TotalGameTime.Seconds, gameTime.TotalGameTime.Milliseconds);
         missiles.Add(Missile.FromWeapon(weapon, position+new Vector2(0,-20), new Vector2(input.CurrentMouseState.X - GameInterface.Width - (screenManager.Settings.Resolution.X - GameInterface.Width) / 2 + camera.Pos.X, input.CurrentMouseState.Y - screenManager.Settings.Resolution.Y / 2 + camera.Pos.Y), timeLastShot, Faction.Fighters, gameTime));
         missiles.Last().Load(screenManager.Game.Content);
     }
 }
Beispiel #11
0
 public void Move(Vector2 resolution, GameMap gameMap, List<Fighter> fighters, List<Enemy> enemies, InputState input)
 {
     if (playerControlled && !isDying)
         Destination = new Vector2(input.CurrentMouseState.X - GameInterface.Width - (resolution.X - GameInterface.Width) / 2 + camera.Pos.X, input.CurrentMouseState.Y - resolution.Y / 2 + camera.Pos.Y);
 }