protected void formBasicShape(InteractiveComponent comp) { Transform middle = this.transform.Find("MiddleBody"); Transform reciever = this.transform.Find("Reciever"); Transform sender = this.transform.Find("Sender"); GameObject.Destroy(sender.gameObject); GameObject.Destroy(reciever.gameObject); //makes the middle //GameObject currentMiddle = Instantiate(middle.gameObject); middle.transform.SetParent(this.transform); middle.transform.localScale = new Vector3(comp.Size.x - .2f, comp.Size.y - .4f); middle.transform.localPosition = Vector3.zero; middle.transform.rotation = this.transform.rotation; reciever.localPosition = new Vector3(((comp.Size.x - 1) / -2f), ((comp.Size.y - 1) / -2f) - .35f, 0); //makes the receivers for (int i = 0; i < comp.receiverCount(); i++) { GameObject currentReciever = Instantiate(reciever.gameObject); currentReciever.transform.SetParent(this.transform); currentReciever.transform.localPosition = new Vector3(((comp.Size.x - 1) / -2f) + i, ((comp.Size.y - 1) / -2f) - .35f, 0); currentReciever.transform.rotation = this.transform.rotation; BoxCollider2D bc = currentReciever.GetComponent <BoxCollider2D>(); //bc.enabled = true; } //makes the senders for (int i = 0; i < comp.senderCount(); i++) { GameObject currentSender = Instantiate(sender.gameObject); currentSender.transform.SetParent(this.transform); currentSender.transform.localPosition = new Vector3(((comp.Size.x - 1) / -2f) + i, ((comp.Size.y - 1) / 2f) + .35f, 0); currentSender.transform.rotation = this.transform.rotation; SenderController cs = currentSender.AddComponent <SenderController>(); BoxCollider2D bc = currentSender.GetComponent <BoxCollider2D>(); cs.setUp(comp.getSenderAt(i)); this.senderControllers.Add(cs); } }
public void connectGraph() { List <InteractiveComponent> interComps = this.lightGraph.getAllInteractiveComponents(); for (int i = 0; i < interComps.Count; i++) { InteractiveComponent currentComp = interComps[i]; for (int s = 0; s < currentComp.senderCount(); s++) { Sender sender = currentComp.getSenderAt(s); int direction = currentComp.Rotation; //gets the connections for the sender sender.setTargets(getConnections(sender, direction)); } } }