Inheritance: MonoBehaviour
Example #1
0
 public ChatMessageAction(Func <ChatMessage, bool> func, bool removeOnSuccess, LobbyController lc, EventRunner eventRunner)
 {
     _func           = func;
     RemoveOnSuccess = removeOnSuccess;
     _lc             = lc;
     _evRunner       = eventRunner;
 }
Example #2
0
 public void JoinRoom(LobbyController controller)
 {
     Debug.Log ("Join room");
     string name = controller.NameText;
     string room = controller.RoomText;
     JoinRoom (name, room);
 }
Example #3
0
        public async Task ChangeComment(DiscordGuild guild, DiscordChannel channel, DiscordUser user, string comment)
        {
            var lobby = await LobbyController.GetLobby(_context, guild, channel, user);

            lobby.Comment = comment;
            await LobbyController.UpdateLobby(_context, lobby);
        }
        public void OpretLobby_PostRedirectToActionUserLogged_on_RedirectsToLobby()
        {
            // Arrange
            var mockUserSession = new Mock <IUserSession>();

            mockUserSession.Setup(x => x.User).Returns(_savedUser);

            ILobby MockedLobby = new Lobby(_savedUser.Username);

            MockedLobby.Id = _lobbyViewModel.Id;

            var mockLobbyProxy = new Mock <ILobbyProxy>();

            mockLobbyProxy
            .Setup(x => x.CreateInstanceAsync(_lobbyViewModel.Id, _savedUser.Username, _savedUser.Password))
            .Returns(Task.FromResult(MockedLobby));

            var sut = new LobbyController(FakeSwagCommunication, mockLobbyProxy.Object, mockUserSession.Object);

            // Act
            var result = (RedirectToActionResult)sut.OpretLobby(_lobbyViewModel);

            //Assert
            Assert.AreEqual("Lobby", result.ActionName);
        }
        public void TilslutLobby_UserOKreturnsLobbyView()
        {
            // Arrange
            var mockUserSession = new Mock <IUserSession>();

            mockUserSession.Setup(x => x.User).Returns(_savedUser);

            List <string> lobbies = new List <string>();

            lobbies.Add("test");

            var mockLobbyProxy = new Mock <ILobbyProxy>();

            mockLobbyProxy
            .Setup(x => x.GetAllLobbyIdsAsync(_savedUser.Username, _savedUser.Password))
            .ReturnsAsync(lobbies);

            var sut = new LobbyController(FakeSwagCommunication, mockLobbyProxy.Object, mockUserSession.Object);

            //act
            var result    = sut.TilslutLobby() as ViewResult;
            var viewModel = result.Model as TilslutLobbyViewModel;

            //assert
            Assert.That(viewModel.Lobbies.Count, Is.EqualTo(lobbies.Count));
        }
        public void TilslutLobby_PostRedirectToActionUserLogged_on_LobbyVMOK()
        {
            // Arrange
            var mockUserSession = new Mock <IUserSession>();

            mockUserSession.Setup(x => x.User).Returns(_savedUser);

            ILobby MockedLobby = new Lobby(_savedUser.Username);

            MockedLobby.Id = _lobbyViewModel.Id;

            var mockLobbyProxy = new Mock <ILobbyProxy>();

            mockLobbyProxy
            .Setup(x => x.JoinLobbyAsync(_lobbyViewModel.Id, _savedUser.Username, _savedUser.Password))
            .Returns(Task.FromResult(MockedLobby));

            var sut = new LobbyController(FakeSwagCommunication, mockLobbyProxy.Object, mockUserSession.Object);

            // Act
            var result = (RedirectToActionResult)sut.TilslutLobby(_lobbyViewModel);

            //Assert
            Assert.That(result.RouteValues.Values.Contains("test"));              //see that lobby id is indeed test
            Assert.That(result.RouteValues.Values.Contains(_savedUser.Username)); //see that the username is in the lobbyVM
        }
        /// <summary>
        /// Once all players are ready, adds players to the Game controller and starts the game
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void start_game_Click(object sender, EventArgs e)
        {
            var ds  = NetworkClasses.GetServer(User.PlayerId, User.LocalIp);
            var row = ds.Tables[0].Rows[0];

            var grabber = NetworkClasses.GetPlayer(int.Parse(row["Host"].ToString()));

            //Host
            LobbyController.AddPlayer(int.Parse(grabber.Tables[0].Rows[0]["Player_ID"].ToString()), grabber.Tables[0].Rows[0]["_Character"].ToString());

            for (var i = 2; i <= 6; i++)
            {
                if (string.IsNullOrEmpty(row["Player_" + i].ToString()))
                {
                    continue;
                }
                grabber = NetworkClasses.GetPlayer(int.Parse(row["Player_" + i].ToString()));
                LobbyController.AddPlayer(int.Parse(grabber.Tables[0].Rows[0]["Player_ID"].ToString()), grabber.Tables[0].Rows[0]["_Character"].ToString());
            }
            NetworkClasses.UpdateServerValue("Status", "In Progress", "Host", User.PlayerId);
            NetworkClasses.UpdateUserValue("User_List", "Online", "In Game", User.PlayerId);
            LobbyController.StartGame();
            Host.StartGame();
            _timer.Stop();
            //_chat.Dispose();
            _gameTimer.Start();
            if (!_profile.IsDisposed)
            {
                _profile.Dispose();
            }
            Hide();

            //MainMenuForm waiter = new MainMenuForm();
            //waiter.Show();
        }
 void Awake()
 {
     //clientName = MyGameManager.user.Name;
     chatUI          = FindObjectOfType <ChatUI>();
     lobbyUI         = FindObjectOfType <LobbyUI>();
     lobbyController = FindObjectOfType <LobbyController>();
 }
