示例#1
0
 public void AddPickUp(Texture2D texture, Vector2 position, PlayerObjectMode playerMode)
 {
     PickUpObj obj = new PickUpObj(texture, position);
     obj.playerTangible = playerMode;
     obj.playerVisible = playerMode;
     obj.SetCollisionBox(22, 22, Vector2.Zero);
     pickUpList.Add(obj);
 }
示例#2
0
        public override void Update()
        {
            ChangeSprite();

            thumb = Vector2.Zero;

            prevActionDown = actionDown;

            rightDown = false;
            leftDown = false;
            upDown = false;
            downDown = false;
            jumpDown = false;
            jumpPressed = false;
            jumpReleased = false;
            actionDown = false;
            actionPressed = false;
            signalPressed = false;
            superDown = false;
            GetInput();

            if (pushTarget == null) runningSpeed = runningSpeedConst;

            if (leftDown)
            {
                if (!IsTopRunningSpeed(false)) force.X += -moveForce;
                else SlowX();
                facing = Facing.Left;
                leftDown = true;
            }
            else if (rightDown)
            {
                if (!IsTopRunningSpeed(true)) force.X += moveForce;
                else SlowX();
                facing = Facing.Right;
                rightDown = true;
            }
            else if (thumb.X > 0)
            {
                if (!IsTopRunningSpeed(true)) force.X += moveForce * Math.Abs(thumb.X);
                else SlowX();
                facing = Facing.Right;
                rightDown = true;
            }
            else if (thumb.X < 0)
            {
                if (!IsTopRunningSpeed(false)) force.X += -moveForce * Math.Abs(thumb.X);
                else SlowX();
                facing = Facing.Left;
                leftDown = true;
            }
            else SlowX();

            if (actionDown)
            {
                grabbing = true;
                pushing = true;
                psyHold = true;
            }

            pressing = false;
            if (actionPressed)
            {
                pressing = true;
                AudioManager.playerPsyActivate.Play();
            }

            if (!actionDown && prevActionDown)
            {
                AudioManager.playerPsyDeactivate.Play();
            }

            if (signalPressed && !isSignaling)
            {
                ActivateSignal();
            }
            if (isSignaling)
            {
                signalCounter += Time.GetSeconds();
                if (signalCounter >= signalRate)
                {
                    DeactivateSignal();
                }
            }

            if (ableToPressDrop)
            {
                if (dropCounter >= dropRate)
                {
                    ignoreOneWay = false;
                }
                else dropCounter++;
            }

            if (!actionDown)
            {
                psyHold = false;
                grabbing = false;
                pushing = false;
                if (holding)
                {
                    holding = false;
                    Vector2 throwSpeed = new Vector2(0, -10);
                    //if (upDown) throwSpeed.Y = -10;
                    //if (downDown) throwSpeed.Y = 10;
                    //if (rightDown) throwSpeed.X = 10;
                    //if (leftDown) throwSpeed.X = -10;

                    if (facing == Facing.Right) throwSpeed.X = 10;
                    if (facing == Facing.Left) throwSpeed.X = -10;

                    if (downDown)
                    {
                        if (rightDown || leftDown) throwSpeed.Y = 10;
                        else throwSpeed = Vector2.Zero;
                    }

                    pickUp.GetDropped(throwSpeed);
                    pickUp = null;
                }
            }

            if (downDown && jumpDown)
            {
                ignoreOneWay = true;
                ableToPressDrop = true;
                dropCounter = 0;
            }

            bool downNotBeingPressed = false;

            if (!GameStateManager.isMultiplayer)
                downNotBeingPressed = InputManager.IsButtonUp(Buttons.DPadDown) && InputManager.IsKeyUp(Keys.S) && !superDown;
            else
            {
                if (playerObjectMode == PlayerObjectMode.One)
                    downNotBeingPressed = InputManager.IsButtonUp(Buttons.DPadDown) && InputManager.IsKeyUp(Keys.S) && !superDown;
                else
                    downNotBeingPressed = InputManager.IsButtonUp2(Buttons.DPadDown) && InputManager.IsKeyUp(Keys.S) && !superDown;
            }

            if (jumpPressed && state == PhysState.Grounded && downNotBeingPressed) //TODO: uncomment
            //if (jumpPressed && downNotBeingPressed) //This be the not correct
            {
                force.Y += jumpForce;
                isJumping = true;
                jumpingLegacy = true;
                AudioManager.playerJump.Play();

            }
            if (jumpDown)
            {

                if (isJumping)
                {
                    force.Y += jumpForce;
                    jumpCounter++;
                    if (jumpCounter >= jumpRate)
                    {
                        StopJump(); //TODO: uncomment
                    }
                }
            }
            if (jumpReleased)
            {
                if (isJumping)
                {
                    StopJump();
                }
            }

            if (light != null) psyHold = true;

            base.Update();
            grabBox.SetPosition(hitBox.GetPosition());
            Level.CheckForPlayerStuff(this);

            if (hitBox.Bottom() < 0 || hitBox.Top() > Level.levelHeight || hitBox.Right() < 0 || hitBox.Left() > Level.levelWidth)
            {

            }
        }
示例#3
0
 public PickUpObj AddBouncyBall(float bounceMultiplier, Texture2D texture, Vector2 position, PlayerObjectMode playerMode)
 {
     PickUpObj obj = new PickUpObj(bounceMultiplier, texture, position);
     obj.playerTangible = playerMode;
     obj.playerVisible = playerMode;
     pickUpList.Add(obj);
     pickUpAuras.Add(new GaussianTargets(gameStateManager.game.GraphicsDevice));
     obj.SetCollisionBox(22, 22, Vector2.Zero);
     return obj;
 }
示例#4
0
        public void CheckForGrab(PickUpObj obj)
        {
            if (playerTangible != PlayerObjectMode.None && obj.playerTangible != PlayerObjectMode.None)
            {
                if (playerTangible != obj.playerTangible) return;
            }

            if (hitBox.CheckCollision(obj.hitBox))
            {
                if (CheckForAlreadyHeld()) return;
                if (obj.parent != null) return;
                if (grabbing)
                {
                    obj.GetPickedUp(this);
                    grabbing = false;
                    holding = true;
                    //obj.psyHold = true;
                }
            }
            else
            {
                if (pickUp == obj)
                {
                    obj.GetDropped(Vector2.Zero);
                    holding = false;
                }
            }
        }