Esempio n. 1
0
        public Player(Vector2 position)
            : base(position)
        {
            this.Tag((int)GameTags.Player);
            this.Collider = new Hitbox((float)20.0f, (float)32.0f, -10.0f, -16.0f);
            this.Visible  = true;

            player = new AnimationPlayer();

            downTexture  = Engine.Instance.Content.Load <Texture2D>("Player/DrifterDown");
            upTexture    = Engine.Instance.Content.Load <Texture2D>("Player/DrifterUp");
            leftTexture  = Engine.Instance.Content.Load <Texture2D>("Player/DrifterLeft");
            rightTexture = Engine.Instance.Content.Load <Texture2D>("Player/DrifterRight");


            downAnimationData  = new AnimationData(downTexture, 60, 32, true);
            upAnimationData    = new AnimationData(upTexture, 60, 32, true);
            leftAnimationData  = new AnimationData(leftTexture, 60, 32, true);
            rightAnimationData = new AnimationData(rightTexture, 60, 32, true);

            vertical  = Vertical.None;
            horizonal = Horizonal.None;

            player.PlayAnimation(downAnimationData);

            Camera.CameraTrap = new Rectangle((int)this.Right, (int)this.Bottom - 40, 40, 40);
        }
Esempio n. 2
0
        private void Input()
        {
            InputMode();

            if (controllerMode == true)
            {
                if (PolyInput.GamePads[0].LeftStickHorizontal(0.3f) > 0.4f ||
                    PolyInput.GamePads[0].DPadRightCheck == true)
                {
                    horizonal = Horizonal.Right;
                }
                else if (PolyInput.GamePads[0].LeftStickHorizontal(0.3f) < -0.4f ||
                         PolyInput.GamePads[0].DPadLeftCheck == true)
                {
                    horizonal = Horizonal.Left;
                }
                else
                {
                    horizonal = Horizonal.None;
                }

                if (PolyInput.GamePads[0].LeftStickVertical(0.3f) > 0.4f ||
                    PolyInput.GamePads[0].DPadUpCheck == true)
                {
                    vertical = Vertical.Up;
                }
                else if (PolyInput.GamePads[0].LeftStickVertical(0.3f) < -0.4f ||
                         PolyInput.GamePads[0].DPadDownCheck == true)
                {
                    vertical = Vertical.Down;
                }
                else
                {
                    vertical = Vertical.None;
                }
            }
            else if (keyboardMode == true)
            {
                if (PolyInput.Keyboard.Check(Keys.Right) ||
                    PolyInput.Keyboard.Check(Keys.D))
                {
                    horizonal = Horizonal.Right;
                }
                else if (PolyInput.Keyboard.Check(Keys.Left) ||
                         PolyInput.Keyboard.Check(Keys.A))
                {
                    horizonal = Horizonal.Left;
                }
                else
                {
                    horizonal = Horizonal.None;
                }

                if (PolyInput.Keyboard.Check(Keys.Up) ||
                    PolyInput.Keyboard.Check(Keys.W))
                {
                    vertical = Vertical.Up;
                }
                else if (PolyInput.Keyboard.Check(Keys.Down) ||
                         PolyInput.Keyboard.Check(Keys.S))
                {
                    vertical = Vertical.Down;
                }
                else
                {
                    vertical = Vertical.None;
                }
            }
        }