Exemple #1
0
    private void  fromJSONRoomsList(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONArrayValue json_array1 = json_value.array_value();

        if (json_array1 == null)
        {
            throw new Exception("The value for field RoomsList of RobotSetKnownRoomsCommandIntentJSON is not an array.");
        }
        int             count1            = json_array1.componentCount();
        List <RoomJSON> vector_RoomsList1 = new List <RoomJSON>(count1);

        for (int num1 = 0; num1 < count1; ++num1)
        {
            RoomJSON convert_classy = RoomJSON.from_json(json_array1.component(num1), ignore_extras, true);
            vector_RoomsList1.Add(convert_classy);
        }
        initRoomsList();
        for (int num1 = 0; num1 < vector_RoomsList1.Count; ++num1)
        {
            appendRoomsList(vector_RoomsList1[num1]);
        }
        for (int num1 = 0; num1 < vector_RoomsList1.Count; ++num1)
        {
        }
    }
Exemple #2
0
    private void  fromJSONRoom(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        RoomJSON convert_classy = RoomJSON.from_json(json_value, ignore_extras, true);

        setRoom(convert_classy);
    }
Exemple #3
0
    private void removeRoom(SocketIOEvent e)
    {
        Debug.Log("Server => removeRoom" + e.data);
        string   data = e.data.ToString();
        RoomJSON user = RoomJSON.CreateFromJSON(data);

        Destroy(uiManger.Rooms[user.name]);
    }
Exemple #4
0
 public void setRoom(RoomJSON new_value)
 {
     if (flagHasRoom)
     {
     }
     flagHasRoom = true;
     storeRoom   = new_value;
 }
 public void appendValue(RoomJSON to_append)
 {
     if (!flagHasValue)
     {
         flagHasValue = true;
         storeValue.Clear();
     }
     Debug.Assert(flagHasValue);
     storeValue.Add(to_append);
 }
Exemple #6
0
 public void appendRoomsList(RoomJSON to_append)
 {
     if (!flagHasRoomsList)
     {
         flagHasRoomsList = true;
         storeRoomsList.Clear();
     }
     Debug.Assert(flagHasRoomsList);
     storeRoomsList.Add(to_append);
 }
    public Room Convert(RoomJSON roomJSON)
    {
        Room.Floor       floor = new Room.Floor(roomJSON.size);
        List <Room.Wall> walls = new List <Room.Wall>();

        List <List <int[]> > wallLines = new List <List <int[]> >();

        wallLines.Add(roomJSON.outerpoints);
        wallLines.AddRange(roomJSON.innerpoints);

        List <Room.Door> windowsAndDoors = new List <Room.Door>();

        foreach (List <int[]> points in wallLines)
        {
            for (int i = 0; i < points.Count - 1; i++)
            {
                int[] p1 = points[i];
                int[] p2 = points[i + 1];

                Vector3Int origin     = new Vector3Int(Mathf.Min(p1[0], p2[0]), 0, Mathf.Min(p1[1], p2[1]));
                bool       isVertical = (p1[0] == p2[0]);
                Room.Wall  wall       = new Room.Wall(origin, isVertical,
                                                      Mathf.Max(Mathf.Abs(p2[0] - p1[0]), Mathf.Abs(p2[1] - p1[1])),
                                                      Mathf.RoundToInt(roomJSON.ceiling * 100));

                foreach (RoomJSON.Door door in roomJSON.door)
                {
                    if (wall.isDoorOn(door))
                    {
                        //int x1 = door.point_1[0];
                        //int x2 = door.point_2[0];
                        //int z1 = door.point_1[1];
                        //int z2 = door.point_2[1];
                        //// Debug.Log(string.Format("wall: [({0}, {1}), ({2}, {3})]\ndoor: [({4}, {5}), ({6}, {7})]",
                        //    p1[0], p1[1], p2[0], p2[1], x1, z1, x2, z2));
                        if (door.height_1 == 0)
                        {
                            wall.addDoor(door);
                        }
                        else
                        {
                            wall.addWindow(door);
                        }
                        break;
                    }
                }
                walls.Add(wall);
            }
        }

        return(new Room(floor, walls));
    }
Exemple #8
0
    //===========================================
    //===========================================

    //===========================================
    //MainGame CallBack function
    //===========================================
    private void GameInit(SocketIOEvent e)
    {
        Debug.Log("Server => Welcom to the Room of " + ClientStatus.currentingRoom);
        string data = e.data.ToString();

        Debug.Log(data);
        RoomJSON roomJSON = RoomJSON.CreateFromJSON(data);

        ClientStatus.currentUUID = roomJSON.currnetUUID;
        if (gameMangerOBJ == null)
        {
            gameMangerOBJ = Instantiate(gameMangerPrefab);
        }
    }
Exemple #9
0
    /// <summary>
    ///
    /// </summary>
    public void join_Room(Room target)
    {
        RoomJSON data = new RoomJSON();

        ClientStatus.currentingRoom = target.Name;
        data.name = target.Name;
        data.UUID = ClientStatus.UUID;
        //data.index = target.index;


        string Data = RoomJSON.CreateToJSON(data);

        socket.Emit("joinRoom", new JSONObject(Data));
        Destroy(target.gameObject);

        mainCanvas.gameObject.SetActive(false);
    }
