Ejemplo n.º 1
0
Archivo: Player.cs Proyecto: alvj/MPV-3
    public FPlayerSaveState GetSaveState()
    {
        int     sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
        Vector3 position   = transform.position;


        return(new FPlayerSaveState(position, HealthReference.GetCurrentLife(), sceneIndex));
    }
Ejemplo n.º 2
0
Archivo: Player.cs Proyecto: alvj/MPV-3
    protected override void Update()
    {
        if (HealthReference.IsDead)
        {
            return;
        }

        if (Input.GetButtonDown("Inventory"))
        {
            if (PauseMenu.IsOpen)
            {
                PauseMenu.CloseMenu();
            }
            else
            {
                PauseMenu.ShowMenu();
            }
        }



        if (PauseMenu.IsOpen)
        {
            return;
        }

        //=========================================
        if (Input.GetKeyDown(KeyCode.Space))
        {
            print("Aplicando bomba nuclear >:)");
            HealthReference.Damage(int.MaxValue);
        }
        //=========================================

        bAimingActive = Input.GetMouseButton(1);
        bIsRunning    = Input.GetKey(KeyCode.LeftShift);

        if (Input.GetMouseButtonDown(1))
        {
            _nextCanShoot = Time.time + 1 / _aimingVelocity;

            weaponIKPosition = _weaponDirection.position + transform.forward * _distanceIK;
        }

        //Camera control
        _playerCamera.SetActive(!bAimingActive);

        //Cursor visibility
        Cursor.visible   = bAimingActive;
        Cursor.lockState = bAimingActive ? CursorLockMode.Confined : CursorLockMode.Locked;

        //Movement and rotation control
        float verticalAxis   = Input.GetAxis("Vertical") * (bAimingActive ? 0 : 1);
        float horizontalAxis = Input.GetAxis("Horizontal") * (bAimingActive ? 0 : 1);

        Vector3 forwardXZ   = Vector3.ProjectOnPlane(Camera.main.transform.forward, Vector3.up);
        Vector3 rightXZ     = Vector3.ProjectOnPlane(Camera.main.transform.right, Vector3.up);
        Vector3 directionXZ = forwardXZ * verticalAxis
                              + rightXZ * horizontalAxis;

        _controller.SimpleMove(directionXZ * (bIsRunning ? _velocityRunMovement : _velocityWalkMovement));

        Vector3 localDirection = transform.InverseTransformDirection(_controller.velocity);

        _animator.SetFloat("MovX", localDirection.x);
        _animator.SetFloat("MovY", localDirection.z);

        if (Mathf.Abs(verticalAxis) > 0 || Mathf.Abs(horizontalAxis) > 0)
        {
            transform.rotation = Quaternion.LookRotation(forwardXZ);
        }

        UpdateLayerAimWeight();
        UpdateAttack();

        _animator.SetFloat("Velocity", Vector3.ProjectOnPlane(_controller.velocity, Vector3.up).magnitude);
    }
Ejemplo n.º 3
0
Archivo: Player.cs Proyecto: alvj/MPV-3
 public void ApplySaveState(FPlayerSaveState saveState)
 {
     transform.position = new Vector3(saveState.x, saveState.y, saveState.z);
     HealthReference.SetCurrentLife(saveState._currentHealth);
 }