using Cysharp.Threading.Tasks;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Outboundequipment : MonoBehaviour
{
///
/// 提升机架子
///
public GameObject frame;
///
/// 箱子位移的速度
///
private float speed = 5f;
///
/// 提升机第一个点位
///
public Transform point1;
///
/// 提升机第二个点位
///
public Transform point2;
///
/// 提升机第三个点位
///
public Transform point3;
void Start()
{
}
void Update()
{
}
//private async void OnTriggerEnter(Collider other)
//{
// if (other.gameObject.CompareTag("Box"))
// {
// await Shipment(other.gameObject,frame);
// }
//}
///
/// 出货
///
///
private async UniTask Shipment(GameObject box,GameObject frame)
{
await MoveObjectToPosition(frame.transform, point1.transform.position, speed);
await MoveObjectToPosition(box.transform, point1.transform.position, speed);
box.transform.SetParent(null);
box.transform.SetParent(frame.transform);
await MoveObjectToPosition(frame.transform, point2.transform.position, speed);
box.transform.SetParent(null);
await MoveObjectToPosition(box.transform, point3.transform.position, speed);
}
///
/// 出货动画
///
///
///
///
///
private async UniTask MoveObjectToPosition(Transform target, Vector3 destination, float speed)
{
float duration = Vector3.Distance(target.position, destination) / speed;
await target.DOMove(destination, duration).SetEase(Ease.InOutQuad).AsyncWaitForCompletion();
}
}