private void InsertAndMoveSiblings(int index, PathCell target) { offsetList.Clear(); offsetList.AddRange(pathCells.GetRange(index, pathCells.Count - index)); pathCells.RemoveRange(index, pathCells.Count - index); pathCells.Add(target); pathCells.AddRange(offsetList); }
public PathCell GetNextPathCell(PathCell current) { for (int i = 0; i < pathCells.Count; i++) { if (i + 1 >= pathCells.Count) { return(null); } if (pathCells[i] == current) { return(pathCells[i + 1]); } } return(null); }
public void SetBranchGizmos(PathCell root, PathMaker branch) { PathCell gizmoA = new GameObject().AddComponent <PathCell>(); gizmoA.transform.SetParent(transform); gizmoA.GizmoOrigin = root; gizmoA.addBranch(branch); PathCell gizmoB = new GameObject().AddComponent <PathCell>(); gizmoB.transform.SetParent(transform); gizmoB.GizmoOrigin = root; gizmoB.addBranch(branch); Vector3 GizmoAPos; Vector3 GizmoBPos; root.transform.LookAt(branch.GetPathCell(1).transform, Vector3.up); GizmoAPos = root.transform.right * (_pathThickness / 2); GizmoBPos = -root.transform.right * (_pathThickness / 2); gizmoA.transform.localPosition = GizmoAPos + root.transform.localPosition; gizmoB.transform.localPosition = GizmoBPos + root.transform.localPosition; int Index = pathCells.IndexOf(root); int SiblingIndex = root.transform.GetSiblingIndex(); InsertAndMoveSiblings(Index, gizmoA); gizmoA.transform.SetSiblingIndex(SiblingIndex); InsertAndMoveSiblings(Index + 1, root); //root.transform.SetSiblingIndex(Index + 1); InsertAndMoveSiblings(Index + 2, gizmoB); gizmoB.transform.SetSiblingIndex(SiblingIndex + 2); }