IEnumerator UpdatePosition() { while (newDisconnections.Count != 0) { ConnectionInstruction inst = newDisconnections.Dequeue(); FishBox firstBox = boxes[inst.firstBox.boxNo]; FishBox secondBox = boxes[inst.secondBox.boxNo]; firstBox.breakConnection(inst, secondBox); } while (newConnections.Count != 0) { ConnectionInstruction inst = newConnections.Dequeue(); FishBox firstBox = boxes[inst.firstBox.boxNo]; FishBox secondBox = boxes[inst.secondBox.boxNo]; firstBox.createConnection(inst, secondBox); } Debug.Log("hey"); avoidPositionCoroutine = null; yield return(null); }
// Update is called once per frame void Update() { //Debug.Log("pos: " + avoidPositionCoroutine); //Debug.Log(avoidWifiCoroutine); if (avoidWifiCoroutine == null /*(&& avoidPositionCoroutine == null*/) { //Debug.Log("A"); avoidWifiCoroutine = StartCoroutine(getPositionUpdates()); } ConnectionInstruction inst1 = makeInst(1, "bottom", "B", 0, "top", "B"); ConnectionInstruction inst2 = makeInst(1, "bottom", "C", 0, "top", "A"); ConnectionInstruction inst3 = makeInst(1, "bottom", "C", 0, "top", "A"); ConnectionInstruction inst4 = makeInst(1, "bottom", "B", 0, "top", "B"); ConnectionInstruction inst5 = makeInst(1, "bottom", "A", 0, "top", "B"); ConnectionInstruction inst6 = makeInst(1, "bottom", "C", 0, "top", "D"); ConnectionInstruction inst7 = makeInst(1, "bottom", "C", 0, "top", "D"); //remember to set a coroutine block // //avoidPositionCoroutine = StartCoroutine(UpdatePosition()); if (Input.GetKeyDown("1")) { /*foreach (Instruction inst in instructions) * { * //run disconnections first to avoid confusion about positions * //if (!inst.connect) { inst.firstBox.breakConnections(inst.secondBox, inst.relationship); } * }*/ //foreach (Instruction inst in instructions) //{ FishBox firstBox = boxes[inst1.firstBox.boxNo]; FishBox secondBox = boxes[inst1.secondBox.boxNo]; firstBox.createConnection(inst1, secondBox); } else if (Input.GetKeyDown("2")) { FishBox firstBox = boxes[inst2.firstBox.boxNo]; FishBox secondBox = boxes[inst2.secondBox.boxNo]; firstBox.createConnection(inst2, secondBox); } else if (Input.GetKeyDown("3")) { FishBox firstBox = boxes[inst3.firstBox.boxNo]; FishBox secondBox = boxes[inst3.secondBox.boxNo]; firstBox.breakConnection(inst3, secondBox); } else if (Input.GetKeyDown("4")) { FishBox firstBox = boxes[inst4.firstBox.boxNo]; FishBox secondBox = boxes[inst4.secondBox.boxNo]; firstBox.breakConnection(inst4, secondBox); } /*GameObject wall = boxes[0].getTankComponent("bottomWall"); * Renderer renderer = wall.transform.Find("A").GetComponent<Renderer>(); * Material mat = renderer.material; * * float emission = 0 + Mathf.PingPong(Time.time * (0.003f), .02f); * Color baseColor = new Color(26, 55, 50); //Replace this with whatever you want for your base color at emission level '1' * * Color finalColor = baseColor * Mathf.LinearToGammaSpace(emission); * * mat.SetColor("_EmissionColor", finalColor);*/ }