Beispiel #1
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);
        }
    }