Esempio n. 1
0
 private void grabInput(InputHandleEvent ihei)
 {
     moveForward  = ihei.upPressed;
     moveBackward = ihei.downPressed;
     strafeLeft   = ihei.leftPressed;
     strafeRight  = ihei.rightPressed;
     sprint       = ihei.sprintPressed;
     jump         = ihei.jumpPressed;
     crouch       = ihei.crouchPressed;
     graple       = ihei.abilityPressed;
 }
Esempio n. 2
0
    //=============================================================================================

    //= Called when the node enters the scene tree for the first time. ============================
    public override void _Ready()
    {
        InputHandleEvent.RegisterListener(grabInput);
        //Make the mouse invisible and not able to leave the window to capture it's movement
        Input.SetMouseMode(Input.MouseMode.Captured);
        //The shape of thte players collision shape
        bodyCollShape = GetNode <CollisionShape>("BodyCollisionShape");
        //The cameras movement gimbal, used for looking mechanics
        grappleRay = GetNode <RayCast>("CameraGimbal/Camera/GrappleRay");
        //Set the ground ray to the raycast in scene
        groundRay = GetNode <RayCast>("GroundCollisionRay");
        //The raycast on the player body that detects cieling collisions
        ceilingRay = GetNode <RayCast>("CeilingCollisionRay");
        //Grab the refference to the cameras gimbals
        cameraGimbal = GetNode <Spatial>("CameraGimbal");
        //Grab the refference to the camera
        camera = GetNode <Camera>("CameraGimbal/Camera");
        //Set the grappel line to the emediate geometry object on the player
        grappleLine = GetNode <DrawGrappleLine>("GrappleLine");
    }
Esempio n. 3
0
    public override void _UnhandledInput(Godot.InputEvent @event)
    {
        ihei = new InputHandleEvent();
        if (@event is InputEventMouseButton eventMouseButton)
        {
            if (eventMouseButton.Pressed)
            {
                if (eventMouseButton.ButtonIndex == (int)ButtonList.Left)
                {
                    ihei.lmbPressed = true;
                }
                if (eventMouseButton.ButtonIndex == (int)ButtonList.Right)
                {
                    ihei.rmbPressed = true;
                }
            }
            else
            {
                if (eventMouseButton.ButtonIndex == (int)ButtonList.Left)
                {
                    ihei.lmbPressed = false;
                }
                if (eventMouseButton.ButtonIndex == (int)ButtonList.Right)
                {
                    ihei.rmbPressed = false;
                }
            }
        }

        if (Input.IsKeyPressed((int)KeyList.W))
        {
            ihei.upPressed = true;
        }
        else
        {
            ihei.upPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.S))
        {
            ihei.downPressed = true;
        }
        else
        {
            ihei.downPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.A))
        {
            ihei.leftPressed = true;
        }
        else
        {
            ihei.leftPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.D))
        {
            ihei.rightPressed = true;
        }
        else
        {
            ihei.rightPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.Space))
        {
            ihei.jumpPressed = true;
        }
        else
        {
            ihei.jumpPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.Control))
        {
            ihei.crouchPressed = true;
        }
        else
        {
            ihei.crouchPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.Shift))
        {
            ihei.sprintPressed = true;
        }
        else
        {
            ihei.sprintPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.E))
        {
            ihei.abilityPressed = true;
        }
        else
        {
            ihei.abilityPressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.Q))
        {
            ihei.consolePressed = true;
        }
        else
        {
            ihei.consolePressed = false;
        }
        if (Input.IsKeyPressed((int)KeyList.Escape))
        {
            ihei.escapePressed = true;
        }
        else
        {
            ihei.escapePressed = false;
        }

        // if (@event is InputEventKey eventKey)
        // {
        //     if (eventKey.Pressed)
        //     {
        //         if (eventKey.Scancode == (int)KeyList.W) ihei.upPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.S) ihei.downPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.A) ihei.leftPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.D) ihei.rightPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.Space) ihei.jumpPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.C) ihei.crouchPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.Shift) ihei.sprintPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.E) ihei.abilityPressed = true;
        //         if (eventKey.Scancode == (int)KeyList.Q) ihei.consolePressed = true;
        //     }
        //     else
        //     {
        //         if (eventKey.Scancode == (int)KeyList.W) ihei.upPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.S) ihei.downPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.A) ihei.leftPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.D) ihei.rightPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.Space) ihei.jumpPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.C) ihei.crouchPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.Shift) ihei.sprintPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.E) ihei.abilityPressed = false;
        //         if (eventKey.Scancode == (int)KeyList.Q) ihei.consolePressed = false;
        //     }
        // }
        ihei.FireEvent();
    }