public AssaultWingCore(GraphicsDeviceService graphicsDeviceService, CommandLineOptions args) : base(graphicsDeviceService) { Log.Write("Assault Wing version " + MiscHelper.Version); CommandLineOptions = args; Log.Write("Loading settings from " + MiscHelper.DataDirectory); Settings = AWSettings.FromFile(this, MiscHelper.DataDirectory); NetworkMode = NetworkMode.Standalone; InitializeComponents(); _standingsTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)); }
public AWGame(GraphicsDeviceService graphicsDeviceService) { GraphicsDeviceService = graphicsDeviceService; Services = new GameServiceContainer(); if (graphicsDeviceService != null) Services.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService); Components = new AWGameComponentCollection(); GameTime = new AWGameTime(); _framerateTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true }; _frameDrawTimes = new RunningSequenceTimeSpan(TimeSpan.FromSeconds(1)); _frameDrawStopwatch = new Stopwatch(); }
public AssaultWing(GraphicsDeviceService graphicsDeviceService, CommandLineOptions args) : base(graphicsDeviceService, args) { CustomControls = new List<Tuple<Control, Action>>(); MessageHandlers = new Net.MessageHandling.MessageHandlers(this); if (CommandLineOptions.DedicatedServer) Logic = new DedicatedServerLogic(this); else if (CommandLineOptions.QuickStart != null) Logic = new QuickStartLogic(this, CommandLineOptions.QuickStart); else Logic = new UserControlledLogic(this); ArenaLoadTask = new BackgroundTask(); NetworkingErrors = new Queue<string>(); _gameSettingsSendTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(2)) { SkipPastIntervals = true }; _arenaStateSendTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(2)) { SkipPastIntervals = true }; _frameNumberSynchronizationTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true }; NetworkEngine = new NetworkEngine(this, 30); WebData = new WebData(this, 21); Components.Add(NetworkEngine); Components.Add(WebData); ChatStartControl = Settings.Controls.Chat.GetControl(); _frameStepControl = new KeyboardKey(Keys.F8); _frameRunControl = new KeyboardKey(Keys.F7); _frameStep = false; _debugPrintLagTimer = new AWTimer(() => GameTime.TotalRealTime, TimeSpan.FromSeconds(1)) { SkipPastIntervals = true }; DataEngine.SpectatorAdded += SpectatorAddedHandler; DataEngine.SpectatorRemoved += SpectatorRemovedHandler; NetworkEngine.Enabled = true; AW2.Graphics.PlayerViewport.CustomOverlayCreators.Add(viewport => new SystemStatusOverlay(viewport)); // Replace the dummy StatsBase by a proper StatsSender. Components.Remove(comp => comp is StatsBase); Stats = new StatsSender(this, 7); Components.Add(Stats); Stats.Enabled = true; }
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(); }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { FinishGame(); if (_graphicsDeviceService != null) _graphicsDeviceService.Dispose(); _graphicsDeviceService = null; base.OnClosing(e); }