Example #1
0
 public override void OnExit(GameTime gameTime)
 {
     DevConsole.OnNewCommand -= DevConsole_OnNewCommand;
     KeyboardEventDispatcher.OnKeyPressed -= KeyboardEventDispatcher_OnKeyPressed;
     DevConsole.Deactivate();
     if (unitModel != null)
     {
         DisposeUnit();
     }
     renderer.Dispose();
     camera = null;
     sP.Unhook();
     sS.Unhook();
     sT.Unhook();
     //MouseEventDispatcher.OnMousePress -= sP.OnMousePress;
     //MouseEventDispatcher.OnMouseMotion -= sP.OnMouseMovement;
     //MouseEventDispatcher.OnMouseRelease -= sP.OnMouseRelease;
     //MouseEventDispatcher.OnMousePress -= sS.OnMousePress;
     //MouseEventDispatcher.OnMouseMotion -= sS.OnMouseMovement;
     //MouseEventDispatcher.OnMouseRelease -= sS.OnMouseRelease;
     //MouseEventDispatcher.OnMousePress -= sT.OnMousePress;
     //MouseEventDispatcher.OnMouseMotion -= sT.OnMouseMovement;
     //MouseEventDispatcher.OnMouseRelease -= sT.OnMouseRelease;
 }
Example #2
0
        public override void OnExit(GameTime gameTime)
        {
            MouseEventDispatcher.OnMousePress     -= OnMP;
            KeyboardEventDispatcher.OnKeyPressed  -= OnKP;
            KeyboardEventDispatcher.OnKeyReleased -= OnKR;
            DevConsole.OnNewCommand -= DevConsole_OnNewCommand;
            DevConsole.Deactivate();

            camera.Controller.Unhook(game.Window);
            renderer.Dispose();

            Thread.VolatileWrite(ref playing, 0);
            tEngine.Join();
            GameEngine.Dispose(state);
            state = null;

            jukeBox.Dispose();
            jukeBox = null;

            if (tPopup != null)
            {
                tPopup.Dispose();
            }
        }
Example #3
0
        private void WorkThread()
        {
            try {
                // Start With Default Values
                isLoaded       = false;
                loadException  = null;
                LoadedRenderer = null;

                // Grab The Initialization Info
                loadData = game.LobbyScreen.InitInfo;

                // Build The Local Game State
                LoadedState = new GameState();
                if (LoadFile == null)
                {
                    GameEngine.BuildLocal(LoadedState, LoadData, new DirectoryInfo(@"Packs"), game.LobbyScreen.Races);
                }
                else
                {
                    GameEngine.Load(LoadedState, new DirectoryInfo(@"Packs"), LoadFile.FullName);
                }

                // Create The Input Controllers
                for (int ti = 0; ti < LoadedState.teams.Length; ti++)
                {
                    if (string.IsNullOrWhiteSpace(LoadData.Teams[ti].InputController))
                    {
                        continue;
                    }
                    GameEngine.SetInput(LoadedState, ti, LoadedState.Scripts[LoadData.Teams[ti].InputController].CreateInstance <ACInputController>());
                }


                // Create Camera
                LoadedCamera = new Camera(G.Viewport);
                LoadedCamera.Controller.Hook(game.Window);

                // Load The Renderer
                RendererInitArgs ria = ZXParser.ParseFile(@"Content\FX\RIA.txt", typeof(RendererInitArgs)) as RendererInitArgs;
                LoadedRenderer = new RTSRenderer(game.Graphics, game.Content, ria, game.Window);
                LoadedRenderer.HookToGame(LoadedState, 0, LoadedCamera);

                // Initialize Inputs
                int teami = -1;
                foreach (var t in LoadedState.teams)
                {
                    teami++;
                    if (t == null)
                    {
                        continue;
                    }

                    // Set Camera
                    var vInput = t.Input as IVisualInputController;
                    if (vInput != null)
                    {
                        vInput.Camera = LoadedCamera;
                    }

                    // Init
                    t.Input.Init(LoadedState, t.Index, loadData.Teams[teami].InputInitArgs);

                    // Build
                    if (vInput != null)
                    {
                        vInput.Build(LoadedRenderer);
                    }
                }

                // Create Gameplay
                LoadedGPlay = new GameplayController();
                GCInitArgs gca = new GCInitArgs()
                {
                    GameTypeScript = LoadData.GTController
                };
                LoadedGPlay.Init(LoadedState, gca);
            }
            catch (Exception e) {
                if (LoadedRenderer != null)
                {
                    LoadedRenderer.Dispose();
                }
                loadException = e;
            }
            isLoaded = true;
        }