示例#1
0
    public void submitPasswordJoinRoom()
    {
        disableButton(submitPasswordJoinButton);
        submitPasswordJoinCountDown = 1;
        ROOM_INFOS chooseRoomInfo = ((Dictionary <string, ROOM_INFOS>)Init.Datas["roomsInfo"])[chooseRoom.name];

        Debug.LogFormat("正在加入房间,key:{0},password:{1}", chooseRoomInfo.roomKey, joinRoomPasswordInput.text);
        KBEngine.Event.fireIn("reqJoinRoom", chooseRoomInfo.roomKey, joinRoomPasswordInput.text);
    }
示例#2
0
    public void onReqRoomsByParams(List <ROOM_INFOS> roomList)
    {
        //移除原列表
        for (int i = 0; i < roomListPanel.transform.childCount; i++)
        {
            Destroy(roomListPanel.transform.GetChild(i).gameObject);
        }

        Dictionary <string, ROOM_INFOS> roomsInfo = (Dictionary <string, ROOM_INFOS>)Init.Datas["roomsInfo"];

        roomsInfo.Clear();


        for (int i = 0; i < roomList.Count; i++)
        {
            ROOM_INFOS room = roomList[i];
            roomsInfo.Add(room.roomKey + "", room);
            Debug.LogFormat("room name:{0},intro:{1},playerCount:{2},isPlaying:{3},hasPassword:{4}", room.name, room.intro, room.playerCount, room.isPlaying, room.hasPassword);
            GameObject roomInfoPanel = Instantiate(Resources.Load("perfabs/RoomInfo")) as GameObject;
            roomInfoPanel.name = room.roomKey + "";
            Transform[] infos = roomInfoPanel.GetComponentsInChildren <Transform>();
            for (int j = 0; j < infos.Length; j++)
            {
                Transform transform = infos[j];
                if (transform.name == "Name")
                {
                    transform.GetComponent <Text>().text = room.name as string;
                }
                else if (transform.name == "Intro")
                {
                    transform.GetComponent <Text>().text = room.intro as string;
                }
                else if (transform.name == "Lock")
                {
                    transform.GetComponent <Image>().enabled = (byte)room.hasPassword == 1 ? false : true;
                }
                else if (transform.name == "PlayerCount")
                {
                    transform.GetComponent <Text>().text = room.playerCount + "/3";
                }
                else if (transform.name == "IsPlaying")
                {
                    transform.GetComponent <Text>().text = (byte)room.isPlaying == 1 ? "准备中" : "游戏中";
                }
            }
            roomInfoPanel.transform.SetParent(roomListPanel, false);
            float top    = roomListPanel.GetComponent <RectTransform>().offsetMax.y;
            float bottom = top + (270 - roomList.Count * 47 + 5);
            roomListPanel.GetComponent <RectTransform>().offsetMin = new Vector2(roomListPanel.GetComponent <RectTransform>().offsetMin.x, bottom);
        }
    }
示例#3
0
    public void joinRoom()
    {
        disableButton(joinButton);
        joinCountDown = 1;
        Debug.LogFormat("roomkey:{0}", chooseRoom.name);
        ROOM_INFOS chooseRoomInfo = ((Dictionary <string, ROOM_INFOS>)Init.Datas["roomsInfo"])[chooseRoom.name];

        if ((byte)chooseRoomInfo.hasPassword == 1)
        {
            Debug.LogFormat("正在加入房间,key:{0}", chooseRoomInfo.roomKey);
            KBEngine.Event.fireIn("reqJoinRoom", chooseRoomInfo.roomKey, "");
            //SceneManager.LoadScene("Room");
        }
        else
        {
            openPasswordInputPanel();
        }
    }