using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 连线两端点 /// public class Line_end : PermanentTriggerBase { public Line_group line_Group; /// /// 所属线 /// 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 { //已画线,不响应 } } } /// /// 画新的线 /// private void BeginDraw() { //当前无连线,则连新的线 Material mat = line_Group.GetCurrentLineMaterial(); if (mat != null) { if (GameManager.ProcessMgr == null || GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(triggerName, true) == 0) { GameObject obj = Instantiate(Resources.Load("Prefabs/Objects/Line/线")); currentLine_Item = obj.GetComponent(); currentLine_Item.Init(mat, line_Group, this); //取消线的选中 line_Group.ChoseLine(null); line_Group.currentLine_Item = currentLine_Item; } } } protected override void OnDestroy() { base.OnDestroy(); } }