Ejemplo n.º 1
0
        public void Run()
        {
            _keyPressed = new ScummInputState();

            ushort result = 0;
            // TODO: configuration
            //if (ConfMan.hasKey("save_slot"))
            //{
            //    var saveSlot = (int)ConfigurationManager["save_slot"];
            //    if (saveSlot >= 0 && saveSlot <= 999)
            //        result = _skyControl.QuickXRestore((int)ConfigurationManager["save_slot"]);
            //}

            if (result != Control.GameRestored)
            {
                bool introSkipped = false;
                if (SystemVars.Instance.GameVersion.Version.Minor > 272)
                {
                    // don't do intro for floppydemos
                    using (var skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system))
                    {
                        // TODO: configuration
                        //var floppyIntro = (bool)ConfigurationManager["alt_intro"];
                        var floppyIntro = false;
                        introSkipped = !skyIntro.DoIntro(floppyIntro);
                    }
                }

                if (!HasToQuit)
                {
                    // restartGame() takes us to the first scene, without showing the
                    // initial animation where Foster is being chased. initScreen0()
                    // shows the first scene together with that animation. We can't
                    // call both, as they both load the same scene.
                    if (introSkipped)
                        _skyControl.RestartGame();
                    else
                        _skyLogic.InitScreen0();
                }
            }

            _lastSaveTime = Environment.TickCount;

            var delayCount = Environment.TickCount;
            while (!HasToQuit)
            {
                // TODO: _debugger.onFrame();

                if (ShouldPerformAutoSave(_lastSaveTime))
                {
                    if (_skyControl.LoadSaveAllowed())
                    {
                        _lastSaveTime = Environment.TickCount;
                        _skyControl.DoAutoSave();
                    }
                    else
                        _lastSaveTime += 30 * 1000; // try again in 30 secs
                }
                _skySound.CheckFxQueue();
                _skyMouse.MouseEngine();
                HandleKey();
                if (SystemVars.Instance.Paused)
                {
                    do
                    {
                        _system.GraphicsManager.UpdateScreen();
                        Delay(50);
                        HandleKey();
                    } while (SystemVars.Instance.Paused);
                    delayCount = Environment.TickCount;
                }

                _skyLogic.Engine();
                _skyScreen.ProcessSequence();
                _skyScreen.Recreate();
                _skyScreen.SpriteEngine();

                // TODO: debugger
                //if (_debugger.showGrid())
                //{
                //    var grid = _skyLogic.Grid.GiveGrid(_skyLogic.ScriptVariables[Logic.SCREEN]);
                //    if (grid != null)
                //    {
                //        _skyScreen.ShowGrid(grid);
                //        _skyScreen.ForceRefresh();
                //    }
                //}
                _skyScreen.Flip();

                if ((_fastMode & 2) != 0)
                    Delay(0);
                else if ((_fastMode & 1) != 0)
                    Delay(10);
                else
                {
                    delayCount += SystemVars.Instance.GameSpeed;
                    int needDelay = delayCount - Environment.TickCount;
                    if ((needDelay < 0) || (needDelay > SystemVars.Instance.GameSpeed))
                    {
                        needDelay = 0;
                        delayCount = Environment.TickCount;
                    }
                    Delay(needDelay);
                }
            }

            _skyControl.ShowGameQuitMsg();
            _skyMusic.StopMusic();
            // TODO: configuration
            //ConfMan.flushToDisk();
            Delay(1500);
        }
Ejemplo n.º 2
0
        public void Run()
        {
            _keyPressed = new ScummInputState();

            ushort result = 0;

            // TODO: configuration
            //if (ConfMan.hasKey("save_slot"))
            //{
            //    var saveSlot = (int)ConfigurationManager["save_slot"];
            //    if (saveSlot >= 0 && saveSlot <= 999)
            //        result = _skyControl.QuickXRestore((int)ConfigurationManager["save_slot"]);
            //}

            if (result != Control.GameRestored)
            {
                bool introSkipped = false;
                if (SystemVars.Instance.GameVersion.Version.Minor > 272)
                {
                    // don't do intro for floppydemos
                    using (var skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system))
                    {
                        // TODO: configuration
                        //var floppyIntro = (bool)ConfigurationManager["alt_intro"];
                        var floppyIntro = false;
                        introSkipped = !skyIntro.DoIntro(floppyIntro);
                    }
                }

                if (!HasToQuit)
                {
                    // restartGame() takes us to the first scene, without showing the
                    // initial animation where Foster is being chased. initScreen0()
                    // shows the first scene together with that animation. We can't
                    // call both, as they both load the same scene.
                    if (introSkipped)
                    {
                        _skyControl.RestartGame();
                    }
                    else
                    {
                        _skyLogic.InitScreen0();
                    }
                }
            }

            _lastSaveTime = Environment.TickCount;

            var delayCount = Environment.TickCount;

            while (!HasToQuit)
            {
                // TODO: _debugger.onFrame();

                if (ShouldPerformAutoSave(_lastSaveTime))
                {
                    if (_skyControl.LoadSaveAllowed())
                    {
                        _lastSaveTime = Environment.TickCount;
                        _skyControl.DoAutoSave();
                    }
                    else
                    {
                        _lastSaveTime += 30 * 1000; // try again in 30 secs
                    }
                }
                _skySound.CheckFxQueue();
                _skyMouse.MouseEngine();
                HandleKey();
                if (SystemVars.Instance.Paused)
                {
                    do
                    {
                        _system.GraphicsManager.UpdateScreen();
                        Delay(50);
                        HandleKey();
                    } while (SystemVars.Instance.Paused);
                    delayCount = Environment.TickCount;
                }

                _skyLogic.Engine();
                _skyScreen.ProcessSequence();
                _skyScreen.Recreate();
                _skyScreen.SpriteEngine();

                // TODO: debugger
                //if (_debugger.showGrid())
                //{
                //    var grid = _skyLogic.Grid.GiveGrid(_skyLogic.ScriptVariables[Logic.SCREEN]);
                //    if (grid != null)
                //    {
                //        _skyScreen.ShowGrid(grid);
                //        _skyScreen.ForceRefresh();
                //    }
                //}
                _skyScreen.Flip();

                if ((_fastMode & 2) != 0)
                {
                    Delay(0);
                }
                else if ((_fastMode & 1) != 0)
                {
                    Delay(10);
                }
                else
                {
                    delayCount += SystemVars.Instance.GameSpeed;
                    int needDelay = delayCount - Environment.TickCount;
                    if ((needDelay < 0) || (needDelay > SystemVars.Instance.GameSpeed))
                    {
                        needDelay  = 0;
                        delayCount = Environment.TickCount;
                    }
                    Delay(needDelay);
                }
            }

            _skyControl.ShowGameQuitMsg();
            _skyMusic.StopMusic();
            // TODO: configuration
            //ConfMan.flushToDisk();
            Delay(1500);
        }