public static void LoadOneDevice(string device_file)
    {
        GameObject device;

        device = GameObject.Find("Device");
        //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]");
        string cdir  = System.IO.Path.Combine(user_app_path, DEVICES);
        string cfile = System.IO.Path.Combine(cdir, device_file);
        //Debug.Log("computer " + cdir);
        GameObject     new_d  = Instantiate(device, new Vector3(1.0F, 0, 0), Quaternion.identity);
        DeviceBehavior script = (DeviceBehavior)new_d.GetComponent(typeof(DeviceBehavior));

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

        //Debug.Log("LoadComputers " + script.computer_name + " pos is " + pos);
        if (pos < 0)
        {
            Debug.Log("LoadOneDevice got invalid pos for " + script.component_name);
            return;
        }
        WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
        int   slot = ws.AddDevice(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_d.transform.position = v;
    }
예제 #2
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();
    }
예제 #3
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;
    }
    public static void LoadOneStaff(string user_file)
    {
        GameObject user = GameObject.Find("ITStaff");

        if (user == null)
        {
            Debug.Log("Error: LoadOneStaff got null when finding ITStaff game object.");
            return;
        }
        //Debug.Log("user_app_path" + user_app_path + " file [" + User_file+"]");
        string cfile = System.IO.Path.Combine(GameLoadBehavior.user_app_path, user_file);

        Debug.Log("user " + cfile);
        GameObject      new_c  = Instantiate(user, new Vector3(1.0F, 0, 0), Quaternion.identity);
        ITStaffBehavior script = (ITStaffBehavior)new_c.GetComponent(typeof(ITStaffBehavior));

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

        //Debug.Log("LoadUsers " + script.User_name + " pos is " + pos);
        if (pos < 0)
        {
            Debug.Log("LoadOneStaff got invalid pos for " + script.user_name);
            return;
        }
        if (pos >= 0)
        {
            WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
            if (ws == null)
            {
                Debug.Log("ITStaffBehavior got null workspace for pos" + pos);
                return;
            }
            if (!ws.AddUser(script.user_name))
            {
                Debug.Log("ITStaffBehavior AddUser, could not user, already populated " + script.user_name);
                return;
            }
            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 - 1.0f, 0.5f, zf);
            new_c.transform.position = v;
        }
        else
        {
            Debug.Log("no postion for " + script.user_name);
        }
    }
    public static void LoadOneDevice(string device_file)
    {
        GameObject device;

        device = GameObject.Find("Device");
        //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]");
        string cdir  = System.IO.Path.Combine(user_app_path, DEVICES);
        string cfile = System.IO.Path.Combine(cdir, device_file);
        //Debug.Log("computer " + cdir);
        GameObject     new_d  = Instantiate(device, new Vector3(1.0F, 0, 0), Quaternion.identity);
        DeviceBehavior script = (DeviceBehavior)new_d.GetComponent(typeof(DeviceBehavior));

        script.SetFilePath(cfile);
        new_d.SetActive(true);
        script.LoadComponent();
        script.LoadDevice();
        script.hw = hw_name;
        SkinnedMeshRenderer this_render = new_d.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("LoadOneDevice got invalid pos for " + script.component_name);
            return;
        }
        WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
        int   slot = ws.AddDevice(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_d.transform.position = v;
    }
예제 #6
0
    public static void doItems()
    {
        if (menus.clicked == "Catalog:Buying")
        {
            Vector2 pt  = ccUtils.GetMouseGrid();
            Vector3 pos = new Vector3(pt.x, 0, pt.y);
            buying_object.transform.position = pos;
            int xout, yout, index;
            WorkSpaceScript.FindClosestWorkspaceCenter(out xout, out yout, out index);
            if (index >= 0)
            {
                WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(index);
                bool room = true;
                Debug.Log("buying object name " + buying_object.name);
                if (buying_object.name.StartsWith("Computer"))
                {
                    if (!ws.ComputerRoom())
                    {
                        room = false;
                    }
                }
                else
                {
                    if (!ws.DeviceRoom())
                    {
                        room = false;
                    }
                }
                Debug.Log("ws " + index + " usage " + ws.usage + " room? " + room);
                if (room && Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftAlt))
                {
                    Debug.Log("Catalog buy");
                    do_buy = true;
                }
            }
            else
            {
                Debug.Log("not here");
            }
        }
        else
        {
//			GUI.DrawTexture(new Rect((Screen.width / 6) - 100, 30, 200, 200), LOGO);
            WindowRect = GUI.Window(1, WindowRect, MenuItems, "Item");
        }
    }
