141 lines
4.5 KiB
C#
141 lines
4.5 KiB
C#
using DefaultNamespace;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public class Conveyordata : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 输送机ID
|
|
/// </summary>
|
|
public string ID;
|
|
/// <summary>
|
|
/// 正转位置
|
|
/// </summary>
|
|
[Header("正传需要位移的位置")]
|
|
public Transform Pointforword;
|
|
/// <summary>
|
|
/// 反转位置
|
|
/// </summary>
|
|
[Header("正传判断箱子位置")]
|
|
public Transform Pointreversal;
|
|
/// <summary>
|
|
/// 提升机反转位置
|
|
/// </summary>
|
|
[Header("一层反转提升机位置")]
|
|
public Transform Liftreversal;
|
|
[Header("二层反转提升机位置")]
|
|
public Transform Liftreversal2;
|
|
[Header("反转判断箱子点位")]
|
|
public Transform Antipoint;
|
|
[Header("反转需要位移的位置")]
|
|
public Transform Antipoint2;
|
|
/// <summary>
|
|
/// 运动的速度
|
|
/// </summary>
|
|
public float Speed = 3.5f;
|
|
public void ConveyorData(Convoyorequipment convoyorequipment)
|
|
{
|
|
if (convoyorequipment.TaskNumber != "0")
|
|
{
|
|
if (convoyorequipment.ForwardRotation == "True")
|
|
{
|
|
Debug.Log("正转");
|
|
Forwardposition();
|
|
}
|
|
if (convoyorequipment.ReverseRotation == "True")
|
|
{
|
|
Debug.Log("反转");
|
|
Reverseposition();
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 正传运动
|
|
/// </summary>
|
|
public void Forwardposition()
|
|
{
|
|
if (Pointreversal.childCount > 0 && Pointreversal)
|
|
{
|
|
GameObject box = Pointreversal.transform.GetChild(0).gameObject;
|
|
if (box != null)
|
|
{
|
|
box.transform.SetParent(null);
|
|
box.transform.DOMove(Pointforword.position, (Vector3.Distance(box.transform.position, Pointforword.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
box.transform.SetParent(Pointforword);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 反转运动
|
|
/// </summary>
|
|
public void Reverseposition()
|
|
{
|
|
if (GetComponent<Hoistmovement>())
|
|
{
|
|
Hoistmovement hoistmovement = GetComponent<Hoistmovement>();
|
|
Debug.Log("一层");
|
|
if (hoistmovement.Downpoint.childCount > 0 && Liftreversal)
|
|
{
|
|
Debug.Log("进来了");
|
|
GameObject box = hoistmovement.Downpoint.transform.GetChild(0).gameObject;
|
|
if (box != null)
|
|
{
|
|
Debug.Log("反转一层");
|
|
box.transform.SetParent(null);
|
|
box.transform.DOMove(Liftreversal.position, (Vector3.Distance(box.transform.position, Liftreversal.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
box.transform.SetParent(Liftreversal);
|
|
});
|
|
}
|
|
}
|
|
else if (hoistmovement.UPpoint.childCount > 0 && Liftreversal2)
|
|
{
|
|
Debug.Log("进来了");
|
|
GameObject box = hoistmovement.UPpoint.transform.GetChild(0).gameObject;
|
|
if (box != null)
|
|
{
|
|
Debug.Log("反转二层");
|
|
box.transform.SetParent(null);
|
|
box.transform.DOMove(Liftreversal2.position, (Vector3.Distance(box.transform.position, Liftreversal2.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
box.transform.SetParent(Liftreversal2);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else if (Antipoint)
|
|
{
|
|
if (Antipoint.childCount > 0)
|
|
{
|
|
GameObject box = Antipoint.transform.GetChild(0).gameObject;
|
|
if (box != null)
|
|
{
|
|
box.transform.SetParent(null);
|
|
box.transform.DOMove(Antipoint2.position, (Vector3.Distance(box.transform.position, Antipoint2.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
Debug.Log("正常反转");
|
|
box.transform.SetParent(Antipoint2);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("箱子等于空");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("不走反转");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("啥也不是");
|
|
}
|
|
}
|
|
}
|