// initializing diffrent dependancies. void Start() { rayElevatorPlatform = this.GetComponentInChildren <ElevatorPlatformTrigger>(); elevatorStopped = new StopElevator(); elevatorMovingUp = new ElevatorMoveUp(this); elevatorMovingDown = new ElevatorMovesDown(this); // Our elevator starts in the stopped state; curentState = elevatorStopped; }
// Moves our elevator toward the ElevatorOriginPoint. If the player is on the panel, it will move them as well. // When our elevator reaches it's destination, it moves on to platformHasReachedDestination(); public void moveToDestination(ElevatorPlatformTrigger elevatorPlatform) { elevatorPlatform.transform.position = Vector3.Lerp(elevatorPlatform.transform.position, rayElevator.ElevatorOriginPoint.position, rayElevator.ElevatorSpeed * Time.deltaTime); if (elevatorPlatform.IsPlayerOnElevator) { elevatorPlatform.PlayerOnPlatform.gameObject.transform.position = new Vector3(elevatorPlatform.PlayerOnPlatform.gameObject.transform.position.x, elevatorPlatform.gameObject.transform.position.y + elevatorPlatform.GetComponentInChildren <Collider>().bounds.size.y, elevatorPlatform.PlayerOnPlatform.gameObject.transform.position.z); } if (elevatorPlatform.transform.position.y <= rayElevator.ElevatorOriginPoint.position.y + offset) { platformHasReachedDestination(elevatorPlatform); } }
public void platformHasReachedDestination(ElevatorPlatformTrigger elevatorPlatform) { // This is empty because a stopped elevator has no destination. }
public void moveToDestination(ElevatorPlatformTrigger elevatorPlatform) { // This is empty because we do not want our stopped elevator to move anywhere. }
// changes elevator state to stopped public void platformHasReachedDestination(ElevatorPlatformTrigger elevatorPlatform) { rayElevator.setElevatorState(rayElevator.changeStateToStopped()); }