Ejemplo n.º 1
0
    // 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;
    }
Ejemplo n.º 2
0
    // 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);
        }
    }
Ejemplo n.º 3
0
 public void platformHasReachedDestination(ElevatorPlatformTrigger elevatorPlatform)
 {
     // This is empty because a stopped elevator has no destination.
 }
Ejemplo n.º 4
0
 public void moveToDestination(ElevatorPlatformTrigger elevatorPlatform)
 {
     // This is empty because we do not want our stopped elevator to move anywhere.
 }
Ejemplo n.º 5
0
 // changes elevator state to stopped
 public void platformHasReachedDestination(ElevatorPlatformTrigger elevatorPlatform)
 {
     rayElevator.setElevatorState(rayElevator.changeStateToStopped());
 }