public void HostGame() { _server = new Server(); _server.StartListening(); var tweenGame = new TweenGame(this, _server.Map); tweenGame.Click += (o, position) => _server.HandleClick(position); _screenManager.LoadScreen(tweenGame); InitializeServerSettingsView(); }
public async Task JoinGame() { _client = new Client(); Map map = await _client.Join(); Player self = map.Players.Last().Value; // Configure Position property synchronization behaviour to highestTick to avoid player snapping back, because server version is older self.GetSyncTargetProperty(x => x.Position).SynchronizationBehaviour = SynchronizationBehaviour.HighestTick; Components.Add(_client); var tweenGame = new TweenGame(this, map); tweenGame.Click += (o, e) => { self.TargetPosition = e; _client.SendMouseClick(new Vector2(e.X, e.Y)); }; _screenManager.LoadScreen(tweenGame); }