/// <summary> /// Метод дополнительное соединения без создания линии /// </summary> /// <param name="vertex">Вершина</param> /// <param name="line">Компонетн</param> public void ReverseConnect(Vertex vertex, LineRenderer line) { ConnectingTunnel newConnect = new ConnectingTunnel(); ContactPoint.Add(vertex); newConnect.endPoint = vertex; newConnect.lineRenderer = line; allConnect.Add(newConnect); }
public static void Draw(List <Vertex> pathComplete) { pathComplete.Reverse(); for (int i = 0; i < pathComplete.Count - 1; i++) { ConnectingTunnel line = pathComplete[i].allConnect.Find(x => x.endPoint.gameObject.name == pathComplete[i + 1].gameObject.name); line.lineRenderer.startColor = Color.yellow; line.lineRenderer.endColor = Color.yellow; } }
/// <summary> /// Добавление соединения /// </summary> /// <param name="vertex">Вершина</param> public void AddConnect(Vertex vertex) { ConnectingTunnel newConnect = new ConnectingTunnel(); ContactPoint.Add(vertex); newConnect.endPoint = vertex; newConnect.lineRenderer = ObjManager.Instance.CreateLine(gameObject.transform).GetComponent <LineRenderer>(); newConnect.lineRenderer.SetPosition(0, Posititon); newConnect.lineRenderer.SetPosition(1, vertex.Posititon); allConnect.Add(newConnect); vertex.ReverseConnect(this, newConnect.lineRenderer); }
public void DeleteConnect(Vertex vertex) { ConnectingTunnel deleteConnect = allConnect.Find(x => x.endPoint.gameObject.name == vertex.gameObject.name); if (deleteConnect != null) { ContactPoint.Remove(deleteConnect.endPoint); Destroy(deleteConnect.lineRenderer.gameObject); allConnect.Remove(deleteConnect); } else { Debug.LogError("Ребро не обнаружено"); } }
/// <summary> /// Нициализация вершины /// </summary> public void InitVertex(bool isCustomWeight) { if (ContactPoint.Count > 0) { for (int i = 0; i < ContactPoint.Count; i++) { ConnectingTunnel newConnect = new ConnectingTunnel(); newConnect.endPoint = ContactPoint[i]; if (!ContactPoint[i].IsCheckConnect) { newConnect.lineRenderer = ObjManager.Instance.CreateLine(gameObject.transform).GetComponent <LineRenderer>(); newConnect.lineRenderer.SetPosition(0, Posititon); newConnect.lineRenderer.SetPosition(1, ContactPoint[i].Posititon); } else { ConnectingTunnel tun = ContactPoint[i].allConnect.Find(x => x.endPoint.gameObject.name == gameObject.name); if (tun != null) { newConnect.lineRenderer = tun.lineRenderer; } else { emptyConnect.Add(ContactPoint[i]); newConnect = null; } } if (newConnect != null) { allConnect.Add(newConnect); } } } IsCheckConnect = true; ClearEmptyContact(); if (isCustomWeight) { Weight = customWeight; } }