public void GenNexuses(GenShape toGen, int numSpirals, int numSpokes, float diameter, float centreDiameter) { //GameObject parent = Selection.activeGameObject; foreach (Nexus toDel in ToGenOn.GetComponentsInChildren <Nexus>()) { DestroyImmediate(toDel.gameObject); } foreach (Segment toDel in ToGenOn.GetComponentsInChildren <Segment>()) { DestroyImmediate(toDel.gameObject); } List <Nexus> createdNexuses = new List <Nexus>(); float halfDia = diameter / 2; float currentDist = centreDiameter / 2; float distInc = (halfDia - (centreDiameter / 2)) / (numSpirals * numSpokes); float pi2 = Mathf.PI * 2; Nexus prevNexus = null; switch (toGen) { case GenShape.Spiral: GameObject NexusParent = new GameObject("NexusParent"); NexusParent.transform.SetParent(ToGenOn.transform, false); NexusParent.transform.localPosition = Vector3.zero; NexusParent.AddComponent <WebBase>(); #if UNITY_EDITOR Nexus centreNexus = ((GameObject)PrefabUtility.InstantiatePrefab(NexusPrefab, ToGenOn.transform)).GetComponent <Nexus>(); #else Nexus centreNexus = Instantiate(NexusPrefab, ToGenOn.transform).GetComponent <Nexus>(); #endif centreNexus.transform.localPosition = Vector3.zero; Dictionary <int, Nexus> prevSpokeNexuses = new Dictionary <int, Nexus>(); for (int i = 0; i < numSpokes; i++) { prevSpokeNexuses[i] = centreNexus; } for (int currSpiral = 0; currSpiral < numSpirals; currSpiral++) { for (int currSpoke = 0; currSpoke < numSpokes; currSpoke++) { float s = Mathf.Sin((pi2 / numSpokes) * currSpoke); float c = Mathf.Cos((pi2 / numSpokes) * currSpoke); #if UNITY_EDITOR Nexus nexus = ((GameObject)PrefabUtility.InstantiatePrefab(NexusPrefab, NexusParent.transform)).GetComponent <Nexus>(); #else Nexus nexus = Instantiate(NexusPrefab, NexusParent.transform).GetComponent <Nexus>(); #endif nexus.transform.localPosition = (new Vector3(s + c, c - s, 0)) * currentDist; if (prevNexus != null) { ConnectNexuses(prevNexus, nexus); } prevNexus = nexus; if (prevSpokeNexuses.ContainsKey(currSpoke)) { ConnectNexuses(prevSpokeNexuses[currSpoke], nexus); } prevSpokeNexuses[currSpoke] = nexus; createdNexuses.Add(nexus); currentDist += distInc; } } break; case GenShape.Spokes: break; } CreateSegments(createdNexuses); }
public GenShapeActionPair(GenShape shape, GenAction action) { this.Shape = shape; this.Action = action; }
public GenShapeActionPair(GenShape shape, GenAction action) { Shape = shape; Action = action; }