public sLine AddLine(sVertex point1, sVertex point2) { if (listLine.Exists(L => L.IsLine(point1, point2))) { // Linha já existe na estrutura return(null); } sLine l = new sLine(point1, point2); listLine.Add(l); switch (sHelper.GetInstance().newLineMaterial) { case 1: l.SetSoftHardness(); break; case 2: l.SetMidHardness(); break; case 3: l.SetHardHardness(); break; } return(l); }
public void SegmentLine(int X, int Y) { sLine original = listLine.Find(l => l.Contains(X, Y)); sVertex newPoint = new sVertex(X, Y); listLine.Add(new sLine(original.Vertex1, newPoint, original.GetHardness())); listLine.Add(new sLine(newPoint, original.Vertex2, original.GetHardness())); Destroy(original.GameObject()); listLine.Remove(original); AddVertex(X, Y); }
public bool SelectVertex(int X, int Y) { sVertex v = listVertex.Find(V => V.IsVertex(X, Y)); if (v == null) { return(false); } if (workVertex != null) { workVertex.SetInactive(); } v.SetActive(); workVertex = v; sHelper.GetInstance().GuideLines(v.GameObject().transform.position.x, v.GameObject().transform.position.y); selected = true; return(true); }
public bool RemoveVertex(sVertex vertex) { if (vertex == null) { return(false); } List <sLine> toRemove = listLine.FindAll(l => l.IsEndPoint(vertex)); foreach (sLine l in toRemove) { RemoveLine(l); } listVertex.Remove(vertex); Destroy(vertex.GameObject()); // Se último vértice foi excluído, auto-destrói (retorna true) if (listVertex.Count == 0) { return(true); } return(false); }
public sVertex AddVertex(int X, int Y) { if (listVertex.Exists(V => V.IsVertex(X, Y))) { // Vértice já existe na estrutura SelectVertex(X, Y); return(null); } sVertex v = new sVertex(X, Y); listVertex.Add(v); v.SetActive(); if (workVertex != null) { workVertex.SetInactive(); } workVertex = v; sHelper.GetInstance().GuideLines(X * 0.24f, Y * 0.24f); selected = true; return(v); }
public bool ContainsVertex(sVertex vertex) { return(listVertex.Exists(v => v.IsVertex(vertex.Coordinate))); }
public sLine(sVertex point1, sVertex point2, int hardness) { v1 = point1; v2 = point2; Hardness = hardness; }
public sLine(sVertex point1, sVertex point2) { v1 = point1; v2 = point2; Hardness = 1; }
public bool IsLine(sVertex d1, sVertex d2) { return((d1 == v1 && d2 == v2) || (d1 == v2 && d2 == v1)); }
public bool IsEndPoint(sVertex vertex) { return(v1 == vertex || v2 == vertex); }