U3D_TobaccoWarehouseISMDTSy.../Assets/Scripts/YL/Littlepony3.cs

55 lines
2.1 KiB
C#

using Cysharp.Threading.Tasks;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Littlepony3 : MonoBehaviour
{
public Transform points;
public Transform tongs;
public GameObject box;
private bool isp = false;
private async UniTask OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Box"))
{
if (transform.childCount == 1)
{
if (transform.GetChild(0).childCount == 1)
{
//Debug.Log("箱子合起来了");
}
else
{
if (points.childCount == 1 && transform.childCount == 1)
{
GameObject box = points.GetChild(0).gameObject;
GameObject box2 = transform.GetChild(0).gameObject;
Destroy(box);
Destroy(box2);
GameObject box3 = Instantiate(this.box, transform);
box3.transform.SetParent(transform);
// Debug.Log("合箱子");
tongs.transform.DOMoveY(tongs.position.y - 0.2f, 0.5f).SetEase(Ease.InOutQuad);
}
else if (points.childCount == 0 && transform.childCount == 1)
{
GameObject game = transform.GetChild(0).gameObject;
tongs.transform.DOMoveY(tongs.position.y - 0.3f, 0.3f).SetEase(Ease.InOutQuad).OnComplete(() =>
{
tongs.transform.DOMoveY(tongs.position.y + 0.5f, 0.5f).SetEase(Ease.InOutQuad);
game.transform.DOMoveY(game.transform.position.y + 0.38f, 0.5f).SetEase(Ease.InOutQuad).OnComplete(() =>
{
game.transform.SetParent(points);
// Debug.Log("第一个箱子抓起来");
});
});
}
}
}
}
}
}