Esempio n. 1
0
    // Update is called once per frame
    //void Update()
    //{
    //    if (isOnline)
    //    {
    //        lock (cli.sendLockObject)
    //        {

    //            Debug.Log(cli.sendTask.Count);
    //            Byte[] temp = StructToArray();
    //            cli.sendTask.Enqueue(temp);
    //            Debug.Log("Enqueue " + temp.Length );
    //        }


    //        //if (cli.recvTask.Count > 0)
    //        //{

    //        //    byte[] buf = cli.recvTask.Dequeue();
    //        //    Debug.Log("recv Pakcet" + buf.Length);

    //        //    //                StructFurniture temp = fromBytes(buf);
    //        //    //              Debug.Log(temp.name);
    //        //}


    //    }
    //}

    public void Clear()
    {
        Debug.Log("Clear Room");
        // 전체 삭제
        isLocalPlayer LocalPlayer = GameObject.Find("LocalPlayer").GetComponent <isLocalPlayer>();

        foreach (Transform child in transform)
        {
            LocalPlayer.CmdDeleteFurniture(child.gameObject);
        }

        ObjDataList obj = new ObjDataList();

        GameObject[] wallTexture = new GameObject[6];
        wallTexture[0] = GameObject.Find("Room").transform.Find("Top").gameObject;
        wallTexture[1] = GameObject.Find("Room").transform.Find("Wall1").gameObject;
        wallTexture[2] = GameObject.Find("Room").transform.Find("Wall2").gameObject;
        wallTexture[3] = GameObject.Find("Room").transform.Find("Wall3").gameObject;
        wallTexture[4] = GameObject.Find("Room").transform.Find("Wall4").gameObject;
        wallTexture[5] = GameObject.Find("Room").transform.Find("Bottom").gameObject;

        int[] walls = new int[6] {
            obj.top, obj.wall1, obj.wall2, obj.wall3, obj.wall4, obj.bottom
        };

        for (int i = 0; i < wallTexture.Length; i++)
        {
            //벽지 초기화
            LocalPlayer.CmdSetSyncWallTexture(wallTexture[i], 0, walls[0]);
            LocalPlayer.CmdSetSyncWallTexture(wallTexture[i], 0, -1);
            //wallTexture[i].GetComponent<MeshRenderer>().material.mainTexture = FurnitureTextures[walls[0]];
            //wallTexture[i].GetComponent<DropObject>().SetMaterial(FurnitureTextures[walls[0]]);
            //wallTexture[i].GetComponent<DropObject>().textureName = FurnitureTextures[walls[0]].name;
        }
    }
Esempio n. 2
0
    public void ListToFurniture(ObjDataList obj)
    {
        //가구 생성에 필요한 스크립트 호출
        isLocalPlayer LocalPlayer = GameObject.Find("LocalPlayer").GetComponent <isLocalPlayer>();


        //벽 객체 받아옴
        Debug.Log(obj.objDataList.Count);
        GameObject[] wallTexture = new GameObject[6];
        wallTexture[0] = GameObject.Find("Room").transform.Find("Top").gameObject;
        wallTexture[1] = GameObject.Find("Room").transform.Find("Wall1").gameObject;
        wallTexture[2] = GameObject.Find("Room").transform.Find("Wall2").gameObject;
        wallTexture[3] = GameObject.Find("Room").transform.Find("Wall3").gameObject;
        wallTexture[4] = GameObject.Find("Room").transform.Find("Wall4").gameObject;
        wallTexture[5] = GameObject.Find("Room").transform.Find("Bottom").gameObject;

        //저장된 리스트에서 벽지 정보 받아옴
        int[] walls = new int[6] {
            obj.top, obj.wall1, obj.wall2, obj.wall3, obj.wall4, obj.bottom
        };

        //벽지 씌워줌
        for (int i = 0; i < wallTexture.Length; i++)
        {
            if (walls[i] != -1)
            {
                LocalPlayer.CmdSetSyncWallTexture(wallTexture[i], 0, walls[i]);

                //wallTexture[i].GetComponent<MeshRenderer>().material.mainTexture = FurnitureTextures[walls[i]];
                //wallTexture[i].GetComponent<DropObject>().SetMaterial(FurnitureTextures[walls[i]]);
                //wallTexture[i].GetComponent<DropObject>().textureName = FurnitureTextures[walls[i]].name;
            }
            else
            {
                LocalPlayer.CmdSetSyncWallTexture(wallTexture[i], 0, 0);
            }
        }


        //리스트의 길이 만큼 반복
        for (int i = 0; i < obj.objDataList.Count; i++)
        {
            //가구 이름 받아옴
            string name = obj.objDataList[i].name;


            LocalPlayer.SpawnObjectRot(name, obj.objDataList[i].position, obj.objDataList[i].rotation, obj.objDataList[i].textures);


            ////이름에 맞는 가구 Prefab Load
            //GameObject NewGameObject = Resources.Load("Prefabs/" + name) as GameObject;
            ////Load 된 Prefab을 가구 정보에 맞게 생성
            //GameObject newObj = Instantiate(NewGameObject, obj.objDataList[i].position, obj.objDataList[i].rotation);
            //newObj.name = name;
            //int cnt = newObj.transform.childCount;

            ////자식 오브젝트가 없는 경우 자기 자신 오브젝트에 Drop Object
            //if (cnt == 0)
            //{
            //    //씌워진 텍스쳐가 없는 경우 혹은 Drop Object가  경우 break;
            //    if (obj.objDataList[i].textures[0] == -1) break;
            //    LocalPlayer.CmdSetSyncListInt(newObj, 0, obj.objDataList[i].textures[0]);
            //    //newObj.GetComponent<MeshRenderer>().material.mainTexture = FurnitureTextures[obj.objDataList[i].textures[0]];
            //    //newObj.GetComponent<DropObject>().SetMaterial(FurnitureTextures[obj.objDataList[i].textures[0]]);
            //    //newObj.GetComponent<DropObject>().textureName = FurnitureTextures[obj.objDataList[i].textures[0]].name;

            //}
            ////자식 오브젝트가 있는 경우 자식 오브젝트에 Drop Object
            //else
            //{
            //    for (int j = 0; j < cnt; j++)
            //    {
            //        if (newObj.transform.GetChild(j).GetComponent<MeshRenderer>() != null)
            //        {
            //            if (obj.objDataList[i].textures[j] == -1)
            //            {
            //                continue;
            //            }
            //            LocalPlayer.CmdSetSyncListInt(newObj, j, obj.objDataList[i].textures[j]);
            //            //newObj.transform.GetChild(j).GetComponent<MeshRenderer>().material.mainTexture = FurnitureTextures[obj.objDataList[i].textures[j]];
            //            //newObj.transform.GetChild(j).GetComponent<DropObject>().SetMaterial(FurnitureTextures[obj.objDataList[i].textures[j]]);
            //            //newObj.transform.GetChild(j).GetComponent<DropObject>().textureName = FurnitureTextures[obj.objDataList[i].textures[j]].name;
            //            //Debug.Log(newObj.transform.GetChild(j).GetComponent<DropObject>().textureName);
            //        }

            //    }
            //}
        }
    }