예제 #1
0
    // for each listed room, set a join button from the available button/slots
    void OnGUI()
    {
        if (!gamesPanel.gameObject.GetActive())
        {
            return;
        }

        foreach (RoomJoiner bt in roomButtons)
        {
            bt.gameObject.SetActive(false);
        }

        int index = 0;

        foreach (RoomInfo game in PhotonNetwork.GetRoomList())
        {
            if (index >= roomButtons.Length || !game.open)
            {
                break;
            }
            RoomJoiner button = roomButtons[index++];
            button.gameObject.SetActive(true);
            button.RoomName = game.name;
            string info = game.name.Trim() + " (" + game.playerCount + "/" + game.maxPlayers + ")";
            button.GetComponentInChildren <Text>().text = info;
        }
    }
예제 #2
0
        public void TestCanCreateRoomWithNullCode()
        {
            var chameleonGame = new Mock <IChameleonGame>();
            var roomJoiner    = new RoomJoiner(chameleonGame.Object);

            const string requestBody = "{\"PersonName\": \"Anita\", \"RoomCode\": null}";

            roomJoiner.Join(requestBody);

            chameleonGame.Verify(x => x.CreateRoom("Anita"), Times.Once);
        }
예제 #3
0
        public void TestErrorsIfPersonNameIsEmpty()
        {
            var chameleonGame = new Mock <IChameleonGame>();
            var roomJoiner    = new RoomJoiner(chameleonGame.Object);

            const string requestBody = "{\"PersonName\": \"\", \"RoomCode\": \"ABCD\"}";

            Assert.Throws <PersonNameMustBeSpecifiedException>(() => { roomJoiner.Join(requestBody); });

            chameleonGame.Verify(x => x.CreateRoom(It.IsAny <string>()), Times.Never);
            chameleonGame.Verify(x => x.JoinRoom(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }