Ejemplo n.º 1
0
 private void CheckLeftTrigger()
 {
     if (state.Triggers.Left > PlayerPrefs.GetFloat("REU_Trigger_Treshold", triggerTreshold))
     {
         leftTriggerWaitForRelease = true;
         if (dashUsed == false && !reviving)
         {
             if (revivablePlayers.Count <= 0)
             {
                 Vector3 dashDirection = moveInput;
                 if (moveInput.magnitude <= 0)
                 {
                     dashDirection = transform.forward;
                 }
                 dashController.Dash(dashDirection);
                 dashUsed = true;
             }
             else if (!rightTriggerWaitForRelease)
             {
                 dashBuffer += Time.deltaTime;
                 if (dashBuffer >= delayBeforeDash)
                 {
                     Vector3 dashDirection = moveInput;
                     if (moveInput.magnitude <= 0)
                     {
                         dashDirection = transform.forward;
                     }
                     dashController.Dash(dashDirection);
                     dashUsed = true;
                 }
             }
         }
     }
     else
     {
         if (leftTriggerWaitForRelease)
         {
             if (revivablePlayers.Count > 0 && dashBuffer < delayBeforeDash && !reviving)
             {
                 Vector3 dashDirection = moveInput;
                 if (moveInput.magnitude <= 0)
                 {
                     dashDirection = transform.forward;
                 }
                 dashController.Dash(dashDirection);
             }
             dashBuffer = 0;
             dashUsed   = false;
             leftTriggerWaitForRelease = false;
         }
     }
 }
Ejemplo n.º 2
0
    //dont use get axis because when releasing button it still has non zero values (coz it floatz)

    // the Update loop contains a very simple example of moving the character around and controlling the animation
    void Update()
    {
        if (!this.isLocalPlayer)
        {
            return;
        }

        directionalInput = new Vector2(horizontalInputAction.ReadValue <float>(), verticalInputAction.ReadValue <float>());

        if (dashController.isDashing)
        {
            _controller.move(dashController.velocity * Time.deltaTime);
        }
        else
        {
            if (dashController.HandleDash())
            {
                StartCoroutine(dashController.Dash(new GetDirectionalInputDelegate(GetDirectionalInput)));
            }

            _velocity = movementController.HandleMovement(directionalInput, jumpInputAction.ReadValue <float>() > 0);

            _controller.move(_velocity * Time.deltaTime);
        }


        _velocity = _controller.velocity;
        FaceMovementDirection();

        animator.SetFloat("speed", Mathf.Abs(_velocity.x));
        animator.SetFloat("jumpSpeed", _velocity.y);
    }
Ejemplo n.º 3
0
    void Update()
    {
        pawnController.animator.SetFloat("ForwardBlend", pawnController.GetCurrentSpeed() / pawnController.pawnMovementValues.moveSpeed);
        pawnController.animator.SetFloat("SideBlend", 0);
        switch (ghostType)
        {
        case GhostType.Moving:
            pawnController.canMove   = true;
            pawnController.moveInput = CurrentDirection * SpeedGhost;
            pawnController.lookInput = CurrentDirection;
            pawnController.UpdateAnimatorBlendTree();
            if (currentCooldown <= 0)
            {
                currentCooldown = actionCooldown;
                if (CurrentDirection == Direction1)
                {
                    CurrentDirection = Direction2;
                }
                else
                {
                    CurrentDirection = Direction1;
                }
            }
            else
            {
                currentCooldown -= Time.deltaTime;
            }

            break;

        case GhostType.Dashing:

            pawnController.canMove   = true;
            pawnController.lookInput = CurrentDirection;
            pawnController.moveInput = CurrentDirection * SpeedGhost;
            pawnController.UpdateAnimatorBlendTree();

            if (currentCooldown <= 0)
            {
                dashController.RecoverAllStackAmount();
                dashController.Dash(CurrentDirection);
                pawnController.lookInput = CurrentDirection;
                currentCooldown          = actionCooldown;
                if (CurrentDirection == Direction1)
                {
                    CurrentDirection = Direction2;
                }
                else
                {
                    CurrentDirection = Direction1;
                }
            }
            else
            {
                currentCooldown -= Time.deltaTime;
            }
            break;

        case GhostType.Passing:
            pawnController.canMove = false;
            if (currentCooldown <= 0)
            {
                transform.LookAt(passTarget.transform.position);
                passController.Shoot();
                currentCooldown = actionCooldown;
            }
            else
            {
                passController.Aim();
                // passController.SetLookDirection(Vector3.MoveTowards(transform.position,passTarget.transform.position, 100));
                currentCooldown -= Time.deltaTime;
            }
            break;

        case GhostType.CurvedPassing:
            pawnController.canMove = false;
            if (currentCooldown <= 0)
            {
                transform.LookAt(passTarget.transform.position);
                passController.Shoot();
                currentCooldown = actionCooldown;
                curvedCooldown  = 0;
            }
            else
            {
                passController.Aim();
                curvedCooldown += Time.deltaTime;
                passController.SetLookDirection(new Vector3(0.2f, 0, -curvedCooldown * 0.2f));
                // passController.SetLookDirection(Vector3.MoveTowards(transform.position,passTarget.transform.position, 100));
                currentCooldown -= Time.deltaTime;
            }
            break;

        case GhostType.Dunk:

            pawnController.canMove = false;
            if (currentCooldown <= 0.5f && myDunkType == DunkType.Dunking && jumpCooldown && !passController.CanShoot())
            {
                dunkController.ForceDunk();
                jumpCooldown = false;
            }
            if (currentCooldown <= 0 && passTarget != null)
            {
                transform.LookAt(passTarget.transform.position);
                passController.Shoot();
                currentCooldown = actionCooldown;
                jumpCooldown    = true;
            }
            else
            {
                passController.Aim();
                // passController.SetLookDirection(Vector3.MoveTowards(transform.position,passTarget.transform.position, 100));
                currentCooldown -= Time.deltaTime;
            }

            break;
        }
    }