private void Start() { _gameSynchronizer = new GameSynchronizer <GameState, InputState>(); _gameSynchronizer.SimulateGame += SimulateGame; _gameSynchronizer.SaveGame += SaveGame; _gameSynchronizer.LoadGame += LoadGame; _gameSynchronizer.BroadcastInput += BroadcastInput; _p1Handle = _gameSynchronizer.AddPlayer(PlayerType.Local); _p2Handle = _gameSynchronizer.AddPlayer(PlayerType.Remote); }
private void CreateMatchInternal(DiscordLobby lobby) { if (_lobby != null) { throw new NotImplementedException(); } _lobby = lobby; _lobby.ConnectNetwork(); _lobby.NetworkMessageReceived += NetworkMessageReceived; _synchronizer = new GameSynchronizer <GameState, InputState>(); _synchronizer.SimulateGame += SimulateGame; _synchronizer.SaveGame += SaveGame; _synchronizer.LoadGame += LoadGame; _synchronizer.BroadcastInput += BroadcastInput; _localPlayer = _synchronizer.AddPlayer(PlayerType.Local); _remotePlayer = _synchronizer.AddPlayer(PlayerType.Remote); }
private async void JoinMatchInternal(DiscordLobby lobby) { if (_lobby != null) { throw new NotImplementedException(); } await lobby.Connect(); _lobby = lobby; _lobby.ConnectNetwork(); _lobby.NetworkMessageReceived += NetworkMessageReceived; _synchronizer = new GameSynchronizer <GameState, InputState>(); _synchronizer.SimulateGame += SimulateGame; _synchronizer.SaveGame += SaveGame; _synchronizer.LoadGame += LoadGame; _synchronizer.BroadcastInput += BroadcastInput; _remotePlayer = _synchronizer.AddPlayer(PlayerType.Remote); _localPlayer = _synchronizer.AddPlayer(PlayerType.Local); _lobby.SendNetworkMessage(0, Encoding.UTF8.GetBytes("READY")); }