public void UpdateCmp() { //Stack the simulator current state so it can be undone UndoState undoState = new UndoState(); undoState.Snapshot(); Simulator.sim.undoStack.Push(undoState); if (!string.IsNullOrEmpty(cmpInput.text)) { if (int.Parse(cmpInput.text) >= 1) { cmp = true; cmpInput.text = "1"; } else { cmp = false; cmpInput.text = "0"; } } else { cmp = false; cmpInput.text = "0"; } }
public void UpdatePC() { TextBox.textBox.Clear(); //Stack the simulator current state so it can be undone UndoState undoState = new UndoState(); undoState.Snapshot(); Simulator.sim.undoStack.Push(undoState); if (state >= 0 && state <= 14 && Simulator.sim.currentProcess == currentProcess) { if (state >= 6 && state <= 8) { Simulator.sim.codeLine[state].color = new Color(0.625f, 0.125f, 0.125f); } else { Simulator.sim.codeLine[state].color = Color.white; } } if (!string.IsNullOrEmpty(pcInput.text)) { if (int.Parse(pcInput.text) >= 0 && int.Parse(pcInput.text) <= 15) { state = int.Parse(pcInput.text); if (state < 0) { state = 0; pcInput.text = "0"; } if (state > 15) { state = 15; pcInput.text = "15"; } } } else { state = 0; pcInput.text = "0"; } if (state >= 0 && state <= 14 && Simulator.sim.currentProcess == currentProcess) { if (state >= 6 && state <= 8) { Simulator.sim.codeLine[state].color = new Color(1f, 0.5f, 0.5f); } else { Simulator.sim.codeLine[state].color = new Color(1f, 1f, 0f); } } Animate(state - 1); }
//Play current process' next public void PlayNext() { if (process[currentProcess].state < 15) { //Stack the simulator current state so it can be undone UndoState state = new UndoState(); state.Snapshot(); undoStack.Push(state); if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(0.625f, 0.125f, 0.125f); } else { codeLine[process[currentProcess].state].color = Color.white; } } process[currentProcess].Play(process[currentProcess].state); if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(1f, 0.5f, 0.5f); } else { codeLine[process[currentProcess].state].color = new Color(1f, 1f, 0f); } } } }
public void UpdateLock() { //Stack the simulator current state so it can be undone UndoState state = new UndoState(); state.Snapshot(); undoStack.Push(state); if (!string.IsNullOrEmpty(lockInput.text)) { lockVar = int.Parse(lockInput.text); doorText.text = "Lock\n" + lockVar; if (lockVar >= 1) { toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(1f, 0.5f, 0.5f, 0.5f); } else { toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(0.5f, 1f, 0.5f, 0.5f); } } else { lockInput.text = "0"; doorText.text = "Lock\n0"; lockVar = 0; toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(0.5f, 1f, 0.5f, 0.5f); } }
public void UpdateToilet() { //Stack the simulator current state so it can be undone UndoState state = new UndoState(); state.Snapshot(); undoStack.Push(state); if (!string.IsNullOrEmpty(toiletInput.text)) { toilet = int.Parse(toiletInput.text); } else { toiletInput.text = "0"; toilet = 0; } }
public void UpdateReg(int register) { //Stack the simulator current state so it can be undone UndoState undoState = new UndoState(); undoState.Snapshot(); Simulator.sim.undoStack.Push(undoState); if (!string.IsNullOrEmpty(rInput[register].text)) { r[register] = int.Parse(rInput[register].text); if (register == 0) { if (r[0] <= 0) { r[0] = 0; rInput[0].text = "0"; rInput[0].textComponent.color = Color.green; } else { r[0] = 1; rInput[0].text = "1"; rInput[0].textComponent.color = Color.red; } } else { r[register] = 0; rInput[register].text = "0"; if (register == 0) { rInput[0].textComponent.color = Color.green; } } } }
public void UpdateProcess() { //Stack the simulator current state so it can be undone UndoState state = new UndoState(); state.Snapshot(); undoStack.Push(state); if (!string.IsNullOrEmpty(toiletInput.text)) { if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(0.625f, 0.125f, 0.125f); } else { codeLine[process[currentProcess].state].color = Color.white; } } processPanel[currentProcess].color = new Color32(200, 200, 200, 255); currentProcess = int.Parse(processInput.text); if (currentProcess < 0) { currentProcess = 0; } else if (currentProcess > 3) { currentProcess = 3; } processInput.text = currentProcess.ToString(); if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(1f, 0.5f, 0.5f); } else { codeLine[process[currentProcess].state].color = new Color(1f, 1f, 0f); } } processPanel[currentProcess].color = new Color(1f, 1f, 0.5f); } else { if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(0.625f, 0.125f, 0.125f); } else { codeLine[process[currentProcess].state].color = Color.white; } } processPanel[currentProcess].color = new Color32(200, 200, 200, 255); currentProcess = 0; if (process[currentProcess].state < 15) { if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8) { codeLine[process[currentProcess].state].color = new Color(1f, 0.5f, 0.5f); } else { codeLine[process[currentProcess].state].color = new Color(1f, 1f, 0f); } } processPanel[currentProcess].color = new Color(1f, 1f, 0.5f); } }