示例#1
0
        public GameWorldXna(PlanesGame game, GameWorld gameWorld, Rectangle gameFieldRectangle)
            : base(game)
        {
            m_lastFrame    = new RenderTarget2D(game.GraphicsDevice, game.Graphics.PreferredBackBufferWidth, game.Graphics.PreferredBackBufferHeight, false, SurfaceFormat.HdrBlendable, DepthFormat.None);
            m_currentFrame = new RenderTarget2D(game.GraphicsDevice, game.Graphics.PreferredBackBufferWidth, game.Graphics.PreferredBackBufferHeight, false, SurfaceFormat.HdrBlendable, DepthFormat.None);

            m_safeDrawableGameComponents = new ThreadSafeCollection <MyDrawableGameComponent>();

            m_safeParticlesCollection = new ThreadSafeCollection <Particle>();

            m_gameWorld = gameWorld;
            m_gameWorld.GameObjectStatusChanged += GameObjectStatusChanged;
            m_gameWorld.BonusApplied            += BonusApplied;
            m_gameWorld.Explosion += ExplosionDetected;

            //m_backgroundVisiblePartWidth = gameFieldRectangle.Width;
            m_backgroundScale = new Vector2(1.5f, 1.5f); // 50% of width and height will be behind screen bound in every frame

            m_coordinatesTransformer = new CoordinatesTransformer(m_gameWorld.Size, gameFieldRectangle, 180);
            m_coordinatesTransformer.ScaleToFit();

            m_instanceMapper = new InstanceMapper(game, m_coordinatesTransformer);

            m_gameObjectMapping = new Dictionary <GameObject, DrawableGameObject>();
            m_equipmentMapping  = new Dictionary <Equipment, DrawableEquipment>();

            m_soundManager = new SoundManager(game, () => m_coordinatesTransformer.VisibleLogicalRectangle);

            //m_lastFrameRenderTarget = new RenderTarget2D(game.Graphics.GraphicsDevice,
            //    game.Graphics.PreferredBackBufferWidth, game.Graphics.PreferredBackBufferHeight,
            //    false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PlatformContents);

            FillInstanceMapper();
        }
示例#2
0
        public void DrawOnMinimap(GameTime gameTime, SpriteBatch minimapSpriteBatch, CoordinatesTransformer coordinatesTransformer)
        {
            if (m_minimapTexture == null)
            {
                m_minimapTexture = Game.Content.Load <Texture2D>("Minimap/arrow");
            }

            var origin = new Vector2(m_minimapTexture.Width / 2.0f, m_minimapTexture.Height / 2.0f);

            minimapSpriteBatch.Draw(m_minimapTexture,
                                    coordinatesTransformer.Transform(GameObject.Position),
                                    null,
                                    Color.White,
                                    (float)Helper.ToRadians(GameObject.Rotation),
                                    origin,
                                    1.0f,
                                    SpriteEffects.None,
                                    0.0f);
        }
示例#3
0
 public InstanceMapper(PlanesGame game, CoordinatesTransformer coordinatesTransformer)
 {
     m_game = game;
     m_coordinatesTransformer = coordinatesTransformer;
     m_classMapDictionary     = new Dictionary <Type, Tuple <ConstructorInfo, object[]> >();
 }
示例#4
0
 protected DrawablePlane(PlanesGame game, Plane plane, CoordinatesTransformer coordinatesTransformer)
     : base(game, plane, coordinatesTransformer)
 {
 }
 protected DrawableStaticObject(PlanesGame game, StaticObject staticObject, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     StaticObject = staticObject;
 }
 protected DrawableGameObject(PlanesGame game, GameObject gameObject, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     GameObject = gameObject;
 }
 protected MyDrawableGameComponent(PlanesGame game, CoordinatesTransformer coordinatesTransformer)
     : base(game)
 {
     CoordinatesTransformer = coordinatesTransformer;
 }
示例#8
0
 protected DrawableEquipment(PlanesGame game, Equipment equipment, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     Equipment = equipment;
 }