示例#1
0
    /**
     * On awake we initialize our controls to tell it what to do with each
     *
     */
    private void Awake()
    {
        controls = new PlayerControls();    // Initialize our controls object

        // Move is controlled with our left stick or keyboard being a 2d plane for direction so save that vector2 as move
        controls.Gameplay.Move.performed += ctx => move = ctx.ReadValue <Vector2>();
        controls.Gameplay.Move.canceled  += ctx => move = Vector2.zero;             //Not moving anymore so set that vector2 to 0


        controls.Gameplay.Jump.performed += ctx => Jump();                    // In jump context call the jump function
        controls.Gameplay.Dash.performed += ctx => initiateDash();            //Similar for dashing
        //controls.Gameplay.Fire.performed += ctx => useWeapons();
        controls.Gameplay.Tool.performed           += ctx => initiateTool(1); //this is meant for your standard attack (the stick)
        controls.Gameplay.Tool2.performed          += ctx => initiateTool(2); //this is meant for your secondary attack (the gun)
        controls.Gameplay.Tool3.performed          += ctx => initiateTool(3); //this is meant for offensive items (grenades)
        controls.Gameplay.Tool4.performed          += ctx => initiateTool(4); //this is meant for support items (estus stimpaks)
        controls.Gameplay.ChangeViewMode.performed += ctx => changeViewMode();
        controls.Gameplay.CycleWeapon.performed    += ctx => cycleWeapon();

        controls.Gameplay.Pickup.performed += ctx => PickupMessage();
        controls.Gameplay.Block.performed  += ctx => startBlock();
        controls.Gameplay.Block.canceled   += ctx => endBlock();
        controls.Gameplay.Sprint.performed += ctx => Sprint();
        controls.Gameplay.Sprint.canceled  += ctx => endSprint();
        controls.Gameplay.Crouch.performed += ctx => crouch();
        controls.Gameplay.Crouch.canceled  += ctx => endCrouch();

        reticle       = GameObject.Find("/Main Camera/Canvas/Reticle");
        retController = reticle.GetComponent <reticleController>();
    }
示例#2
0
    private void Awake()
    {
        cameraMain      = Camera.main.transform;
        reticle         = GameObject.Find("/Main Camera/Canvas/Reticle");
        Reticle         = reticle.transform;
        retController   = reticle.GetComponent <reticleController>();
        crossHairpieces = reticle.GetComponentsInChildren <Image>();
        controls        = new PlayerControls();
        cineCam         = GetComponent <CinemachineFreeLook>();
        // set to initalize look with mouse or right thumbstick
        controls.Gameplay.Look.performed += ctx => rotate = ctx.ReadValue <Vector2>();
        controls.Gameplay.Look.canceled  += ctx => rotate = Vector2.zero;

        controls.Gameplay.Aim.performed += ctx => zoomIn();
        controls.Gameplay.Aim.canceled  += ctx => zoomOut();
    }