92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using DefaultNamespace;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Hoistmovement : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 提升机ID
|
|
/// </summary>
|
|
public string ID;
|
|
/// <summary>
|
|
/// 一层位置
|
|
/// </summary>
|
|
public Transform Downpoint;
|
|
/// <summary>
|
|
/// 二层位置
|
|
/// </summary>
|
|
public Transform UPpoint;
|
|
/// <summary>
|
|
/// 运动的速度
|
|
/// </summary>
|
|
public float Speed = 3.5f;
|
|
public void Hoister(Elvequipment elvequipment)
|
|
{
|
|
if (elvequipment.CurrentLayer == "1")
|
|
{
|
|
Debug.Log("一层");
|
|
Alayer();
|
|
}
|
|
else if(elvequipment.CurrentLayer == "2")
|
|
{
|
|
Debug.Log("二层");
|
|
Layertwo();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 下降到一层
|
|
/// </summary>
|
|
public void Alayer()
|
|
{
|
|
if (UPpoint.childCount > 0)
|
|
{
|
|
GameObject box = UPpoint.GetChild(0).gameObject;
|
|
if (box != null)
|
|
{
|
|
box.transform.SetParent(transform);
|
|
transform.DOMove(Downpoint.position, (Vector3.Distance(transform.position, Downpoint.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
box.transform.SetParent(Downpoint);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Designateddisplacement(Downpoint.position,Speed);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 上升二层
|
|
/// </summary>
|
|
public void Layertwo()
|
|
{
|
|
if(Downpoint.childCount > 0)
|
|
{
|
|
GameObject box = Downpoint.GetChild(0).gameObject;
|
|
if(box != null)
|
|
{
|
|
box.transform.SetParent(transform);
|
|
transform.DOMove(UPpoint.position, (Vector3.Distance(transform.position, UPpoint.transform.position) / Speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
|
|
{
|
|
box.transform.SetParent(UPpoint);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Designateddisplacement(UPpoint.position, Speed);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 移动方法
|
|
/// </summary>
|
|
public void Designateddisplacement(Vector3 dis, float speed)
|
|
{
|
|
Debug.Log("提升机移动");
|
|
float times = Vector3.Distance(transform.position, dis) / speed;
|
|
transform.DOMove(dis, times).SetEase(Ease.InOutQuad);
|
|
}
|
|
}
|