private void Awake() { var startNode = new DosNode(""); var homeConnections = new DosNode(""); var server1_1Connections = new DosNode(WorldState.serverAddress1); server1_1Connections.customChoiceName += server1ChoiceName; var server2_1Connections = new DosNode(WorldState.serverAddress2); server2_1Connections.customChoiceName += server2ChoiceName; var server3_1Connections = new DosNode(WorldState.serverAddress3); server3_1Connections.customChoiceName += server3ChoiceName; var server4Connections = new DosNode(WorldState.serverAddress4); server4Connections.customChoiceName += server4ChoiceName; startNode.programStartCommand = "PrtScn -f -u"; startNode.startTextLines.Add("Local server address:\n" + WorldState.homeAddress + "\n"); startNode.startTextLines.Add("Input server address to inspect:"); startNode.showChoices = false; startNode.choices.Add(WorldState.homeAddress, homeConnections); startNode.choices.Add(WorldState.serverAddress1, server1_1Connections); startNode.choices.Add(WorldState.serverAddress2, server2_1Connections); startNode.choices.Add(WorldState.serverAddress3, server3_1Connections); var sharedTextLines = new List <string>(); sharedTextLines.Add("This server has forward connections."); sharedTextLines.Add("Input a connection index to inspect it"); homeConnections.startTextLines = sharedTextLines; homeConnections.choices.Add("1", server1_1Connections); homeConnections.choices.Add("2", server4Connections); server1_1Connections.startTextLines = sharedTextLines; server1_1Connections.choices.Add("1", server2_1Connections); server1_1Connections.choices.Add("2", server4Connections); server2_1Connections.startTextLines = sharedTextLines; server2_1Connections.choices.Add("1", server3_1Connections); server2_1Connections.choices.Add("2", server4Connections); server3_1Connections.startTextLines = sharedTextLines; server3_1Connections.choices.Add("1", server4Connections); server4Connections.startTextLines.Add("This server has no forward connections."); server4Connections.startTextLines.Add("Input r to restart."); server4Connections.showChoices = false; server4Connections.choices.Add("r", startNode); GetComponent <MSDOSPrompt>().startNode = startNode; }
void SetCurrentServerAsServer3() { currentServerStartNode = server3StartNode; }
private void Awake() { var startNode = new DosNode(""); startNode.programStartCommand = "Sacs -noW"; GetComponent <MSDOSPrompt>().startNode = startNode; //shared admin nodes adminPasswordNode = new DosNode(""); adminPasswordNode.startTextLines.Add("Password:"******""); badCredentialsNode.startTextLines.Add("Access denied"); badCredentialsNode.customChoiceInputAction += GoBackToCurrentServerStart; var disconnectNode = new DosNode("Disconnect"); disconnectNode.startTextLines.Add("Disconnected from server."); disconnectNode.nextNode = startNode; string exceptionOption = "Add firewall exception"; string exceptionQuestionText = "From which address:"; string exceptionText = "Exception added"; string noSelfAddText = "Cannot add self as an exception"; //server connections var connectionTextLines = new List <string>(); connectionTextLines.Add("Connecting to server"); connectionTextLines.Add("."); connectionTextLines.Add(".."); connectionTextLines.Add("..."); connectionTextLines.Add("Connection established"); server1StartNode = new DosNode("Menu"); server2StartNode = new DosNode("Menu"); server3StartNode = new DosNode("Back"); server4StartNode = new DosNode("Menu"); var connectToServer1 = new DosNode(""); connectToServer1.startTextLines = connectionTextLines; connectToServer1.nextNode = server1StartNode; var connectToServer2 = new DosNode(""); connectToServer2.startTextLines = connectionTextLines; connectToServer2.nextNode = server2StartNode; var connectToServer3 = new DosNode(""); connectToServer3.startTextLines = connectionTextLines; connectToServer3.nextNode = server3StartNode; var connectToServer4 = new DosNode(""); connectToServer4.startTextLines = connectionTextLines; connectToServer4.nextNode = server4StartNode; startNode.startTextLines.Add("Input server address to connect to:"); startNode.showChoices = false; startNode.choices.Add(WorldState.serverAddress1, connectToServer1); startNode.choices.Add(WorldState.serverAddress2, connectToServer2); startNode.choices.Add(WorldState.serverAddress3, connectToServer3); startNode.choices.Add(WorldState.serverAddress4, connectToServer4); { //server 1 adminNodeServer1 = new DosNode(""); var adminNameNode = new DosNode("Admin options"); var emailNode = new DosNode("Email options"); var downloadEmails = new DosNode("Download emails"); var removeEmails = new DosNode("Remove emails"); var addPortForwardException = new DosNode(exceptionOption); var addedCorrectAddress = new DosNode(""); var addedSelfAddress = new DosNode(""); var addedOtherAddress = new DosNode(""); server1StartNode.startTextLines.Add("Welcome to Brady's Petshop server :-)"); server1StartNode.choices.Add("a", adminNameNode); server1StartNode.choices.Add("e", emailNode); server1StartNode.choices.Add("d", disconnectNode); adminNameNode.startTextLines.Add("Name:"); adminNameNode.onStartEvent += SetCurrentServerAsServer1; adminNameNode.customChoiceInputAction += OnNameInput; adminNodeServer1.startTextLines.Add("Admin options:"); adminNodeServer1.choices.Add("e", addPortForwardException); adminNodeServer1.choices.Add("m", server1StartNode); addPortForwardException.startTextLines.Add(exceptionQuestionText); addPortForwardException.showChoices = false; addPortForwardException.choices.Add(WorldState.homeAddress, addedCorrectAddress); addPortForwardException.choices.Add(WorldState.serverAddress1, addedSelfAddress); addPortForwardException.choices.Add(WorldState.serverAddress2, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress3, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress4, addedOtherAddress); addedCorrectAddress.startTextLines.Add(exceptionText); addedCorrectAddress.nextNode = adminNodeServer1; addedCorrectAddress.onStartEvent += OpenServer1; addedOtherAddress.startTextLines.Add(exceptionText); addedOtherAddress.nextNode = adminNodeServer1; addedSelfAddress.startTextLines.Add(noSelfAddText); addedSelfAddress.nextNode = adminNodeServer1; emailNode.onChoiceAvailable += OnEmailChoiceAvailable; emailNode.choices.Add("d", downloadEmails); emailNode.choices.Add("r", removeEmails); emailNode.choices.Add("m", server1StartNode); downloadEmails.startTextLines.Add("Emails downloaded"); downloadEmails.onStartEvent += DownloadEmails; downloadEmails.nextNode = emailNode; removeEmails.startTextLines.Add("Emails removed"); removeEmails.onStartEvent += RemoveEmails; removeEmails.nextNode = emailNode; } { //server 2 adminNodeServer2 = new DosNode(""); var adminNameNode = new DosNode("Admin options"); var addPortForwardException = new DosNode(exceptionOption); var addedCorrectAddress = new DosNode(""); var addedSelfAddress = new DosNode(""); var addedOtherAddress = new DosNode(""); adminNameNode.startTextLines.Add("Name:"); adminNameNode.onStartEvent += SetCurrentServerAsServer2; adminNameNode.customChoiceInputAction += OnNameInput; adminNodeServer2.startTextLines.Add("Admin options:"); adminNodeServer2.choices.Add("1", addPortForwardException); adminNodeServer2.choices.Add("2", server2StartNode); addPortForwardException.startTextLines.Add(exceptionQuestionText); addPortForwardException.showChoices = false; addPortForwardException.choices.Add(WorldState.homeAddress, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress1, addedCorrectAddress); addPortForwardException.choices.Add(WorldState.serverAddress2, addedSelfAddress); addPortForwardException.choices.Add(WorldState.serverAddress3, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress4, addedOtherAddress); addedCorrectAddress.startTextLines.Add(exceptionText); addedCorrectAddress.nextNode = adminNodeServer2; addedCorrectAddress.onStartEvent += OpenServer2; addedOtherAddress.startTextLines.Add(exceptionText); addedOtherAddress.nextNode = adminNodeServer2; addedSelfAddress.startTextLines.Add(noSelfAddText); addedSelfAddress.nextNode = adminNodeServer2; //custom nodes var databaseAccess = new DosNode("Database addresses"); server2StartNode.startTextLines.Add("Wideforest institute of rehabilitation."); server2StartNode.choices.Add("1", adminNameNode); server2StartNode.choices.Add("2", databaseAccess); server2StartNode.choices.Add("3", disconnectNode); databaseAccess.startTextLines.Add("Database addresses:"); databaseAccess.startTextLines.Add("Users - " + WorldState.server2userDatabaseAddress); databaseAccess.choices.Add("1", server2StartNode); } { //server 3 var adminNameNode = new DosNode("Admin options"); var addPortForwardException = new DosNode(exceptionOption); var addedCorrectAddress = new DosNode(""); var addedSelfAddress = new DosNode(""); var addedOtherAddress = new DosNode(""); adminNameNode.startTextLines.Add("Name:"); adminNameNode.onStartEvent += SetCurrentServerAsServer3; adminNameNode.customChoiceInputAction += OnNameInput; adminNodeServer3 = new DosNode(""); adminNodeServer3.startTextLines.Add("Admin options:"); adminNodeServer3.choices.Add("add", addPortForwardException); adminNodeServer3.choices.Add("bck", server3StartNode); addPortForwardException.startTextLines.Add(exceptionQuestionText); addPortForwardException.showChoices = false; addPortForwardException.choices.Add(WorldState.homeAddress, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress1, addedOtherAddress); addPortForwardException.choices.Add(WorldState.serverAddress2, addedCorrectAddress); addPortForwardException.choices.Add(WorldState.serverAddress3, addedSelfAddress); addPortForwardException.choices.Add(WorldState.serverAddress4, addedOtherAddress); addedCorrectAddress.startTextLines.Add(exceptionText); addedCorrectAddress.nextNode = adminNodeServer3; addedCorrectAddress.onStartEvent += OpenServer3; addedOtherAddress.startTextLines.Add(exceptionText); addedOtherAddress.nextNode = adminNodeServer3; addedSelfAddress.startTextLines.Add(noSelfAddText); addedSelfAddress.nextNode = adminNodeServer3; //custom nodes var logsAccess = new DosNode("Logs"); var downloadLogs = new DosNode("Download"); server3StartNode.startTextLines.Add("Ez-Tech Mainframe - Unauthorized access forbidden"); server3StartNode.choices.Add("adm", adminNameNode); server3StartNode.choices.Add("log", logsAccess); server3StartNode.choices.Add("dis", disconnectNode); logsAccess.startTextLines.Add("Logs:"); logsAccess.choices.Add("dwn", downloadLogs); logsAccess.choices.Add("bck", server3StartNode); downloadLogs.startTextLines.Add("Success!"); downloadLogs.nextNode = server3StartNode; downloadLogs.onStartEvent += DownloadLogs; } { //server 4 server4StartNode.startTextLines.Add("Nameless proxy. Nothing to see here."); server4StartNode.choices.Add("x", disconnectNode); } }
IEnumerator ProcessProgramCoroutine(DosNode node) { scrollbar.value = 1; commandField.readOnly = true; if (node.programStartCommand != null) { yield return(new WaitForSeconds(0.2f)); textArea.text += "\nC:/> " + node.programStartCommand + "\n"; yield return(new WaitForSeconds(0.4f)); } while (node != null) { if (node.onStartEvent != null) { node.onStartEvent(); } LayoutRebuilder.ForceRebuildLayoutImmediate(scrollViewRect); commandField.readOnly = true; yield return(new WaitForSeconds(0.9f)); for (int i = 0; i < node.startTextLines.Count; i++) { textArea.text += "\n" + node.startTextLines[i]; yield return(null); scrollbar.value = 0; LayoutRebuilder.ForceRebuildLayoutImmediate(scrollViewRect); yield return(new WaitForSeconds(0.4f)); } if (node.nextNode != null) { node = node.nextNode; continue; } if (node.showChoices) { foreach (var choice in node.choices) { if (choice.Value == null) { continue; } if (node.onChoiceAvailable != null && !node.onChoiceAvailable(choice.Key)) { continue; } string name = choice.Value.name; if (choice.Value.customChoiceName != null) { name = choice.Value.customChoiceName(); } textArea.text += string.Format("\n {0} - {1}", choice.Key, name); yield return(null); scrollbar.value = 0; LayoutRebuilder.ForceRebuildLayoutImmediate(scrollViewRect); yield return(new WaitForSeconds(0.4f)); } } while (true) { commandField.readOnly = false; commandField.text = ""; yield return(null); scrollbar.value = 0; yield return(null); LayoutRebuilder.ForceRebuildLayoutImmediate(scrollViewRect); commandField.Select(); yield return(null); commandField.Select(); yield return(null); commandField.Select(); //bool notSelected = true; while (true) { // if(UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == commandField.gameObject) // { // notSelected = false; // } // else if (notSelected) // commandField.Select(); // // if(Input.anyKey) // { // commandField.Select(); // } LayoutRebuilder.ForceRebuildLayoutImmediate(scrollViewRect); if (UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == commandField.gameObject && Input.GetKeyDown(KeyCode.Return)) { break; } yield return(null); } commandField.readOnly = true; string input = commandField.text.Replace("\n", "").Trim(); commandField.text = ""; textArea.text += "\n" + input; scrollbar.value = 0; yield return(new WaitForSeconds(0.3f)); if (node.customChoiceInputAction != null) { node = node.customChoiceInputAction(input); break; } else { DosNode nextNode; if (node.choices.TryGetValue(input, out nextNode)) { node = nextNode; break; } else { textArea.text += "\nBad command"; scrollbar.value = 0; yield return(null); } } } } textArea.text += "\nProgram terminated"; programEnumerator = null; scrollbar.value = 0; }