예제 #1
0
    static void LoadItems()
    {
        NetworkBehavior.LoadNetworks(user_app_path);
        procedural_settings = new ProceduralScript("procedural.txt");
        physical_settings   = new ProceduralScript("physical.txt");
        Debug.Log("Calling LoadHardwareTypes");
        CatalogBehavior.LoadHardwareTypes();
        CatalogBehavior.LoadCatalog(user_app_path);
        OrganizationScript.LoadOrganization();
        GameObject      ws        = GameObject.Find("WorkSpace");
        WorkSpaceScript ws_script = (WorkSpaceScript)ws.GetComponent(typeof(WorkSpaceScript));

        WorkSpaceScript.LoadWorkSpace();
        dac_groups = new DACGroups();
        UserBehavior.LoadUsers();
        AssetBehavior.LoadAssets();
        ComputerBehavior.LoadAllComputers();
        DeviceBehavior.LoadDevices(user_app_path);
        ITStaffBehavior.LoadStaffFromFile();
        ZoneBehavior.LoadZones();
        ObjectivesBehavior.LoadObjectives();

        //UserBehavior.UpdateStatus();
        //LoadMainOffice();
    }
    // Update is called once per frame
    void Update()
    {
        float delta = Time.deltaTime;

        elapsed_since_receive += delta;
        if (elapsed_since_receive > 0.1f)
        {
            elapsed_since_receive = 0.0f;
        }
        else
        {
            return;
        }
        //Debug.Log("call receive");
        int len = ReceiveMsg();

        while (len > 0)
        {
            if (!server_ready)
            {
                if (read_string == "ready")
                {
                    Debug.Log("IPCManager got server ready");
                    server_ready = true;
                    GameLoadBehavior.AfterServerReady();
                    SendRequest("begin");
                    SendRequest("on_screen:" + menus.UI_SCREEN_OFFICE);
                }
                return;
            }
            string command = read_string;
            string message = null;
            //Debug.Log("buf [" + read_string + "]");
            if (read_string.IndexOf(':') > 0)
            {
                message = ccUtils.GetCommand(read_string, out command);
            }

            //Debug.Log("IPC update got command " + command + " message [" + message+"]");
            switch (command)
            {
            case "status":
                //Debug.Log("got status %s" + message);
                GameStatusScript.UpdateStatus(message);
                break;

            case "attack_log":
                //Debug.Log("got status %s" + message);
                AttackLogScript.AddEntry(message);
                break;

            case "load_computer":
                ComputerBehavior.LoadOneComputer(message + ".sdf");
                break;

            case "load_device":
                DeviceBehavior.LoadOneDevice(message + ".sdf");
                break;

            case "user_status":
                UserBehavior.UpdateStatus(message);
                break;

            case "ticker":
                scrolling_text.AddTicker(message);
                break;

            case "withdraw_ticker":
                scrolling_text.WithdrawTicker(message);
                break;

            case "message":
                MessageScript message_panel = (MessageScript)menus.menu_panels["MessagePanel"].GetComponent(typeof(MessageScript));
                message_panel.ShowMessage(message);
                break;

            case "yes_no":
                YesNoScript yesno_panel = (YesNoScript)menus.menu_panels["YesNoPanel"].GetComponent(typeof(YesNoScript));
                yesno_panel.ShowMessage(message);
                break;

            case "tool_tip":
                ToolTipScript.AddTip(message);
                break;

            case "objective":
                ObjectivesBehavior.ObjectiveStatus(message);
                break;

            case "phase":
                ObjectivesBehavior.PhaseDone(message);
                break;

            case "lose":
                SendRequest("exit");
                QuitGame();
                break;

            case "remove_computer":
                ComputerBehavior.RemoveComputer(message);
                break;

            default:
                Debug.Log("nothing to do for " + command + " " + message);
                break;
            }
            len = ReceiveMsg();
        }
    }
예제 #3
0
    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();
        }
    }