Пример #1
0
        public Minimap(PlanesGame game, Rectangle positionRecangle, GameWorldXna gameWorldXna)
            : base(game, positionRecangle)
        {
            m_gameWorldXna = gameWorldXna;

            m_coordinatesTransformer = new CoordinatesTransformer(gameWorldXna.GameWorld.Size, positionRecangle);
        }
Пример #2
0
        public GameManager(PlanesGame game)
        {
            m_game = game;

            m_client = new GameServiceClient();
            m_client.Open();
        }
Пример #3
0
        static void Main()
        {
            try
            {
                using (PlanesGame game = new PlanesGame())
                {
                    game.Run();
                }
            }
            catch (Exception exc)
            {
                var fileStream = new FileStream("errors.txt", FileMode.Append);

                var streamWriter = new StreamWriter(fileStream);

                using (streamWriter)
                {
                    streamWriter.WriteLine(DateTime.Now);
                    streamWriter.WriteLine(exc.GetType().ToString());
                    streamWriter.WriteLine(exc.Message);
                    streamWriter.WriteLine(exc.StackTrace);
                    streamWriter.WriteLine(Environment.NewLine);
                }
            }
        }
Пример #4
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();
        }
Пример #5
0
 public LaserGunXna(PlanesGame game, LaserGun weapon, CoordinatesTransformer coordinatesTransformer)
     : base(game, weapon, coordinatesTransformer)
 {
     m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
     {
         PositionDeviationRadius      = 0.4,
         VelocityDeviationRadius      = 3,
         AlphaVelocityDeviationFactor = 0.3
     };
 }
Пример #6
0
 public HealthRecoveryPlanetXna(PlanesGame game, HealthRecoveryPlanet healthRecoveryPlanet, CoordinatesTransformer coordinatesTransformer)
     : base(game, healthRecoveryPlanet, coordinatesTransformer)
 {
     m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
     {
         PositionDeviationRadius      = 6,
         VelocityDeviationRadius      = 4,
         AlphaVelocityDeviationFactor = 0.5
     };
 }
Пример #7
0
        public HomingRocketXna(PlanesGame game, HomingRocket bullet, CoordinatesTransformer coordinatesTransformer)
            : base(game, bullet, coordinatesTransformer)
        {
            var sound = game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("bullet_sound");

            sound.Position = bullet.Position;
            sound.Play();

            m_trailDrawer = new TrailDrawer(game.Content.Load <Texture2D>("Other/line_3px"), coordinatesTransformer, Color.White, 0.3, 0.2f, 0.05f, 15, 3);
        }
Пример #8
0
        public BonusXna(PlanesGame game, Bonus bonus, CoordinatesTransformer coordinatesTransformer, Color color, Texture2D texture)
            : base(game, bonus, coordinatesTransformer)
        {
            Bonus = bonus;
            Color = color;

            m_texture = texture;

            m_emitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
            {
                PositionDeviationRadius      = Bonus.RelativeGeometry.BoundingRectangle.LongSide * 2.0 / 3.0,
                VelocityDeviationRadius      = 10,
                AlphaVelocityDeviationFactor = 0.3
            };
        }
Пример #9
0
        public RocketEngineXna(PlanesGame game, RocketEngine rocketEngine, CoordinatesTransformer coordinatesTransformer)
            : base(game, rocketEngine, coordinatesTransformer)
        {
            m_workSoundEffect = game.GameManager.GameWorldXna.SoundManager.CreateFadeInOutSoundEffect("engine_work",
                                                                                                      TimeSpan.FromSeconds(0.4), TimeSpan.FromSeconds(0.1));

            m_particlesEmitter = new AsymmetricParticlesEmitter(game.GameManager.GameWorldXna)
            {
                LongitualPositionDeviationRadius  = 2,
                TransversePositionDeviationRadius = 0.4,
                LongitualVelocityDeviationRadius  = 0.1,
                TransverseVelocityDeviationRadius = 0.02,
                AlphaVelocityDeviationFactor      = 0.3
            };
        }
Пример #10
0
        public ExplosionXna(PlanesGame game, GameObject exploded, CoordinatesTransformer coordinatesTransformer)
            : base(game, coordinatesTransformer)
        {
            m_exploded          = exploded;
            m_explosionPosition = new Rect(exploded.Position, exploded.RelativeGeometry.BoundingRectangle.Size);

            if (exploded is NRPlanes.Core.Common.Plane || exploded is Bullet)
            {
                m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
                {
                    PositionDeviationRadius = m_explosionPosition.Width / 2,
                    VelocityDeviationRadius = 5
                };
            }
            else if (exploded is Bonus)
            {
                m_particlesEmitter = new SymmetricParticlesEmitter(game.GameManager.GameWorldXna)
                {
                    PositionDeviationRadius   = m_explosionPosition.Width / 3,
                    VelocityDeviationRadius   = 20,
                    RotationDeviation         = 180,
                    RotationVelocityDeviation = 60
                };
            }

            BasicSoundEffect sound = null;

            if (exploded is NRPlanes.Core.Common.Plane)
            {
                sound = game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("plane_explosion");
            }
            else if (exploded is Bullet)
            {
                sound = game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("bullet_explosion");
            }
            else if (exploded is Bonus)
            {
                sound = game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("debris_explosion");
            }

            if (sound != null)
            {
                sound.Position = m_explosionPosition.Center;
                sound.Play();
            }

            //m_angle = (float) (2 * Math.PI * m_random.NextDouble());
        }
