public DedicatedServerLogic(AssaultWing game)
     : base(game)
 {
     var dedicatedServer = new DedicatedServer(game, 13);
     game.Components.Add(dedicatedServer);
     dedicatedServer.Enabled = true;
 }
 /// <summary>
 /// Creates a new connection to a management server that works solely on UDP.
 /// </summary>
 public ManagementServerConnection(AssaultWing game, IPEndPoint managementServerEndPoint)
     : base(game)
 {
     Name = "Management Server Connection " + ID;
     RemoteUDPEndPoint = managementServerEndPoint;
     OnPingReceived();
 }
 public MenuEngineImpl(AssaultWing game, int updateOrder)
     : base(game, updateOrder)
 {
     Controls = new MenuControls();
     MenuContent = new MenuContent();
     ProgressBar = new ProgressBar(this)
     {
         HorizontalAlignment = HorizontalAlignment.Center,
         VerticalAlignment = VerticalAlignment.Bottom,
         CustomAlignment = () => new Vector2(0, -2),
     };
 }
 public UserControlledLogic(AssaultWing game)
     : base(game)
 {
     StartupScreen = new StartupScreen(Game, -1);
     MenuEngine = new MenuEngineImpl(Game, 10);
     IntroEngine = new IntroEngine(Game, 11);
     PlayerChat = new PlayerChat(Game, 12);
     OverlayDialog = new OverlayDialog(Game, 20);
     Game.Components.Add(StartupScreen);
     Game.Components.Add(MenuEngine);
     Game.Components.Add(IntroEngine);
     Game.Components.Add(PlayerChat);
     Game.Components.Add(OverlayDialog);
     CreateCustomControls(Game);
     Game.MessageHandlers.GameServerConnectionClosing += Handle_GameServerConnectionClosing;
 }
 public ConnectAsyncState(AssaultWing game, Socket[] sockets, AWEndPoint[] remoteEndPoints)
 {
     Game = game;
     Sockets = sockets;
     RemoteEndPoints = remoteEndPoints;
 }
Exemple #6
0
 public ProgramLogic(AssaultWing game)
 {
     Game = game;
 }
Exemple #7
0
 private void InitializeGame(IntPtr windowHandle, CommandLineOptions commandLineOptions)
 {
     if (!commandLineOptions.DedicatedServer) _graphicsDeviceService = new GraphicsDeviceService(windowHandle);
     _game = new AssaultWing(_graphicsDeviceService, commandLineOptions);
     AssaultWingCore.Instance = _game; // HACK: support older code that uses the static instance
     _game.Window = new Window(new Window.WindowImpl
     {
         GetTitle = () => Text,
         SetTitle = text => BeginInvoke((Action)(() => Text = text)),
         GetClientBounds = () => _isFullScreen ? ClientRectangle.ToXnaRectangle() : _gameView.ClientRectangle.ToXnaRectangle(),
         GetFullScreen = () => _isFullScreen,
         SetWindowed = () => BeginInvoke((Action)SetWindowed),
         SetFullScreen = (width, height) => BeginInvoke((Action<int, int>)SetFullScreen, width, height),
         IsVerticalSynced = () => _graphicsDeviceService.IsVerticalSynced,
         EnableVerticalSync = () => BeginInvoke((Action)_graphicsDeviceService.EnableVerticalSync),
         DisableVerticalSync = () => BeginInvoke((Action)_graphicsDeviceService.DisableVerticalSync),
         EnsureCursorHidden = () => BeginInvoke((Action)EnsureCursorHidden),
         EnsureCursorShown = () => BeginInvoke((Action)EnsureCursorShown),
     });
     _gameView.Draw += _game.Draw;
     _gameView.ExternalWndProc += WndProcImpl;
     _gameView.Resize += (sender, eventArgs) => _game.DataEngine.RearrangeViewports();
 }
