67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
public class TruckAnimation : MonoBehaviour
|
|
{
|
|
public AnimationClip clip;
|
|
|
|
public Transform truckDoor;
|
|
|
|
public GameObject worker;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
AnimationEvent ani1 = new AnimationEvent();
|
|
ani1.time = 4.02f;
|
|
ani1.functionName = "CloseTruckDor";
|
|
clip.AddEvent(ani1);
|
|
|
|
AnimationEvent ani2 = new AnimationEvent();
|
|
ani2.time = clip.length;
|
|
ani2.functionName = "EndTruckAnimation";
|
|
clip.AddEvent(ani2);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void OpenTruckDoor()
|
|
{
|
|
//Debug.Log("212121212");
|
|
truckDoor.DOLocalRotate(new Vector3(0, 0, -90), 0.9f).SetEase(Ease.Linear).OnComplete(() =>
|
|
{
|
|
this.GetComponent<Animator>().Play("ExitTruckLeft");
|
|
Invoke("CloseTruckDoor",4.8F);
|
|
});
|
|
}
|
|
public void OpenTruckDoorOther()
|
|
{
|
|
//Debug.Log("212121212");
|
|
truckDoor.DOLocalRotate(new Vector3(0, 0, 90), 0.9f).SetEase(Ease.Linear).OnComplete(() =>
|
|
{
|
|
this.GetComponent<Animator>().Play("ExitTruckLeft");
|
|
});
|
|
}
|
|
|
|
public void CloseTruckDoor()
|
|
{
|
|
//Debug.Log("212121212");
|
|
truckDoor.DOLocalRotate(Vector3.zero, 0.9f).SetEase(Ease.Linear);
|
|
}
|
|
|
|
public void EndTruckAnimation()
|
|
{
|
|
//Debug.Log("212121212");
|
|
gameObject.SetActive(false);
|
|
worker.SetActive(true);
|
|
}
|
|
public void OnDisable()
|
|
{
|
|
|
|
}
|
|
}
|