IEnumerator GetToDestination(float height, ShaftDoors shaftDoors) { Vector3 desiredPosition = new Vector3(transform.position.x, height, transform.position.z); while (Vector3.Distance(transform.position, desiredPosition) > 0.10f) { transform.position = Vector3.MoveTowards(transform.position, desiredPosition, elevatorSpeed * Time.deltaTime); yield return(null); } GameController.instance.SetFloor((int)destinationFloorNumber); currentFloorNumber = destinationFloorNumber; }
IEnumerator CallElevatorCoroutine(uint floor, float height, ShaftDoors shaftDoors) { //wait for doors to close on the current floor yield return(StartCoroutine(ClosePreviousElevatorDoors())); destinationFloorNumber = floor; //if elevator is already on the current floor, just open the doors if (currentFloorNumber == floor) { Debug.Log("Elevator is on the current floor. Opening doors!"); shaftDoors.Open(); } else { //wait for elevator to arrive yield return(StartCoroutine(GetToDestination(height, shaftDoors))); shaftDoors.Open(); } Debug.Log("Please Enter"); }
public void SetValues(uint f, float h, ShaftDoors d) { floor = f; height = h; door = d; }
private void CallElevator(uint floor, float height, ShaftDoors shaftDoors) { StartCoroutine(CallElevatorCoroutine(floor, height, shaftDoors)); }