Пример #11
0
        public SoundManager(PlanesGame game, Func <Rect> getVisibleRectangleDelegate)
        {
            m_game = game;
            m_getVisibleRectangleDelegate = getVisibleRectangleDelegate;

            m_volumeEsimationFunction = (Rect visible, Vector position) =>
            {
                double distanceToCenterOfVisibleRect = (visible.Center - position).Length;
                double halfDiagonalLen = new Vector(visible.Width, visible.Height).Length / 2;

                // in circle with radius halfDiagonalLen mult = 1
                // when on every halfDiagonalLen alienation mult decreases in E times

                return((float)Math.Exp(-Math.Max(0, distanceToCenterOfVisibleRect - halfDiagonalLen) / halfDiagonalLen));
            };
        }
Пример #12
0
        //note: info panel position rectangle needed??
        public InfoPanel(PlanesGame game, GameWorldXna gameWorldXna)
            : base(game)
        {
            m_gameWorldXna = gameWorldXna;

            m_infoPanelItems = new List <InfoPanelItem>();

            const int panelsWidth = 200;
            const int indent      = 10;

            var minimapPosition = new Rectangle(game.Graphics.PreferredBackBufferWidth - panelsWidth - indent, indent, panelsWidth,
                                                (int)(panelsWidth / gameWorldXna.GameWorld.Size.Aspect));

            var planeInfoPosition = new Rectangle(game.Graphics.PreferredBackBufferWidth - panelsWidth - indent,
                                                  minimapPosition.Y + minimapPosition.Height + indent, panelsWidth,
                                                  game.Graphics.PreferredBackBufferHeight - 2 * indent -
                                                  minimapPosition.Y - minimapPosition.Height);

            MinimapPanel   = new Minimap(game, minimapPosition, m_gameWorldXna);
            PlaneInfoPanel = new PlaneInfoPanelItem(game, planeInfoPosition);

            m_infoPanelItems.Add(MinimapPanel);
            m_infoPanelItems.Add(PlaneInfoPanel);
        }
Пример #13
0
 protected DrawableStaticObject(PlanesGame game, StaticObject staticObject, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     StaticObject = staticObject;
 }
Пример #14
0
 public ShieldXna(PlanesGame game, Shield shield, CoordinatesTransformer coordinatesTransformer)
     : base(game, shield, coordinatesTransformer)
 {
 }
Пример #15
0
 protected DrawableGameObject(PlanesGame game, GameObject gameObject, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     GameObject = gameObject;
 }
Пример #16
0
 public PlaneInfoPanelItem(PlanesGame game, Rectangle positionRectangle)
     : base(game, positionRectangle)
 {
 }
Пример #17
0
 protected DrawableEquipment(PlanesGame game, Equipment equipment, CoordinatesTransformer coordinatesTransformer)
     : base(game, coordinatesTransformer)
 {
     Equipment = equipment;
 }
Пример #18
0
 public RectangleGravityFieldXna(PlanesGame game, RectangleGravityField gravityField, CoordinatesTransformer coordinatesTransformer)
     : base(game, gravityField, coordinatesTransformer)
 {
 }
 protected MyDrawableGameComponent(PlanesGame game, CoordinatesTransformer coordinatesTransformer)
     : base(game)
 {
     CoordinatesTransformer = coordinatesTransformer;
 }
Пример #20
0
 public Particle(PlanesGame game, CoordinatesTransformer transformer, ParticleType type = ParticleType.BluredCircle)
     : base(game, transformer)
 {
     Type = type;
 }
Пример #21
0
 protected DrawablePlane(PlanesGame game, Plane plane, CoordinatesTransformer coordinatesTransformer)
     : base(game, plane, coordinatesTransformer)
 {
 }
Пример #22
0
 public XWingPlaneXna(PlanesGame game, XWingPlane xWingPlane, CoordinatesTransformer coordinatesTransformer)
     : base(game, xWingPlane, coordinatesTransformer)
 {
 }
Пример #23
0
 public InstanceMapper(PlanesGame game, CoordinatesTransformer coordinatesTransformer)
 {
     m_game = game;
     m_coordinatesTransformer = coordinatesTransformer;
     m_classMapDictionary     = new Dictionary <Type, Tuple <ConstructorInfo, object[]> >();
 }
Пример #24
0
 protected InfoPanelItem(PlanesGame game, Rectangle positionRectangle)
     : base(game)
 {
     PositionRectangle = positionRectangle;
 }