Exemplo n.º 1
0
 public void AddScene(AGT_Scene scene)
 {
     lock (this)
     {
         scene.GameFramework = this;
         _scene_queue.Add(scene);
     }
 }
Exemplo n.º 2
0
        public void GetNextScene(int index)
        {
            lock (this)
            {
                if ((_scene_queue.Count > 0) && (index < _scene_queue.Count))
                {
                    Suspend();

                    _Scene_ = _scene_queue[index];
                    if ((_Scene_ is AGT.Forms.IAGT_SplashDialog) && (_Scene_.State == SceneState.INIT))
                    {
                        if (_Scene_.ShowSplashScreen)
                        {
                            AGT.Forms.AGT_SplashDialog s1 = new AGT.Forms.AGT_SplashDialog(_VIDEO_DEVICE_,
                                                                                           (AGT.Forms.IAGT_SplashDialog)_Scene_);
                            s1.ShowDialog();
                            s1.Dispose();
                        }
                    }
                    if ((_Scene_ is AGT.Forms.IAGT_SceneLoadDialog) && (_Scene_.State == SceneState.INIT))
                    {
                        if (!_Scene_.ShowSplashScreen)
                        {
                            AGT.Forms.AGT_SceneLoadDialog s2 = new AGT.Forms.AGT_SceneLoadDialog(_VIDEO_DEVICE_,
                                                                                                 (AGT.Forms.IAGT_SceneLoadDialog)_Scene_);
                            s2.ShowDialog();
                            s2.Dispose();
                        }
                    }

                    Resume();
                }
                else
                {
                    if (OnGameOver == null)
                    {
                        MessageBox.Show("Generic placeholder.", "Game Over");
                        _Game_Over = true;
                    }
                    else
                    {
                        OnGameOver();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public AGT_GameFramework(DeviceParams parameters)
        {
            if (parameters == DeviceParams.Empty)
            {
                throw new ArgumentException("Empty Device Parameters");
            }
            if (parameters.PresentationParameters == null)
            {
                throw new ArgumentException("Missing PresentationParameters, in DeviceParams");
            }
            if (parameters.TargetControl == null)
            {
                throw new ArgumentException("Missing TargetControl, in DeviceParams");
            }

            _AppIdleHandler = new EventHandler(this.Application_Idle);

            AGT_Scene.QueryPerformanceFrequency(ref _ticks_per_second);
            _DeviceParams_ = parameters;
            BindFormEvents();

            _VIDEO_DEVICE_ = new Microsoft.DirectX.Direct3D.Device(
                Microsoft.DirectX.Direct3D.Manager.Adapters.Default.Adapter,
                Microsoft.DirectX.Direct3D.DeviceType.Hardware,
                parameters.TargetControl,
                parameters.Flags,
                parameters.PresentationParameters);

            _SystemImages = new AGT_SystemImages(_VIDEO_DEVICE_);
            Cursor        = _SystemImages.Cursor_Select;

            _device_lost   = new EventHandler(_DEVICE__DeviceLost);
            _device_reset  = new EventHandler(_DEVICE__DeviceReset);
            _device_resize = new System.ComponentModel.CancelEventHandler(_DEVICE__DeviceResizing);

            _VIDEO_DEVICE_.DeviceLost     += _device_lost;
            _VIDEO_DEVICE_.DeviceReset    += _device_reset;
            _VIDEO_DEVICE_.DeviceResizing += _device_resize;
        }
Exemplo n.º 4
0
 public void AddScene(AGT_Scene scene)
 {
     lock (this)
     {
         if (gf != null)
         {
             gf.AddScene(scene);
         }
     }
 }
Exemplo n.º 5
0
        private void RenderScene()
        {
            long current_ticks = 0;

            while (AppStillIdle && !_Game_Over)
            {
                AGT_Scene.QueryPerformanceCounter(ref _elapsed_ticks);

                _VIDEO_DEVICE_.Clear(_DeviceParams_.ClrFlags,
                                     _DeviceParams_.ClrColor,
                                     _DeviceParams_.ZDepth,
                                     _DeviceParams_.Stencil);

                switch (Scene.State)
                {
                case SceneState.INIT:
                    goto case SceneState.RENDER;

                case SceneState.REINIT:
                    goto case SceneState.RENDER;

                case SceneState.RENDER:
                    if (Scene._Projection_ != null)
                    {
                        _VIDEO_DEVICE_.Transform.Projection = Scene._Projection_;
                    }
                    if (Scene._View_ != null)
                    {
                        _VIDEO_DEVICE_.Transform.View  = Scene._View_;
                        _VIDEO_DEVICE_.Transform.World = Matrix.Translation(0, 0, 0);
                    }

                    _VIDEO_DEVICE_.BeginScene();

                    Scene.RenderScene(_VIDEO_DEVICE_, _frames_per_second);

                    if (Scene.ShowMouseCursor && MouseOver)
                    {
                        if (Cursor != AGT_SpriteId.Empty)
                        {
                            _SystemImages.DrawSingle(Cursor, Scene.CursorX, Scene.CursorY, 0);
                        }
                    }

                    _VIDEO_DEVICE_.EndScene();

                    try
                    {
                        _VIDEO_DEVICE_.Present();
                    }
                    catch (DeviceLostException)
                    {
                        RecoverLostDevice();
                    }

                    AGT_Scene.QueryPerformanceCounter(ref current_ticks);
                    _elapsed_ticks     = current_ticks - _elapsed_ticks;
                    _frames_per_second = (float)Math.Round((float)_ticks_per_second / (float)_elapsed_ticks);

                    break;

                case SceneState.END:
                    GetNextScene();
                    break;

                case SceneState.ERROR:
                    // TBD - Eric, Port over the exception handler.
                    _Game_Over = true;
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public void GetNextScene(int index)
        {
            lock (this)
            {
                if ((_scene_queue.Count > 0) && (index < _scene_queue.Count))
                {
                    Suspend();

                    _Scene_ = _scene_queue[index];
                    if ((_Scene_ is AGT.Forms.IAGT_SplashDialog) && (_Scene_.State == SceneState.INIT))
                    {
                        if (_Scene_.ShowSplashScreen)
                        {
                            AGT.Forms.AGT_SplashDialog s1 = new AGT.Forms.AGT_SplashDialog(_VIDEO_DEVICE_,
                                (AGT.Forms.IAGT_SplashDialog)_Scene_);
                            s1.ShowDialog();
                            s1.Dispose();
                        }
                    }
                    if ((_Scene_ is AGT.Forms.IAGT_SceneLoadDialog) && (_Scene_.State == SceneState.INIT))
                    {
                        if (!_Scene_.ShowSplashScreen)
                        {
                            AGT.Forms.AGT_SceneLoadDialog s2 = new AGT.Forms.AGT_SceneLoadDialog(_VIDEO_DEVICE_,
                                (AGT.Forms.IAGT_SceneLoadDialog)_Scene_);
                            s2.ShowDialog();
                            s2.Dispose();
                        }
                    }

                    Resume();
                }
                else
                {
                    if (OnGameOver == null)
                    {
                        MessageBox.Show("Generic placeholder.", "Game Over");
                        _Game_Over = true;
                    }
                    else
                    {
                        OnGameOver();
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void AddScene(AGT_Scene scene)
 {
     lock (this)
     {
         scene.GameFramework = this;
         _scene_queue.Add(scene);
     }
 }