public void SetPassword(string group_name, Dictionary <string, bool> dict, ComputerBehavior computer)
    {
        GameObject newText = (GameObject)Instantiate(myTextPrefab);

        newText.transform.SetParent(passwordPanel);
        newText.GetComponent <Text>().text = group_name;

        foreach (KeyValuePair <string, bool> entry in dict)
        {
            //Debug.Log("SetPassword for " + entry.Key);
            GameObject newTog = (GameObject)Instantiate(procPrefab);
            newTog.transform.SetParent(passwordPanel);
            Toggle t = (Toggle)newTog.GetComponent <Toggle>();
            if (t == null)
            {
                Debug.Log("Toggle is null");
                return;
            }
            t.GetComponentInChildren <Text>().text = entry.Key;
            t.isOn = entry.Value;
            t.onValueChanged.AddListener(delegate
            {
                computer.PasswordChanged(group_name, t);
            });
        }
    }
 public void ConfigureCanvas(ComputerBehavior computer, ComputerConfigure computer_config_script)
 {
     computer_config_script.SetProc(this.proc_dict, computer);
     computer_config_script.SetPassword(PWD_LEN, this.pw_len_dict, computer);
     computer_config_script.SetPassword(PWD_CHANGE, this.pw_change_dict, computer);
     computer_config_script.SetPassword(PWD_COMPLEX, this.pw_complex_dict, computer);
 }
    public static void LoadOneComputer(string computer_file)
    {
        GameObject computer;

        computer = GameObject.Find("Computer");
        //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]");
        string cdir  = System.IO.Path.Combine(GameLoadBehavior.user_app_path, COMPUTERS);
        string cfile = System.IO.Path.Combine(cdir, computer_file);
        //Debug.Log("computer " + cdir);
        GameObject       new_c  = Instantiate(computer, new Vector3(1.0F, 0, 0), Quaternion.identity);
        ComputerBehavior script = (ComputerBehavior)new_c.GetComponent(typeof(ComputerBehavior));

        script.SetFilePath(cfile);
        new_c.SetActive(true);
        script.LoadComponent();
        script.LoadComputer();
        int pos = script.position;

        //Debug.Log("LoadComputers " + script.computer_name + " pos is " + pos);
        if (pos < 0)
        {
            Debug.Log("LoadOneComputer got invalid pos for " + script.component_name);
            return;
        }
        WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
        int   slot = ws.AddComputer(script.component_name);
        float xf, zf;

        ccUtils.GridTo3dPos(ws.x, ws.y, out xf, out zf);
        //Debug.Log(ws.x + " " + ws.y + " " + xf + " " + zf);
        Vector3 v = new Vector3(xf, 0.5f, zf);

        new_c.transform.position = v;
    }
Exemplo n.º 4
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();
    }
Exemplo n.º 5
0
    public static void LoadOneComputer(string computer_file)
    {
        GameObject computer;

        computer = GameObject.Find("Computer");
        //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]");
        string cdir  = System.IO.Path.Combine(GameLoadBehavior.user_app_path, COMPUTERS);
        string cfile = System.IO.Path.Combine(cdir, computer_file);

        Debug.Log("computer " + cdir);
        GameObject       new_c  = Instantiate(computer, new Vector3(1.0F, 0, 0), Quaternion.identity);
        ComputerBehavior script = (ComputerBehavior)new_c.GetComponent(typeof(ComputerBehavior));

        script.SetFilePath(cfile);
        new_c.SetActive(true);
        script.LoadComponent();
        script.LoadComputerInfoFromFile();
        script.hw = hw_name;
        //This is the part that will hopefully load the correct assets from dict
        SkinnedMeshRenderer this_render = new_c.GetComponent <SkinnedMeshRenderer>();

        try
        {
            this_render.sharedMesh = CatalogBehavior.object_mesh_dict[script.hw];
        } catch (KeyNotFoundException)
        {
            Debug.Log("Key Exception in object_mesh_dict caused by " + script.hw);
        }
        try
        {
            this_render.material = CatalogBehavior.object_mat_dict[script.hw];
        } catch (KeyNotFoundException)
        {
            Debug.Log("Key Exception in object_mat_dict caused by  " + script.hw);
        }
        int pos = script.position;

        //Debug.Log("LoadComputers " + script.computer_name + " pos is " + pos);
        if (pos < 0)
        {
            Debug.Log("LoadOneComputer got invalid pos for " + script.component_name);
            return;
        }
        WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
        int   slot = ws.AddComputer(script.component_name);
        float xf, zf;

        ccUtils.GridTo3dPos(ws.x, ws.y, out xf, out zf);
        //Debug.Log(ws.x + " " + ws.y + " " + xf + " " + zf);
        Vector3 v = new Vector3(xf, 0.5f, zf);

        new_c.transform.position = v;
    }
Exemplo n.º 6
0
    public void SetAssets(List <string> asset_list, ComputerBehavior computer)
    {
        asset_dropdown.ClearOptions();
        List <Dropdown.OptionData> ddo = new List <Dropdown.OptionData>();

        foreach (string asset in asset_list)
        {
            Dropdown.OptionData new_data = new Dropdown.OptionData(asset);
            ddo.Add(new_data);
            //asset_dropdown.options.Add(new Dropdown.OptionData(asset));
            Debug.Log("SetAsset adding " + asset);
        }
        asset_dropdown.AddOptions(ddo);
        Debug.Log("SetAsset done");
    }
Exemplo n.º 7
0
 public void Configure()
 {
     Debug.Log("ComponentBehavior Configure");
     if (this.gameObject.name.StartsWith("Computer"))
     {
         ComputerBehavior computer_script = (ComputerBehavior)this;
         //menus.clicked = "";
         //computer_script.ComputerConfigure();
         computer_script.HandleConfigure();
     }
     else
     {
         Debug.Log("do support for devices yet");
         menus.clicked = "";
     }
 }
    // 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();
        }
    }
 public void SetComputer(ComputerBehavior computer)
 {
     this.computer = computer;
 }
Exemplo n.º 10
0
    // 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);
                }
            }
        }
    }