Example #9
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
    public override void OnJoinedRoom()
    {
        LobbyController delayStartLobby  = FindObjectOfType <LobbyController>();
        string          selectedGameMode = delayStartLobby.getGameMode();

        Debug.Log(selectedGameMode);
        if (selectedGameMode == "delay")
        {
            SceneManager.LoadScene(waitingRoomSceneIndex);
        }
        else if (selectedGameMode == "priv")
        {
            roomPanel.SetActive(true);
            lobbyPanel.SetActive(false);
            roomNameDisplay.text = PhotonNetwork.CurrentRoom.Name;
            if (PhotonNetwork.IsMasterClient)
            {
                masterClientObjects.SetActive(true);
            }
            else
            {
                masterClientObjects.SetActive(false);
            }
            ClearPlayerListings();
            ListPlayers();
        }
        else
        {
            SceneManager.LoadScene(gameRoomSceneIndex);
        }
    }
Example #11
0
    public override void EnableLayer()
    {
        base.EnableLayer();
        if (Database.Instance.islogin)
        {
            objHeadPrepareLogin.SetActive(false);
            objHeadLogined.SetActive(true);
        }
        else
        {
            objHeadLogined.SetActive(false);
            objHeadPrepareLogin.SetActive(true);

            // Get Pass, acount Saved
            GetPassSaveLocal();
        }

        if (lobbyController == null)
        {
            lobbyController = GetComponent <LobbyController>();
            lobbyController.Init(this);
        }
        else
        {
            lobbyController.Show();
        }

        AudioAssistant.Instance.PlayMusic(StringHelper.SOUND_GATE_BG);
        SetSoundAndMusic();
    }
Example #12
0
    public void OnDeviceDisconnected(int deviceId)
    {
        if (_currentGameState == GameState.OnLobby)
        {
            var indexOfPlayerWithDeviceId = IndexOfPlayerWithDeviceId(deviceId);
            if (indexOfPlayerWithDeviceId >= 0)
            {
                var globalPlayer    = _globalPlayers[indexOfPlayerWithDeviceId];
                var lobbyController = LobbyController.FindInScene();

                lobbyController.OnLobbyPlayerDisconnected(globalPlayer.LobbyPlayerData.Id);

                // Tell the Lobby that this guy has disconnected
                _globalPlayers.RemoveAt(indexOfPlayerWithDeviceId);
            }
        }
        else if (_currentGameState == GameState.OnGame)
        {
            IPlayerToGameStateBridge gameCharacter;
            if (_deviceIdToGameCharacterMap.TryGetValue(deviceId, out gameCharacter))
            {
                gameCharacter.DeviceId = 0; // No device Id
            }
        }
    }
Example #13
0
        public void LobbyConnectedUsersTest()
        {
            var lobbyController = new LobbyController(_dbservmock.Object);
            var actual          = lobbyController.Get();

            actual.Should().BeEquivalentTo(_users);
        }
