示例#1
0
        public void Update()
        {
            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()))
            {
                if (MouseInput.ScrolledDown())
                {
                    _offset -= 64f;
                }
                if (MouseInput.ScrolledUp())
                {
                    _offset += 64f;
                }
            }

            if (_offset < -((32 * _items.Count) - Boundary.Size.Y + 32))
            {
                _offset = -((32 * _items.Count) - Boundary.Size.Y + 32);
            }

            if (_offset > 0)
            {
                _offset = 0;
            }

            for (int i = 0; i < _items.Count; i++)
            {
                _items[i].Move(_offset);
                _items[i].Update(this);
            }
        }
示例#2
0
        public void Update()
        {
            _oldSelectedIndex = SelectedIndex;

            _scrollBar.Update(GetLenghtOfContent());

            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()))
            {
                if (MouseInput.ScrolledDown())
                {
                    _scrollBar.ScroolDown();
                }
                if (MouseInput.ScrolledUp())
                {
                    _scrollBar.ScroolUp();
                }
            }

            Set();

            SelectedIndex = null;

            foreach (IHolderItem tile in Items)
            {
                tile.Update();

                if (tile.Selected == true)
                {
                    SelectedIndex = tile.Index;
                }
            }

            if (ChangedSelection() == true)
            {
                _method?.Invoke();
            }
        }
示例#3
0
        public void ControlPlayer(Player player)
        {
            player.Walking = false;

            if (KeyboardInput.KeyboardStateNew.IsKeyDown(Game1.STP.ControlKeys["Jump"]))
            {
                if (player.Resolver.InWater == true)
                {
                    player.Velocity = new Vector2(player.Velocity.X, -0.2f);
                }
            }

            if (KeyboardInput.KeyboardStateNew.IsKeyDown(Game1.STP.ControlKeys["Walk left"]) && KeyboardInput.KeyboardStateNew.IsKeyUp(Game1.STP.ControlKeys["Walk right"]))
            {
                player.Velocity -= new Vector2(player.Speed.X, 0);
                if (player.Velocity.X < -player.MaxSpeed.X)
                {
                    player.Velocity = new Vector2(-player.MaxSpeed.X, player.Velocity.Y);
                }

                if (player.Resolver.InWater == true)
                {
                    if (player.Resolver.TouchLeft == true)
                    {
                        player.Velocity = new Vector2(player.Velocity.X, -player.MaxSpeed.Y * 2);
                    }
                }

                player.Walking = true;
            }

            if (KeyboardInput.KeyboardStateNew.IsKeyDown(Game1.STP.ControlKeys["Walk right"]) && KeyboardInput.KeyboardStateNew.IsKeyUp(Game1.STP.ControlKeys["Walk left"]))
            {
                player.Velocity += new Vector2(player.Speed.X, 0);

                if (player.Velocity.X > player.MaxSpeed.X)
                {
                    player.Velocity = new Vector2(player.MaxSpeed.X, player.Velocity.Y);
                }

                if (player.Resolver.InWater == true)
                {
                    if (player.Resolver.TouchRight == true)
                    {
                        player.Velocity = new Vector2(player.Velocity.X, -player.MaxSpeed.Y * 2);
                    }
                }

                player.Walking = true;
            }

            if (KeyboardInput.KeyPressed(Game1.STP.ControlKeys["Jump"]))
            {
                if (player.Resolver.InWater == false)
                {
                    if (player.Resolver.TouchTop == true || player.Resolver.TouchTopMovable == true)
                    {
                        Game1.soundjump.Play();
                        player.Velocity = new Vector2(player.Velocity.X, -player.MaxSpeed.Y * 2);
                    }
                }
            }

            if (player.WeaponsAvailable == true)
            {
                if (MouseInput.ScrolledDown())
                {
                    player.PreviousWeapon();
                }

                if (MouseInput.ScrolledUp())
                {
                    player.NextWeapon();
                }
            }

            if (KeyboardInput.KeyPressed(Game1.STP.ControlKeys["Throw grenade"]))
            {
                if (player.WeaponsAvailable == true)
                {
                    ThrowGrenade(player);
                }
            }
        }