/// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _SpriteBatch.Begin();
            if (GlobalVariables._InGame)
            {
                _Controller.Draw(_SpriteBatch);
            }

            _InterfaceController.Draw(_SpriteBatch);
            _SpriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        internal void Draw()
        {
            if (_CurrentGameMode == GameMode.InGame || _CurrentGameMode == GameMode.Paused)
            {
                List <MapObject> touchedObject = new List <MapObject>();
                foreach (var mapObject in _GameWorld)
                {
                    if (mapObject._Type == TextureType.NotDrawn)
                    {
                        continue;                                          //For character and Caveman, as these have their own draw handlers.
                    }
                    if (!mapObject._ObjectTouched && mapObject._Type != TextureType.Projectile)
                    {
                        mapObject.DrawMapObject();
                    }
                    else
                    {
                        if (mapObject._Type != TextureType.Projectile)
                        {
                            touchedObject.Add(mapObject);
                        }
                        else
                        {
                            if (mapObject._BoundingBox._Shape.GetPos().Y > 800) //Projectile Cleanup.
                            {
                                touchedObject.Add(mapObject);
                            }
                            else
                            {
                                mapObject.DrawMapObject();
                            }
                        }
                    }
                }

                //This handles map collisions, such as gems, doors, levers, etc.
                foreach (MapObject obj in touchedObject)
                {
                    switch (obj._Type)
                    {
                    case TextureType.BlueGem:
                        _GameWorld.Remove(obj);
                        _Player._Score += 100;
                        break;

                    case TextureType.RedGem:
                        _GameWorld.Remove(obj);
                        _Player._Score += 50;
                        break;

                    case TextureType.Lever:
                        obj.DrawMapObject();
                        _Textures.UnpauseAnimation(TextureType.Lever);
                        _Textures.UnpauseAnimation(TextureType.CastleDoor);
                        break;

                    case TextureType.CastleDoor:
                        obj.DrawMapObject();
                        if (!_Textures.IsPaused(TextureType.CastleDoor))     //if lever has been touched.
                        {
                            //TODO: Next level progression.
                        }
                        break;

                    case TextureType.Projectile:
                        _GameWorld.Remove(obj);
                        break;

                    case TextureType.MovingSaw:
                        obj.DrawMapObject();
                        _Player._Health   -= 1;
                        obj._ObjectTouched = false;
                        break;
                    }
                }

                _Player.Draw();
                _NpcCaveman.Draw();
                if (_ShowPathfinderPaths)
                {
                    DrawAStarPathAndNodes();
                }
            }
            _UserInterface.Draw();
        }