public static void RemoveComputer(string computer_name) { if (!computer_dict.ContainsKey(computer_name)) { Debug.Log("ERROR: RemoveComputer, no computer named " + computer_name); return; } ComponentBehavior bh = computer_dict[computer_name]; GameObject.Destroy(bh.gameObject); }
public static void doItems() { /* find the computer that brought up a menu, and call its menuItems method */ string component_name = menus.MenuLevel(1); Debug.Log("look in dict for " + component_name); if (!computer_dict.ContainsKey(component_name)) { Debug.Log("Error ComponentBehavior, doItems, not in computer_dict: " + component_name); menus.clicked = ""; return; } ComponentBehavior script = computer_dict[component_name]; int level = ccUtils.SubstringCount(menus.clicked, ":"); if (level == 1) { WindowRect = GUI.Window(1, WindowRect, script.MenuItems, "Item"); } else { string submenu = menus.MenuLevel(2); Debug.Log("submenu is <" + submenu + "> level is " + level + " clicked " + menus.clicked); switch (submenu) { case "Networks": if (level == 3) { string operation = menus.MenuLevel(3); Debug.Log("level 3, operation " + operation); if (operation == "Connect") { WindowRect = GUI.Window(2, WindowRect, script.ConnectList, operation); } else if (operation == "Disconnect") { WindowRect = GUI.Window(2, WindowRect, script.DisconnectList, operation); } } else { WindowRect = GUI.Window(3, WindowRect, script.NetworkItems, "Item"); } break; case "Configure": Debug.Log("is configure"); script.Configure(); break; } } }
public static ComponentBehavior GetNextComponent() { ComponentBehavior first_component = null; bool gotit = false; Debug.Log("GetNextComponent, num is " + computer_dict.Count); foreach (KeyValuePair <string, ComponentBehavior> entry in computer_dict) { ComponentBehavior component = entry.Value; Debug.Log("check " + component.component_name); if (!component.IsActiveComponent()) { continue; } if (gotit) { Debug.Log("got it, return " + component.component_name); current_component = component; return(component); } if (first_component == null) { first_component = component; } if (current_component == null) { Debug.Log("current is null, return " + component.component_name); current_component = component; return(component); } if (component == current_component) { gotit = true; } } Debug.Log("returning first " + first_component.component_name); current_component = first_component; return(first_component); }
// Update is called once per frame void Update() { if (Input.GetKeyDown("h")) { Debug.Log("h key is down"); Vector3 pos = GameLoadBehavior.home_pos; mainCamera.transform.rotation = GameLoadBehavior.home_rot; cameraScript.setPosition(pos); } else if (Input.GetKeyDown("u")) { UserBehavior ub = UserBehavior.GetNextUser(); //Debug.Log("next user is " + ub.user_name); if (ub == null) { Debug.Log("Error: menus, no next user"); return; } GameObject user = ub.gameObject; cameraScript.setPosition(user.transform.position); } else if (Input.GetKeyDown("?")) { Debug.Log("got dump keydown"); IPCManagerScript.SendRequest("dump_conditions"); } else if (Input.GetKeyDown("d")) { Debug.Log("got d keydown"); IPCManagerScript.SendRequest("dump_conditions"); } else if (Input.GetKeyDown("c")) { ComponentBehavior ub = ComponentBehavior.GetNextComponent(); GameObject computer = ub.gameObject; Debug.Log("next component is " + ub.component_name + " pos x" + computer.transform.position.x); cameraScript.setPosition(computer.transform.position); } else if (Input.GetMouseButtonDown(1) && !Input.GetKey(KeyCode.LeftAlt)) { menu_panels["HelpTip"].SetActive(false); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { //Debug.Log("raycast on " + hit.transform.gameObject.name); if (hit.transform.gameObject.name.StartsWith("Computer") || hit.transform.gameObject.name.StartsWith("Device")) { ComponentBehavior bh = (ComponentBehavior)hit.transform.gameObject.GetComponent(typeof(ComponentBehavior)); //computer_canvas.SetActive(true); if (hit.transform.gameObject.gameObject.name.StartsWith("Computer")) { ComputerBehavior computer_script = (ComputerBehavior)hit.transform.gameObject.GetComponent(typeof(ComputerBehavior)); //computer_script.ConfigureCanvas(); //clicked = ""; } clicked = "Component:" + bh.component_name; } else if (hit.transform.gameObject.name.StartsWith("User")) { UserBehavior bh = (UserBehavior)hit.transform.gameObject.GetComponent(typeof(UserBehavior)); clicked = "User:"******"menu"; menu_panels["HelpTip"].SetActive(false); } } } }
private void checkSelect() { if (clicked_was == "" && clicked != "") { // new click, advise engine IPCManagerScript.DialogUp(); } else if (clicked_was != "" && clicked == "" && active_screen == "office") { IPCManagerScript.DialogClosed(); } if (clicked_was == "menu" && clicked != "" && clicked != "menu") { // new click, advise engine Debug.Log("clicked is " + clicked); if (screen_dict.ContainsKey(clicked)) { IPCManagerScript.SendRequest("on_screen:" + screen_dict[clicked]); } } else if (clicked_was != "menu" && clicked_was != "" && clicked == "" && active_screen == "office") { if (screen_dict.ContainsKey(clicked_was)) { IPCManagerScript.SendRequest("on_screen:" + UI_SCREEN_OFFICE); } } clicked_was = clicked; //Debug.Log("checkSelect"); //if (clicked == "" && !inHelp && Event.current.type != EventType.MouseDown) if (clicked == "" && !inHelp) { string pplabel = "Pause"; if (GameStatusScript.isPaused()) { pplabel = "Play"; } //Debug.Log( && Event.current.type == EventType.Layout GUILayout.BeginArea(new Rect(5, 5, 150, 100)); GUILayout.BeginHorizontal(); if (GUILayout.Button(pplabel)) { //Debug.Log("got button, send " + pplabel); IPCManagerScript.SendRequest(pplabel); //startup.doUserPause(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } else if (clicked == "menu") { WindowRect = GUI.Window(1, WindowRect, MenuItemsFunc, "Menu"); } else if (clicked == "help") { Debug.Log("asked help"); //Application.OpenURL("file://" + startup.helpHome + "/README.html"); clicked = ""; } else if (clicked == "Buy") { Debug.Log("clicked Buy"); CatalogBehavior.doMenu(); } else if (clicked == "Hire") { Debug.Log("clicked Hire"); ITStaffBehavior.doItems(); } else if (clicked == "Objectives") { Debug.Log("clicked Objectives"); ObjectivesBehavior.doItems(); } else if (clicked == "Zones") { Debug.Log("clicked Zones"); ZoneBehavior.doItems(); } else if (clicked == "Save") { Debug.Log("clicked Save"); string fname = System.IO.Path.Combine(GameLoadBehavior.user_app_path, "debug_save.sdf"); IPCManagerScript.SendRequest("save:" + fname); } //else if (clicked == "Servers" || clicked == "Workstations" || clicked == "Devices" ||clicked == "Buying") else if (clicked.StartsWith("Catalog:")) { CatalogBehavior.doItems(); } else if (clicked.StartsWith("Component:")) { ComponentBehavior.doItems(); } else if (clicked.StartsWith("User:")) { UserBehavior.doItems(); } }