Example #14
0
        public async Task AddArena(Lobby data)
        {
            var existingLobby = await LobbyController.GetLobby(_context, data.GuildId, data.ChannelId, data.OwnerId);

            if (existingLobby != null)
            {
                existingLobby.RoomId      = data.RoomId;
                existingLobby.Password    = data.Password;
                existingLobby.Comment     = data.Comment;
                existingLobby.PublishTime = data.PublishTime;
                await LobbyController.UpdateLobby(_context, existingLobby);
            }
            else
            {
                var key = new { gId = data.GuildId, cId = data.ChannelId, uId = data.OwnerId };
                await LobbyController.CreateLobby(_context, data);

                var timerData = new TimerData {
                    timeSpan = _arenaTimeSpan
                };
                timerData.callback += async() => await Pop(data.GuildId, data.ChannelId, data.OwnerId);

                _deleteTimerService.SaveData(key, timerData);
            }
        }
Example #15
0
    public void OnSetReadyMessage(int deviceId, SetReadyMessage setReadyMessage)
    {
        var playerIndex = IndexOfPlayerWithDeviceId(deviceId);

        if (playerIndex < 0)
        {
            return;
        }

        if (_currentGameState == GameState.OnLobby)
        {
            var globalPlayer = _globalPlayers[playerIndex];
            globalPlayer.LobbyPlayerData.IsReady = setReadyMessage.IsReady;

            var lobbyController = LobbyController.FindInScene();
            lobbyController.OnLobbyPlayerDataChanged(globalPlayer.LobbyPlayerData);
            AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
        }
        else if (_currentGameState == GameState.OnGame)
        {
            IPlayerToGameStateBridge playerOnGame;
            if (_deviceIdToGameCharacterMap.TryGetValue(deviceId, out playerOnGame))
            {
                playerOnGame.OnSetReadyMessage(setReadyMessage);
            }
        }
    }
Example #16
0
    public void OnSetAvatarIndexMessage(int deviceId, SetAvatarIndexMessage setAvatarIndexMessage)
    {
        var playerIndex = IndexOfPlayerWithDeviceId(deviceId);

        if (playerIndex < 0)
        {
            return;
        }

        var globalPlayer = _globalPlayers[playerIndex];

        if (globalPlayer.AvatarIndex != setAvatarIndexMessage.AvatarIndex)
        {
            if (_currentGameState == GameState.OnLobby && IsAvatarAvailable(setAvatarIndexMessage.AvatarIndex))
            {
                globalPlayer.AvatarIndex = setAvatarIndexMessage.AvatarIndex;
                var lobbyController = LobbyController.FindInScene();

                lobbyController.OnLobbyPlayerDataChanged(globalPlayer.LobbyPlayerData);
            }

            AirConsoleBridge.Instance.SendOrUpdateAvatarForPlayer(globalPlayer);
            AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
        }
    }
Example #17
0
        public List <IPlayer> Static(IMatch match)
        {
            var players     = new List <IPlayer>();
            var roleEntries = new List <RoleEntry>();

            foreach (var selector in Selectors)
            {
                if (!selector.First(roleEntries))
                {
                    throw new ArgumentException($"No first role found for selector {selector}");
                }
            }

            for (var i = 0; i < roleEntries.Count; i++)
            {
                var roleEntry  = roleEntries[i];
                var role       = new Role(roleEntry);
                var controller = new LobbyController($"Bot {i + 1}", null);
                var player     = new Player(controller, match, i + 1, controller.Name, role);

                players.Add(player);
            }

            return(players);
        }
Example #18
0
        public ILobbyController Add(string name, Guid id)
        {
            var controller = new LobbyController(name, id, this);

            _controllers.Add(controller);
            return(controller);
        }
Example #19
0
    public void JoinRoom(LobbyController controller)
    {
        Debug.Log("Join room");
        string name = controller.NameText;
        string room = controller.RoomText;

        JoinRoom(name, room);
    }
Example #20
0
 //Singleton
 private void Awake()
 {
     if (lobby != this)
     {
         Destroy(lobby);
     }
     lobby = this;
 }
Example #21
0
    private void RegisterPlayerInLobby(GlobalPlayer globalPlayer)
    {
        var lobbyController = LobbyController.FindInScene();

        lobbyController.OnLobbyPlayerConnected(globalPlayer.LobbyPlayerData);
        AirConsoleBridge.Instance.SendOrUpdateAvatarForPlayer(globalPlayer);
        AirConsoleBridge.Instance.BroadcastCharacterSetChanged(_globalPlayers);
    }
Example #22
0
 public static LobbyController getInstance()
 {
     if (_instance == null)
     {
         _instance = new LobbyController();
     }
     return(_instance);
 }
    Game GetGameFromConnection(int connectionId)
    {
        LobbyController lc = (LobbyController)_lobbyController
                             .GetComponent(typeof(LobbyController));
        int gameNumber = lc._gameConnections[connectionId];

        return(lc._games[gameNumber]);
    }
