73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class PipelineSystem : MonoBehaviour
|
|
{
|
|
#region 组件
|
|
|
|
[SerializeField] private Transform pipeline;
|
|
[SerializeField] private Transform checkScreen;
|
|
[SerializeField] private Transform[] wayPoints;
|
|
[SerializeField] private PipelineProduct productPrefab;
|
|
|
|
public event Action<PipelineProduct> OnSelected;
|
|
|
|
#endregion
|
|
|
|
#region 运行时数据
|
|
|
|
private PipelineProduct _selectedProduct;
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
}
|
|
|
|
public void Selected(PipelineProduct product)
|
|
{
|
|
if (_selectedProduct != null && _selectedProduct != product)
|
|
{
|
|
_selectedProduct.Deselect();
|
|
}
|
|
|
|
if (_selectedProduct != product)
|
|
{
|
|
_selectedProduct = product;
|
|
OnSelected?.Invoke(product);
|
|
}
|
|
}
|
|
|
|
public void OnProductEnd(PipelineProduct product, bool isSuccess)
|
|
{
|
|
// TODO
|
|
if (isSuccess)
|
|
{
|
|
// TODO 成功
|
|
}
|
|
else
|
|
{
|
|
// TODO 失败
|
|
}
|
|
}
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
DrawPipeline();
|
|
}
|
|
|
|
private void DrawPipeline()
|
|
{
|
|
if (wayPoints == null || wayPoints.Length < 2)
|
|
return;
|
|
|
|
for (int i = 0; i < wayPoints.Length - 1; i++)
|
|
{
|
|
Gizmos.color = Color.red;
|
|
Gizmos.DrawLine(wayPoints[i].position, wayPoints[i + 1].position);
|
|
}
|
|
}
|
|
}
|
|
} |