81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 连线两端点
|
|
/// </summary>
|
|
public class Line_end : PermanentTriggerBase
|
|
{
|
|
public Line_group line_Group;
|
|
/// <summary>
|
|
/// 所属线
|
|
/// </summary>
|
|
private Line_item currentLine_Item;
|
|
public void Init(Line_group line_group)
|
|
{
|
|
this.line_Group = line_group;
|
|
if(!line_group.line_Ends.Contains(this))
|
|
line_group.line_Ends.Add(this);
|
|
}
|
|
|
|
public void MyOnMDown()
|
|
{
|
|
if(line_Group.currentLine_Item == null)
|
|
{
|
|
BeginDraw();
|
|
}
|
|
else
|
|
{
|
|
//当前正在连线
|
|
if (currentLine_Item == null)
|
|
{
|
|
//无所属线,结束当前连线
|
|
if (line_Group.currentLine_Item.line_Ends[1] == null)
|
|
{
|
|
if (GameManager.ProcessMgr == null || GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
|
|
{
|
|
currentLine_Item = line_Group.currentLine_Item;
|
|
currentLine_Item.AddPoint(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//画新线
|
|
BeginDraw();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//已画线,不响应
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 画新的线
|
|
/// </summary>
|
|
private void BeginDraw()
|
|
{
|
|
//当前无连线,则连新的线
|
|
Material mat = line_Group.GetCurrentLineMaterial();
|
|
if (mat != null)
|
|
{
|
|
if (GameManager.ProcessMgr == null || GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
|
|
{
|
|
GameObject obj = Instantiate<GameObject>(Resources.Load<GameObject>("Prefabs/Objects/Line/线"));
|
|
currentLine_Item = obj.GetComponent<Line_item>();
|
|
currentLine_Item.Init(mat, line_Group, this);
|
|
//取消线的选中
|
|
line_Group.ChoseLine(null);
|
|
line_Group.currentLine_Item = currentLine_Item;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
base.OnDestroy();
|
|
}
|
|
}
|