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) { if (ppc.FindCollision("water")) { ppc.SetState(PlayerAbovewaterState); return; } ppc.move = Vector2.zero; ppc.move.x = SwimmerInput.GetAxis("Horizontal"); }
void Awake() { if (instance == null) { instance = this; } mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); float widthAdjustment = mainCamera.pixelWidth / 2.0f; float heightAdjustment = mainCamera.pixelHeight / 2.0f; instance.leftMoveData = new ButtonData(leftMovementImage, widthAdjustment, heightAdjustment); instance.leftJumpData = new ButtonData(leftJumpImage, widthAdjustment, heightAdjustment); instance.rightMoveData = new ButtonData(rightMovementImage, widthAdjustment, heightAdjustment); instance.rightJumpData = new ButtonData(rightJumpImage, widthAdjustment, heightAdjustment); touchList = new Touch[10]; }
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; } }