Exemple #8
0
 public new void Dispose()
 {
     if (_game != null)
     {
         _game.UnloadContent();
         _game.Dispose();
     }
     _game = null;
     if (_updateTimer != null) _updateTimer.Dispose();
     AW2.Helpers.Log.Written -= AddToLogView;
     base.Dispose();
 }
 private void ListenOneConnection(AssaultWing game)
 {
     if (_serverSocket == null) throw new ApplicationException("Server socket must be opened first");
     try
     {
         _listenResult = _serverSocket.BeginAccept(AcceptCallback, new ConnectAsyncState(game, new Socket[] { _serverSocket }, null));
     }
     catch (SocketException e)
     {
         Connection.HandleNewConnection(new Result<Connection>(e));
     }
 }
 /// <summary>
 /// Creates a new connection to a game client.
 /// </summary>
 /// <param name="tcpSocket">An opened TCP socket to the remote host. The
 /// created connection owns the socket and will dispose of it.</param>
 public GameClientConnection(AssaultWing game, Socket tcpSocket)
     : base(game, tcpSocket)
 {
     Name = string.Format("Game Client {0} ({1})", ID, RemoteTCPEndPoint.Address);
     ConnectionStatus = new GameClientStatus();
 }
 private void CreateCustomControls(AssaultWing game)
 {
     var escapeControl = new MultiControl
     {
         new KeyboardKey(Keys.Escape),
         new GamePadButton(0, GamePadButtonType.Start),
         new GamePadButton(0, GamePadButtonType.Back),
     };
     var screenShotControl = new KeyboardKey(Keys.PrintScreen);
     game.CustomControls.Add(Tuple.Create<Control, Action>(escapeControl, Click_EscapeControl));
     game.CustomControls.Add(Tuple.Create<Control, Action>(screenShotControl, Game.TakeScreenShot));
     game.CustomControls.Add(Tuple.Create<Control, Action>(MenuEngine.Controls.Back, Click_MenuBackControl));
 }
 public MessageHandlers(AssaultWing game)
 {
     Game = game;
 }
 public ConnectionAttemptListener(AssaultWing game)
 {
     _game = game;
 }
 /// <summary>
 /// Creates a new connection to a game server.
 /// </summary>
 /// <param name="tcpSocket">An opened TCP socket to the remote host. The
 /// created connection owns the socket and will dispose of it.</param>
 public GameServerConnection(AssaultWing game, Socket tcpSocket)
     : base(game, tcpSocket)
 {
     Name = string.Format("Game Server {0} ({1})", ID, RemoteTCPEndPoint.Address);
 }
 public QuickStartLogic(AssaultWing game, CommandLineOptions.QuickStartOptions options)
     : base(game)
 {
     _options = options;
 }
Exemple #16
0
 public NetworkEngine(AssaultWing game, int updateOrder)
     : base(game, updateOrder)
 {
     _game = game;
     GameClientConnections = new List<GameClientConnection>();
     _removedClientConnections = new List<GameClientConnection>();
     _udpMessagesToHandle = new ThreadSafeWrapper<List<Tuple<Message, IPEndPoint>>>(new List<Tuple<Message, IPEndPoint>>());
     _managementServerConnectionCheckTimer = new AWTimer(() => _game.GameTime.TotalRealTime, TimeSpan.FromSeconds(10)) { SkipPastIntervals = true };
     MessageHandlers = new List<MessageHandlerBase>();
     InitializeUDPSocket();
 }
Exemple #17
0
 /// <summary>
 /// Turns this game instance into a game client by connecting to a game server.
 /// Poll <c>Connection.ConnectionResults</c> to find out when and if
 /// the connection was successfully estblished.
 /// </summary>
 public void StartClient(AssaultWing game, AWEndPoint[] serverEndPoints, Action<Result<Connection>> connectionHandler)
 {
     Log.Write("Client starts connecting");
     _startClientConnectionHandler = connectionHandler;
     Connection.Connect(game, serverEndPoints);
 }