Beispiel #1
0
    public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity)
    {
        ppc.move   = Vector2.zero;
        ppc.move.x = SwimmerInput.GetAxis("Horizontal");
        if (SwimmerInput.GetButtonDown("Jump"))
        {
            velocity.y = ppc.jumpTakeOffSpeed;
            ppc.SetState(playerUnderwaterState);
        }
        else if (velocity.y < -0.01f)  //if we've just walked off a ledge
        {
            ppc.SetState(playerUnderwaterState);
        }

        if (!isWalking && Mathf.Abs(ppc.move.x) > 0.01f)
        {
            Debug.Log("Broadcasting Walking-OnRiverbed Event!");
            WalkingOnRiverbedEvent.Raise();
            isWalking = !isWalking;
        }
        else if (isWalking && Mathf.Abs(ppc.move.x) < 0.01f)
        {
            Debug.Log("Broadcasting Standing Still on Riverbed Event!");
            StillOnRiverbedEvent.Raise();
            isWalking = !isWalking;
        }
    }
 public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity)
 {
     ppc.move   = Vector2.zero;
     ppc.move.x = SwimmerInput.GetAxis("Horizontal");
     if (ppc.exhausted)
     {
         return;
     }
     if (SwimmerInput.GetButtonDown("Jump"))
     {
         Debug.Log("Jumping!");
         velocity.y = ppc.jumpTakeOffSpeed;
         ppc.animator.SetTrigger("strokePerformed");
         StrokeEvent.Raise();
         AbovewaterStrokeEvent.Raise();
     }
     if (ppc.headCollider.IsTouching(ppc.waterCollider))
     {
         ppc.SetState(UnderwaterState);
     }
     if (ppc.FindCollision("Ledge"))
     {
         ppc.GetLedgeInfo(ppc.move);
         if (ppc.ledgeType == PlayerPlatformController.LEDGE.NONE)
         {
             return;
         }
         ppc.SetState(LedgeHangState);
     }
 }
 public override void ComputeVelocity(PlayerPlatformController ppc, ref Vector2 velocity)
 {
     velocity.y = 0.0f;
     velocity.x = 0.0f;
     if ((SwimmerInput.GetKeyDown(KeyCode.A) && ppc.ledgeType == PlayerPlatformController.LEDGE.LEFT) ||
         (SwimmerInput.GetKeyDown(KeyCode.D) && ppc.ledgeType == PlayerPlatformController.LEDGE.RIGHT) ||
         SwimmerInput.GetKeyDown(KeyCode.S))
     {
         ppc.animator.SetTrigger("grabbedLedge");
         ppc.SetState(UnderwaterSwimState);
         return;
     }
     else if (SwimmerInput.GetButtonDown("Jump"))
     {
         //velocity.y = ppc.jumpTakeOffSpeed;
         ppc.SetState(LedgeClimbingState);
         return;
     }
 }