Added complete lift interaction. Might need some debugging later.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
|
||||
public class ElevatorOuter : MonoBehaviour
|
||||
{
|
||||
public ElevatorBox box;
|
||||
|
||||
public int floor;
|
||||
public Transform boxPos;
|
||||
|
||||
public GameObject leftDoor;
|
||||
public Transform leftDoorOpenPos;
|
||||
public Transform leftDoorClosedPos;
|
||||
|
||||
public GameObject rightDoor;
|
||||
public Transform rightDoorOpenPos;
|
||||
public Transform rightDoorClosedPos;
|
||||
|
||||
private float doorOpenTime = 4f;
|
||||
private float doorCloseTime = 5.6f;
|
||||
|
||||
public ElevatorStatusPlate statusPlate;
|
||||
public AudioSource arrivalBeeper;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
doorOpenTime = box.doorOpenTime;
|
||||
doorCloseTime = box.doorCloseTime;
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Debug.Log("Something entered call area");
|
||||
if (other.GetComponent<XROrigin>() == null && other.GetComponent<KbmController>() == null) return;
|
||||
StartCoroutine(box.callElevator(floor));
|
||||
Debug.Log("Player entered call area");
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
Debug.Log("Something entered call area");
|
||||
if (other.GetComponent<XROrigin>() == null && other.GetComponent<KbmController>() == null) return;
|
||||
box.interestExpired();
|
||||
Debug.Log("Player exited call area");
|
||||
}
|
||||
public void CloseDoors()
|
||||
{
|
||||
StartCoroutine(MoveDoors(leftDoor, leftDoorClosedPos, rightDoor, rightDoorClosedPos, doorCloseTime));
|
||||
|
||||
|
||||
}
|
||||
public void OpenDoors()
|
||||
{
|
||||
arrivalBeeper.Play();
|
||||
Debug.Log("Outer Doors opened");
|
||||
StartCoroutine(MoveDoors(leftDoor, leftDoorOpenPos, rightDoor, rightDoorOpenPos, doorOpenTime));
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator MoveDoors(GameObject left, Transform targetLeft, GameObject right, Transform targetRight, float moveTime)
|
||||
{
|
||||
Vector3 startL = left.transform.position;
|
||||
Vector3 startR = right.transform.position;
|
||||
float t = 0;
|
||||
|
||||
while (t < 1f)
|
||||
{
|
||||
t += Time.deltaTime / moveTime;
|
||||
float easedT = Mathf.SmoothStep(0f, 1f, t); // ease in/out
|
||||
left.transform.position = Vector3.Lerp(startL, targetLeft.position, easedT);
|
||||
right.transform.position = Vector3.Lerp(startR, targetRight.position, easedT);
|
||||
yield return null;
|
||||
}
|
||||
Debug.Log("Outer Doors moved");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user