public void JumpTo(Lane targetLane) { Vector3 targetPosition; if (targetLane != null) { targetPosition = targetLane.GetJumpDestinationFrom(transform.position); targetPosition.z += currentSpeed * jumpDuration; KillEnemyAtJumpDestination(targetLane, targetPosition); } else { // Temp targetPosition = transform.position + Vector3.right * 3f; targetPosition.z += currentSpeed * jumpDuration; } currentJumpAnimation = new PlayerJump(transform, targetPosition, jumpPower, jumpDuration) .OnComplete(() => { currentJumpAnimation = null; isJumping = false; representation.location.laneA = targetLane; representation.location.laneB = null; representation.location.isMovingBetweenLanes = false; representation.location.isAboveLane = false; }); isJumping = true; wasJumpPressedDuringJump = false; previousJumpStartTime = Time.unscaledTime; if (currentPlatformRepresentation != null) { previousPlatform = currentPlatformRepresentation; } representation.location.laneB = targetLane; representation.location.isMovingBetweenLanes = currentLane && currentLane != targetLane; representation.location.isAboveLane = true; PlayJumpSound(); if (targetLane == currentLane.leftNeighbor) { animator.SetTrigger("Jump_L"); } else if (targetLane == currentLane.rightNeighbor) { animator.SetTrigger("Jump_R"); } else if (targetLane == currentLane) { animator.SetTrigger("Jump_F"); } else { animator.SetTrigger("Jump_R"); // TEMP. Jump to a null lane is right by default. } }
private void MoveTo(Lane targetLane) { Assert.IsNotNull(targetLane); Vector3 targetPosition = targetLane.GetJumpDestinationFrom(transform.position); transform .DOMove(targetPosition, moveDuration) .SetEase(Ease.InOutQuart) .OnComplete(() => { representation.location.laneA = targetLane; representation.location.laneB = null; representation.location.isMovingBetweenLanes = false; isPlayingAnimation = false; moveCountdown = moveInterval; }); representation.location.laneB = targetLane; representation.location.isMovingBetweenLanes = true; }
private void JumpTo(Lane targetLane) { Assert.IsNotNull(targetLane); Vector3 targetPosition = targetLane.GetJumpDestinationFrom(transform.position); transform .DOJump(targetPosition, jumpPower, 1, jumpDuration) .OnComplete(() => { isJumping = false; representation.location.laneA = targetLane; representation.location.laneB = null; representation.location.isMovingBetweenLanes = false; representation.location.isAboveLane = false; }); isJumping = true; representation.location.laneB = targetLane; representation.location.isMovingBetweenLanes = currentLane && currentLane != targetLane; representation.location.isAboveLane = true; }