예제 #7
0
    public static void BuyItHere()
    {
        Destroy(buying_object);
        buying_object = null;
        //int item_id = catalog_ids[buying_item];
        int outx, outy, index;

        WorkSpaceScript.FindClosestWorkspaceCenter(out outx, out outy, out index);
        // catalogName position
        XElement xml = new XElement("componentEvent",
                                    new XElement("name", ""),
                                    new XElement("buy",
                                                 new XElement("catalogName", buying_item),
                                                 new XElement("position", index)));

        Debug.Log(xml.ToString());

        IPCManagerScript.SendRequest(xml.ToString());
        menus.clicked = "";
    }
예제 #8
0
    /*public static void LoadOneUser(string user_file)
     * {
     *      GameObject user = GameObject.Find("User");
     *      //Debug.Log("user_app_path" + user_app_path + " file [" + User_file+"]");
     *      string cfile = System.IO.Path.Combine(GameLoadBehavior.user_app_path, user_file);
     *      //Debug.Log("user " + cdir);
     *      GameObject new_c = Instantiate(user, new Vector3(1.0F, 0, 0), Quaternion.identity);
     *      UserBehavior script = (UserBehavior)new_c.GetComponent(typeof(UserBehavior));
     *      script.SetFilePath(cfile);
     *      new_c.SetActive(true);
     *      script.LoadUser();
     *      int pos = script.position;
     *      //Debug.Log("LoadUsers " + script.user_name + " pos is " + pos);
     *      if (pos < 0)
     *      {
     *              Debug.Log("LoadOneUser got invalid pos for " + script.user_name);
     *              return;
     *      }
     *      if (pos >= 0)
     *      {
     *              WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
     *              if (ws == null)
     *              {
     *                      Debug.Log("UserBehavior got null workspace for pos" + pos);
     *                      return;
     *              }
     *              if (!ws.AddUser(script.user_name))
     *              {
     *                      Debug.Log("UserBehavior AddUser, could not user, already populated " + script.user_name);
     *                      return;
     *              }
     *              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 - 1.0f, 0.5f, zf);
     *              new_c.transform.position = v;
     *      }
     *      else
     *      {
     *              Debug.Log("no postion for " + script.user_name);
     *      }
     * }*/

    public static void LoadOneUser(string user_file)
    {
        string cfile = System.IO.Path.Combine(GameLoadBehavior.user_app_path, user_file);
        Dictionary <String, String> this_user_info = new Dictionary <string, string>();
        GameObject user;

        this_user_info = LoadUser(cfile, this_user_info);
        Debug.Log("LoadOneUser " + user_file);
        string this_user_gender = this_user_info["Gender"];
        string this_user_dept   = this_user_info["Dept"];

        if (this_user_dept == "Tech")
        {
            user = GameObject.Find("itstaff-obj");
        }
        else if (this_user_gender == "female")
        {
            user = GameObject.Find("femworker-obj");
        }
        else
        {
            user = GameObject.Find("maleworker-obj");
        }
        GameObject new_c = Instantiate(user, new Vector3(1.0F, 0, 0), Quaternion.identity);
        // UserBehavior script = new_c.GetComponent<UserBehavior>();
        UserBehavior script = (UserBehavior)new_c.GetComponent(typeof(UserBehavior));

        if (script == null)
        {
            Debug.Log("Error: LoadUser failed to get script for " + user_file);
            return;
        }
        script.SetFilePath(cfile);
        new_c.SetActive(true);
        //Now we can load the stuff that used to be done in LoadUser
        script.user_name = this_user_info["Name"];
        user_dict.Add(this_user_info["Name"], script);
        script.department = this_user_info["Dept"];
        if (!int.TryParse(this_user_info["PosIndex"], out script.position))
        {
            Debug.Log("Error: LoadUser parsing position" + this_user_info["PosIndex"]);
        }
        if (!int.TryParse(this_user_info["InitialTraining"], out script.training))
        {
            Debug.Log("Error: LoadUser parsing training" + this_user_info["InitialTraining"]);
        }
        int pos = script.position;

        //Debug.Log("LoadUsers " + script.user_name + " pos is " + pos);
        if (pos < 0)
        {
            Debug.Log("LoadOneUser got invalid pos for " + script.user_name);
            return;
        }
        if (pos >= 0)
        {
            WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos);
            if (ws == null)
            {
                Debug.Log("UserBehavior got null workspace for pos" + pos);
                return;
            }
            if (!ws.AddUser(script.user_name))
            {
                Debug.Log("UserBehavior AddUser, could not user, already populated " + script.user_name);
                return;
            }
            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 - 1.0f, 0.5f, zf);
            new_c.transform.position = v;
        }
        else
        {
            Debug.Log("no postion for " + script.user_name);
        }
    }