Beispiel #1
0
 public void Update(GameTime time, HeatMap heatMap, GamePartSystem partSystem, LevelScreen levelScreen)
 {
     if (IsDestroyed)
     {
         return;
     }
     if (Type.Type == ObjectType.Hydrant)
     {
         return;
     }
     if (IsBurning)
     {
         Burning = Math.Min(Burning + 0.5f, Type.FireLimit);
         heatMap.RadiateHeat(Position, Burning);
         HP -= Burning / 1000f;
         if (IsDestroyed)
         {
             if (Type.Type == ObjectType.Explosive)
             {
                 heatMap.Explode(Position);
                 partSystem.Explode(Position);
                 levelScreen.ExplosionSound.Play(1f, 0f, Position.X / 512f - 1f);
                 levelScreen.ExplosionSound.Play(1f, 0f, Position.X / 512f - 1f);
                 levelScreen.ExplosionSound.Play(1f, 0f, Position.X / 512f - 1f);
             }
         }
         else
         {
             var count = (int)(Burning / 100f) + 1;
             if (FireArea is Circle c)
             {
                 for (var i = 0; i < count; ++i)
                 {
                     var d = MathHelper.ToRadians(Utils.Random.Next(360));
                     var l = Utils.Random.Next(c.Radius);
                     partSystem.AddFirePart(
                         new Vector2(
                             Position.X + c.X + (float)Math.Cos(d) * l,
                             Position.Y + c.Y - (float)Math.Sin(d) * l
                             ),
                         Type.FireType
                         );
                 }
             }
             else if (FireArea is Rect r)
             {
                 for (var i = 0; i < count; ++i)
                 {
                     partSystem.AddFirePart(
                         new Vector2(
                             Position.X + r.X - r.Width / 2 + Utils.Random.Next(r.Width),
                             Position.Y + r.Y - r.Height / 2 + Utils.Random.Next(r.Height)
                             ),
                         Type.FireType
                         );
                 }
             }
         }
     }
 }
Beispiel #2
0
 public void Initialize(IntoTheBlaze game)
 {
     this.game       = game;
     winTimer        = new StepTimer(180);
     fireSndTimer    = new StepTimer(108);
     fireExtSndTimer = new StepTimer(440);
     heatMap         = new HeatMap();
     partSystem      = new GamePartSystem();
     partSystem.Initialize(game);
     startingCost = 0;
     player       = new Player();
     player.Initialize(this, game);
     background = new RenderTarget2D(
         game.GraphicsDevice,
         1024, 640,
         false,
         game.GraphicsDevice.PresentationParameters.BackBufferFormat,
         DepthFormat.Depth24);
     floor = new byte[32, 17];
     walls = new byte[32, 17];
     backgroundGenerated = false;
     gameObjects         = new Dictionary <string, GameObject>();
     wallColliders       = new List <Rect>();
     gameObjectInstances = new List <GameObjectInstance>();
 }