private void initialize() { //Set all positions to "free" for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { occupied[i, j] = new bool(); occupied[i, j] = false; //10 rows x 14 (A-N) columns , spaces that can be filled } } //initialize all nodes //Nodes 0 -1 leftPos = new Node(); // column A Is one node leftNeg = new Node(); // column B Is one node //Nodes 2 - 21 for (int i = 0; i < 2; i++) { for (int k = 0; k < rows; k++) { nodeArray[k, i] = new Node();// 10 x 2 , 10 rows by [(C,D,E,F,G) , (H,I,J,K,L) ] } } //Nodes 22-23 rightPos = new Node(); // column M is one node rightNeg = new Node(); // columnN is one node DC_Component.intializeSupplyGround(supply, ground); }
public void fixSort(List <List <DC_Component> > circuit, List <DC_Component> temp)//? { DC_Component prev = null; DC_Component curr = null; foreach (List <DC_Component> list in circuit) { for (int i = (list.Count - 1); i > 0; i--) { prev = list[i - 1]; curr = list[i]; if (prev.getNodeL().getNodeID() == supply.getNodeID() || prev.getNodeR().getNodeID() == ground.getNodeID()) {/* Do nothing*/ } else if (curr.getNodeL().getNodeID() != prev.getNodeR().getNodeID()) { if (curr.getNodeL().getNodeID() == prev.getNodeL().getNodeID()) { Node tmp = prev.getNodeL(); prev.changeNodeL(prev.getNodeR()); prev.changeNodeR(tmp); Debug.Log("SWITCH COMPLETE!"); //tbh shouldnt even have to happen } } } } }
public void placeComponent(GameObject component, String name, int[] row, int[] col, int LED_) { Node n1 = getNode(row[0], col[0]); Node n2 = getNode(row[1], col[1]); Node positive = getNode(row[1], col[1]); //Postive side of LED, Adding more components make sure to follow convention //LED_ usless at this point? //Debug.Log("Positive Node : " + positive + "Node 1: " + n1 + " Node 2: " + n2 + "LED_: " + LED_); if (n1.getNodeID() > n2.getNodeID())//&& LED_ < 0 )//&& !name.Equals("LED")) { n2 = getNode(row[0], col[0]); n1 = getNode(row[1], col[1]); } DC_Component c = null; if (name.Equals("Wire")) { c = component.GetComponent <Wire>(); } else if (name.Equals("Resistor")) { c = component.GetComponent <Resistor>(); } else if (name.Equals("LED")) { c = component.GetComponent <LED_Component>(); } c.changeNodeL(n1); c.changeNodeR(n2); c.setPositiveNode(positive); components.Add(c); //will be sorted later...eventually c.setLocation(row, col); //component to remember grid values incase it is deleted if (n1.getNodeID() > n2.getNodeID()) { c.swapLocation(); } }
public void removeComponent(DC_Component c) { freeNode(c.getRow()[0], c.getCol()[0]);//Free node space on bread board and delete object freeNode(c.getRow()[1], c.getCol()[1]); components.Remove(c); }