Example #1
0
        // Update player
        public override void Update(GameTime gameTime)
        {
            // Do start update things
            StartUpdate();

            // Normalized vector
            if (GameInput.ControllerMode)
            {
                //norm = MyMaths.Normalize(GameControlls.LeftStickX, GameControlls.LeftStickY);
                norm.X = GameInput.LeftStickX;
                norm.Y = GameInput.LeftStickY;
                if (Math.Abs(norm.X) > 0.70f || Math.Abs(norm.Y) > 0.70f)
                {
                    norm = MyMaths.Normalize(GameInput.LeftStickX, GameInput.LeftStickY);
                }
            }
            else
            {
                norm = MyMaths.Normalize((GameInput.RightCD ? 1 : 0) - (GameInput.LeftCD ? 1 : 0), (GameInput.DownCD ? 1 : 0) - (GameInput.UpCD ? 1 : 0));
            }

            // Do movement if no cutscene
            if (!GahameController.CutScene)
            {
                // Horizontal speed
                if (GameInput.RightCD || GameInput.LeftCD)
                {
                    // le nice walk horizontal thing
                    WalkHorizontal(maxSpeed * norm.X);
                }

                // Vertical speed
                if (GameInput.UpCD || GameInput.DownCD)
                {
                    // le nice walk horizontal thing
                    WalkVertical(maxSpeed * norm.Y);
                }
            }

            // Activate Object
            if (GameInput.ActivateCD)
            {
                // Insane
                if (hitBox.InstancePlace <ActivatableObject>(Position + direction) is ActivatableObject o)
                {
                    o.Activate();
                }
                else
                {
                    Dialogue d = hitBox.DialogueMeeting(Position + direction);
                    if (d != null)
                    {
                        d.StartDialogue();
                    }
                }

                screen.ScreenEffects.Add(new CameraShakeEffect(screen, 4, 20));
            }

            // Update component last
            base.Update(gameTime);
        }
        // Update stufferino
        public override void Update(GameTime gameTime)
        {
            // Start updateing
            StartUpdate();

            // Im sorry my child
            if (!GahameController.CutScene)
            {
                // Walking left and right
                if (!GameInput.InputDown(GameInput.stopInput))
                {
                    if (GameInput.ControllerMode)
                    {
                        if (GameInput.PlatformerMovementStickX != 0)
                        {
                            WalkHorizontal(GameInput.PlatformerMovementStickX * maxSpeed);
                        }
                    }
                    else
                    {
                        bool rightKey = GameInput.InputDown(GameInput.RightKey);
                        bool leftKey  = GameInput.InputDown(GameInput.LeftKey);
                        if (rightKey || leftKey)
                        {
                            WalkHorizontal(((rightKey ? 1 : 0) - (leftKey ? 1 : 0)) * maxSpeed);
                        }
                    }
                }

                // Jumping
                jumpBuffer--;
                if (GameInput.InputPressed(GameInput.JumpInput))
                {
                    jumpBuffer = 3;
                }
                if (jumpBuffer > 0)
                {
                    Jump();
                }

                // Stop Jump things
                //Jumping = GameInput.JumpHeld;
                Jumping = GameInput.InputDown(GameInput.JumpInput);

                // Stop jump
                if (!GameInput.InputDown(GameInput.JumpInput))
                {
                    StopJump();
                }

                // Interact with object
                if (GameInput.ActivateCD)
                {
                    Dialogue d = hitBox.DialogueMeeting(Position + new Vector2(imageScale, 0));
                    if (d != null)
                    {
                        d.StartDialogue();
                    }
                }
            }

            // I dont even know anymore
            base.Update(gameTime);

            if (!physics.Grounded)
            {
                spriteManager.ChangeSprite("Jumping");
            }

            spriteManager.ChangeScaleOnAllSprites(new Vector2(imageScale, 1));
        }