58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
public class OfficeTimelineControl : MonoBehaviour
|
|
{
|
|
private PlayableDirector mPlayableDirector;
|
|
|
|
//过场动画所用的玩家模型
|
|
private GameObject playerModel;
|
|
public GameObject playerController;
|
|
public GameObject aniCamera;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
playerController.SetActive(false);
|
|
mPlayableDirector = GetComponent<PlayableDirector>();
|
|
mPlayableDirector.Stop();
|
|
mPlayableDirector.stopped += OnPlayableDirectorStopped;
|
|
playerModel = transform.GetChild(0).gameObject;
|
|
StartTimeline(); //TODO 这里先掉一下,后续应该流程控制的时候触发调用
|
|
}
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown("p"))
|
|
{
|
|
mPlayableDirector.Stop();
|
|
}
|
|
}
|
|
public void StartTimeline()
|
|
{
|
|
mPlayableDirector.Play();
|
|
}
|
|
|
|
private void OnPlayableDirectorStopped(PlayableDirector aDirector)
|
|
{
|
|
if (mPlayableDirector == aDirector)
|
|
{
|
|
GameManager.EventMgr.EventTrigger(Enum_EventType.OfficeTimeLineOver);
|
|
Invoke("DestroyPlayer", 1f);
|
|
}
|
|
}
|
|
|
|
private void DestroyPlayer()
|
|
{
|
|
Destroy(playerModel);
|
|
Destroy(aniCamera);
|
|
playerController.SetActive(true);
|
|
GameManager.EventMgr.EventTrigger(Enum_EventType.InitializationUI);
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
mPlayableDirector.stopped -= OnPlayableDirectorStopped;
|
|
}
|
|
} |