Example #24
0
 public LobbyForm()
 {
     InitializeComponent();
     _lobbyController = new LobbyController();
     Globals.Network.ConnectedToServerHandler += Network_ConnectedToServerHandler;
     MMessageBus.LobbyLoadedHandler           += MMessageBus_LobbyLoadedHandler;
     MMessageBus.LobbyLoadRequestHandler      += MMessageBus_LobbyLoadRequestHandler;
 }
	/**
	 * Runs at load time
	 */
	void Start () {
		gameController = GameController.S;
		lobbyController = LobbyController.S;
		multiplayerController = MultiplayerController.S;
		networkController = NetworkController.S;
		uiController = UIController.S;

		// Setup the UI's buttons
		construct ();
	}
	private GameController gameController = null; //!< The local reference to the game controller
	#endregion

	#region Unity methods /// @name Unity methods
	/**
	 * Called when the script is loaded, before the game starts
	 */
	void Awake () {
		S = this;

		// Get the controller
		gameController = GameController.S;

		// Initialize the arrays
		players = new Dictionary<string, GameObject> ();
		playerScripts = new Dictionary<string, LobbyPlayerController> ();
	}
Example #27
0
 public Lobby(Guid id, string hostName, Guid hostId, Setup setup = null)
 {
     Id           = id;
     Setup        = setup ?? new Setup();
     Host         = new LobbyController(hostName, hostId, this);
     _controllers = new List <ILobbyController> {
         Host
     };
     Started = false;
 }
Example #28
0
 public UpdateSettings(LobbyController lc, EventRunner evr) : base(lc, evr)
 {
     _settingParsers = new Dictionary <string, Action <string> >()
     {
         { "room name: ", new Action <string>(s => ((Settings)lc.Settings).RoomName = s) },
         { "history: ", new Action <string>(s => ((Settings)lc.Settings).HistoryUrl = s) },
         { "team mode: ", new Action <string>(s => ((Settings)lc.Settings).TeamMode = Enum.Parse <TeamMode>(s)) },
         { "win condition: ", new Action <string>(s => ((Settings)lc.Settings).WinCondition = Enum.Parse <WinCondition>(s)) }
     };
 }
Example #29
0
        public async Task <Lobby> Pop(ulong guild, ulong channel, ulong user)
        {
            var lobby = await LobbyController.PopLobby(_context, guild, channel, user);

            if (lobby != null)
            {
                _deleteTimerService.RemoveData(new { gId = guild, cId = channel, uId = user });
                return(lobby);
            }
            return(lobby);
        }
Example #30
0
        public async Task LobbyRemoveUserTest()
        {
            var lobbyController = new LobbyController(_dbservmock.Object);
            await lobbyController.DeleteAsync("5");

            foreach (UserModel user in _users)
            {
                user.Name.Should().NotBeEquivalentTo("Max");
            }
            _users.Should().HaveCount(5);
        }
Example #31
0
        public async Task LobbyAddUserTest()
        {
            var lobbyController = new LobbyController(_dbservmock.Object);
            var newUser         = new UserModel()
            {
                Name = "newGuy"
            };
            await lobbyController.PostAsync(newUser);

            _users.Should().Contain(newUser);
        }
Example #32
0
        public async Task MakeArenaGlobal(DiscordGuild guild, DiscordChannel channel, DiscordUser user)
        {
            var lobby = await LobbyController.GetLobby(_context, guild, channel, user);

            if (lobby.Global)
            {
                return;
            }
            lobby.Global = true;
            await LobbyController.UpdateLobby(_context, lobby);
        }
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
Example #34
0
	/**
	 * Runs at load time
	 */
	void Start () {
		gameController = GameController.S;
		lobbyController = LobbyController.S;
	}
	public void CmdJoinServer (string playerName) {
		// Reset the countdown
		gameController.resetCountdown ();

		// Ensure that the lobby is shown
		tvUIController.showUI ("Lobby");

		// Get the lobby controller
		lobbyController = LobbyController.S;

		// Pass on the player's name to the method that joins the lobby
		lobbyController.addPlayerToLobby (playerName);
	}
Example #36
0
 void Start()
 {
     _lobby = gameObject.GetComponent<LobbyController>();
     Init();
 }
Example #37
0
 public void RegisterController(LobbyController controller)
 {
     this.controller = controller;
 }
Example #38
0
 void Awake()
 {
     if (_instance == null) _instance = this;
 }
Example #39
0
 void Start()
 {
     _playerPrefab = NetworkManager.singleton.playerPrefab;
     _lobby = gameObject.GetComponent<LobbyController>();
     Init ();
 }