72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
public class OfficeTimelineControl : MonoBehaviour
|
|
{
|
|
private PlayableDirector mPlayableDirector;
|
|
|
|
//过场动画所用的玩家模型
|
|
public GameObject playerModel;
|
|
//public GameObject playerController;
|
|
public GameObject aniCamera;
|
|
private Transform door;
|
|
|
|
// Start is called before the first frame update
|
|
private async void Start()
|
|
{
|
|
door = transform.GetChild(0);
|
|
await Task.Delay(1);
|
|
mPlayableDirector = GetComponent<PlayableDirector>();
|
|
door.localEulerAngles = new Vector3(0f, 62.853f, 0f);
|
|
if (!GameManager.RunModelMgr.isOnceOfficeAni)
|
|
{
|
|
mPlayableDirector.Play();
|
|
GameManager.RunModelMgr.isOnceOfficeAni = true;
|
|
GameManager.RunModelMgr.isAniOver = false;
|
|
Debug.Log("GameManager.RunModelMgr.isOnceOfficeAni false" + GameManager.RunModelMgr.isAniOver);
|
|
}
|
|
else
|
|
{
|
|
mPlayableDirector.initialTime = 0;
|
|
Debug.Log("GameManager.RunModelMgr.isOnceOfficeAni true" + GameManager.RunModelMgr.isAniOver);
|
|
DestroyPlayer();
|
|
}
|
|
}
|
|
private void Update()
|
|
{
|
|
#if UNITY_EDITOR
|
|
if (Input.GetKeyDown("p"))
|
|
{
|
|
mPlayableDirector.Stop();
|
|
DestroyPlayer();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/// <summary>
|
|
/// 外挂到场景中得timeline
|
|
/// </summary>
|
|
public void OnPlayableDirectorStopped()
|
|
{
|
|
GameManager.EventMgr.EventTrigger(Enum_EventType.OfficeTimeLineOver);
|
|
Invoke("DestroyPlayer", 1f);
|
|
}
|
|
|
|
private void DestroyPlayer()
|
|
{
|
|
GameManager.EventMgr.EventTrigger(Enum_EventType.InitializationUI);
|
|
GameManager.RunModelMgr.isAniOver = true;
|
|
door.localEulerAngles = new Vector3(0f, -90f, 0f);
|
|
Destroy(playerModel);
|
|
Destroy(aniCamera);
|
|
mPlayableDirector.Stop();
|
|
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
}
|
|
} |