Inheritance: IDisposable
Exemple #1
0
        public override void OnEntry(GameTime gameTime)
        {
            tPopup = null;
            end    = false;
            MouseEventDispatcher.OnMousePress     += OnMP;
            KeyboardEventDispatcher.OnKeyPressed  += OnKP;
            KeyboardEventDispatcher.OnKeyReleased += OnKR;
            DevConsole.OnNewCommand += DevConsole_OnNewCommand;

            team = 0;
            type = 0;

            state             = game.LoadScreen.LoadedState;
            state.OnNewPopup += OnNewPopup;
            camera            = game.LoadScreen.LoadedCamera;
            renderer          = game.LoadScreen.LoadedRenderer;
            renderer.UseFOW   = true;
            gameInput         = (from t in state.teams
                                 where t.Input != null && t.Input.Type == RTSInputType.Player
                                 select t.Input).FirstOrDefault();
            vInput         = gameInput == null ? null : gameInput as IVisualInputController;
            playController = game.LoadScreen.LoadedGPlay;

            sfDebug = renderer.LoadFont(@"Fonts\CourierNew32");


            // Create Game Engine Thread
            playController.BeginPlaying(state);
            tEngine          = new Thread(EngineThread);
            tEngine.Priority = ThreadPriority.Highest;
            tEngine.TrySetApartmentState(ApartmentState.MTA);
            tEngine.IsBackground = true;
            playing     = 1;
            pauseEngine = false;
            pauseRender = false;
            tEngine.Start();

            // Create Background Music
            jukeBox = new Jukebox();
            jukeBox.LoadFromDirectory(new DirectoryInfo(BS_SOUND_DIR));
        }
Exemple #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();
            }
        }