public bool CreateClimbTarget() { GameObject instance = Instantiate(Resources.Load("ClimbTargetMid", typeof(GameObject))) as GameObject; instance.transform.parent = transform; instance.transform.position = transform.position; instance.transform.rotation = transform.rotation; if (instance != null) { instance.name = "ClimbTarget " + (m_targets.Count + 1); ClimbTarget target = instance.GetComponent <ClimbTarget>(); if (m_targets.Count > 0) { m_targets[m_targets.Count - 1].RightNeigbour = target; target.LeftNeigbour = m_targets[m_targets.Count - 1]; } else { LedgeEdge previousEdge = null; if ((previousEdge = VertexClosestToOrigin.EdgeClosestToOrigin) != null) { if (previousEdge.m_targets.Count > 0) { target.LeftNeigbour = previousEdge.m_targets[previousEdge.m_targets.Count - 1]; previousEdge.m_targets[previousEdge.m_targets.Count - 1].RightNeigbour = target; } } } m_targets.Add(target); return(true); } return(false); }
// Instantiates and adds a edge between to vertices private void CreateEdge(LedgeVertex from, LedgeVertex to, int edgeNum) { GameObject instance = Instantiate(Resources.Load("LedgeEdge", typeof(GameObject))) as GameObject; LedgeEdge instanceEdge = instance.GetComponent <LedgeEdge>(); instance.name = "LedgeEdge " + edgeNum; instanceEdge.VertexClosestToOrigin = from; instanceEdge.VertexFurthestFromOrigin = to; instance.transform.position = from.transform.position + (to.transform.position - from.transform.position) * 0.5f; instance.transform.parent = from.transform; from.EdgeFurthestFromOrigin = instanceEdge; to.EdgeClosestToOrigin = instanceEdge; m_target.AddEdge(instanceEdge); }
public void SetFurthestOutNeighbours() { if (m_targets.Count > 0) { LedgeVertex furthestOutVert = null; LedgeEdge forwardNeigbourEdge = null; if ((furthestOutVert = VertexFurthestFromOrigin) != null) { if ((forwardNeigbourEdge = furthestOutVert.EdgeFurthestFromOrigin) != null) { ClimbTarget furthestInOnNeighbourEdge; if ((furthestInOnNeighbourEdge = forwardNeigbourEdge.FirstTarget) != null) { ClimbTarget furthestOutTarget = LastTarget; furthestOutTarget.RightNeigbour = furthestInOnNeighbourEdge; furthestInOnNeighbourEdge.LeftNeigbour = furthestOutTarget; } } } } }
public void AddEdge(LedgeEdge edge) { m_edges.Add(edge); }