/// <summary> /// On register mediator /// </summary> public override void OnRegister() { View.GetStartGameBtn().onClick.AddListener(() => { SceneManager.LoadScene("GameArena"); }); ServerConnectedSignal.AddListener(() => { View.OnServerConnected(); }); DisconnectedFromServerSignal.AddListener(() => { View.OnServerDisconnected(); }); ShowLobbyPlayersSignal.AddListener(() => { View.ShowPlayersList(NetworkPlayerService.OnlinePlayers); }); }
public void Construct( GameStartedSignal gameStartedSignal, DisconnectedFromServerSignal disconnectedFromServerSignal, List <IGUIState> guiStates) { _gameStartedSignal = gameStartedSignal; _guiImplementations = guiStates; _disconnectedFromServerSignal = disconnectedFromServerSignal; }
/// <summary> /// Disconnect fom server /// </summary> public void DisconnectFromServer() { if (_client != null) { _client.Disconnect(); DisconnectedFromServerSignal.Dispatch(); } else { Debug.LogError("You should connect to server first"); } }
/// <summary> /// Connect to server /// </summary> /// <param name="url"></param> /// <param name="port"></param> public void Connect(string url, int port) { _client = new NetworkClient(); _client.Connect(url, port); _client.RegisterHandler(MsgType.Connect, msg => { ServerConnectedSignal.Dispatch(); }); _client.RegisterHandler(MsgType.Disconnect, mas => { DisconnectedFromServerSignal.Dispatch(); }); RegisterHandlers(new List <IServerMessageHandler> { GetEnemyTurnHandler, GetLobbyPlayerHandler, RemoveLobbyPlayerHandler }); }
public void Construct(TeamManager teamManager, CustomNetworkDiscovery networkDiscovery, ConnectedToServerSignal connectedToServerSignal, DisconnectedFromServerSignal disconnectedFromServerSignal, GameStartedSignal gameStartedSignal, BattleStatsManager battleStatsManager) { _teamManager = teamManager; _connectedToServerSignal = connectedToServerSignal; _disconnectedFromServerSignal = disconnectedFromServerSignal; _networkDiscovery = networkDiscovery; _gameStartedSignal = gameStartedSignal; _battleStatsManager = battleStatsManager; }
/// <summary> /// On register mediator /// </summary> public override void OnRegister() { ServerConnectedSignal.AddListener(() => { View.OnServerConnected(); }); DisconnectedFromServerSignal.AddListener(() => { View.OnServerDisconnected(); }); ShowLobbyPlayersSignal.AddListener(() => { View.ShowPlayersList(NetworkPlayerService.OnlinePlayers); }); }