Exemple #10
0
        protected override void finish()
        {
            RoomJSON result = new RoomJSON();

            Debug.Assert(result != null);
            finish(result);
            int extra_count = unknownFieldGenerator.field_names.Count;

            Debug.Assert(extra_count == unknownFieldGenerator.field_values.Count);
            for (int extra_num = 0; extra_num < extra_count; ++extra_num)
            {
                result.extraRoomAppendPair(unknownFieldGenerator.field_names[extra_num], unknownFieldGenerator.field_values[extra_num]);
            }
            unknownFieldGenerator.field_names.Clear();
            unknownFieldGenerator.field_values.Clear();
            unknownFieldGenerator.index = new Dictionary <string, JSONValue>();
            handle_result(result);
        }
Exemple #11
0
    public void CreateRoom()
    {
        if (inputField.text.Equals(""))
        {
            return;
        }

        RoomJSON data = new RoomJSON();

        ClientStatus.currentingRoom = inputField.text;
        data.name = inputField.text;
        data.UUID = ClientStatus.UUID;

        string Data = RoomJSON.CreateToJSON(data);

        socket.Emit("creatRoom", new JSONObject(Data));

        socket.Emit("joinRoom", new JSONObject(Data));
        mainCanvas.gameObject.SetActive(false);
        inputField.text = "";
    }
    void LoadRoom()
    {
        Dictionary <string, string> parameters = new Dictionary <string, string>();

        parameters.Add("function", "GetRoomInfofile");
        parameters.Add("model_id", login.model_id);

        string json = http.Get("http://" + LoginManager.host + ":" + LoginManager.port + "/model", parameters);

        //// Debug.Log("new room: " + json);
        //// Debug.Log("old room: " + http.GetTestJSON());

        //string json = httpRequest.GetTestJSON();

        roomJSON = roomParser.Parse(json);
        Room       room    = roomParser.Convert(roomJSON);
        GameObject roomObj = room.GenerateRoom();

        GameObject[] floors = GameObject.FindGameObjectsWithTag("floor");
        foreach (GameObject fo in floors)
        {
            fo.AddComponent <Teleportable>();
            fo.AddComponent <Teleportable>().target       = target;
            fo.AddComponent <Teleportable>().pivot        = pivot;
            fo.AddComponent <Teleportable>().fadeDuration = fadeDuration;
        }

        ModelLoader loader = new ModelLoader();

        foreach (RoomJSON.Product p in roomJSON.product)
        {
            GameObject obj = loader.LoadModelFromDir(p.product_id);
            obj.transform.position = new Vector3(p.position[0], p.position[1], p.position[2]);
            obj.transform.Rotate(new Vector3(0, p.rotation, 0));
            //// Debug.Log("Load product: " + p.product_id);
        }

        MoveCamera(room);
    }
Exemple #13
0
    public void UpdateRoom(SocketIOEvent e)
    {
        string   data     = e.data.ToString();
        RoomJSON roomJSON = RoomJSON.CreateFromJSON(data);

        var obj = Instantiate(RoomOBJ) as GameObject;

        obj.transform.SetParent(Scroll_View_Content.transform);

        RectTransform rectTransform = obj.GetComponent <RectTransform>();
        Room          room          = obj.GetComponent <Room>();

        rectTransform.anchoredPosition3D = new Vector3(0, 0, 0);
        rectTransform.localScale         = new Vector3(1, 1, 1);
        room.uiManger = this;
        room.Name     = roomJSON.name;
        room.index    = roomJSON.index;
        room.UUID     = roomJSON.UUID;
        //room.currnetUUID.Add(roomJSON.UUID);

        Rooms.Add(room.Name, obj);
    }
Exemple #14
0
 protected void finish(RoomJSON result)
 {
     if (fieldGeneratorName.have_value)
     {
         result.setName(fieldGeneratorName.value);
         fieldGeneratorName.have_value = false;
     }
     else if ((!(result.hasName())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"Name\" field was missing.");
     }
     if (fieldGeneratorDeterminerMentioned.have_value)
     {
         result.setDeterminerMentioned(fieldGeneratorDeterminerMentioned.value);
         fieldGeneratorDeterminerMentioned.have_value = false;
     }
     if (fieldGeneratorUUID.have_value)
     {
         result.setUUID(fieldGeneratorUUID.value);
         fieldGeneratorUUID.have_value = false;
     }
 }
Exemple #15
0
    void LateUpdate()
    {
        if (ClientStatus.GameOver)
        {
            RoomJSON data = new RoomJSON();
            data.name = ClientStatus.currentingRoom;
            data.UUID = ClientStatus.UUID;
            string Data = RoomJSON.CreateToJSON(data);
            socket.Emit("joinlobby", new JSONObject(Data));

            ClientStatus.currentingRoom = "lobby";
            Destroy(Players[ClientStatus.currentUUID[0]]);
            Destroy(Players[ClientStatus.currentUUID[1]]);
            Destroy(Ball);
            ClientStatus.currentUUID[0] = "";
            ClientStatus.currentUUID[1] = "";

            uimager.ReturnLobby();
            Destroy(this.gameObject);
            ClientStatus.GameOver = false;
        }
    }
Exemple #16
0
 public static string CreateToJSON(RoomJSON data)
 {
     return(JsonUtility.ToJson(data));
 }
Exemple #17
0
 protected override void handle_result(RoomJSON result)
 {
     top.value.Add(result);
 }
Exemple #18
0
        protected override void handle_result(RoomJSON result)
        {
//@@@            Debug.Assert(!have_value);
            have_value = true;
            value      = result;
        }
Exemple #19
0
 protected abstract void handle_result(RoomJSON new_result);