public void UpdateFromHeatmap(HeatMap heatMap) { if (Type.Type == ObjectType.Hydrant) { return; } if (!IsBurning && heatMap.GetHeat(Position) > Type.FireLimit / 10) { SetAlight(); } }
public void Draw(SpriteBatch batch, GameTime time) { // pre-render floor if (!backgroundGenerated) { game.GraphicsDevice.SetRenderTarget(background); game.GraphicsDevice.Clear(Color.Black); batch.Begin(SpriteSortMode.Deferred, BlendState.Opaque); for (var x = 0; x < 32; ++x) { for (var y = 0; y < 17; ++y) { var tx = x % 8 * 32 + floor[x, y] * 256; var ty = y % 8 * 32; batch.Draw( floorTex, new Vector2(x * 32, y * 32), new Rectangle(tx, ty, 32, 32), Color.White ); } } batch.Draw(hud, new Vector2(0, 544), Color.White); batch.End(); game.GraphicsDevice.SetRenderTarget(null); backgroundGenerated = true; } batch.Begin(); // floor batch.Draw(background, Vector2.Zero, Color.White); batch.End(); batch.Begin(SpriteSortMode.Texture); // layer 1 foreach (var inst in gameObjectInstances) { if (inst.Type.ZHeight == 1) { inst.Draw(batch, time); } } batch.End(); batch.Begin(SpriteSortMode.Texture); // layer 2 foreach (var inst in gameObjectInstances) { if (inst.Type.ZHeight == 2) { inst.Draw(batch, time); } } batch.End(); batch.Begin(); player.Draw(batch, time); batch.End(); batch.Begin(SpriteSortMode.Texture); // layer 3 foreach (var inst in gameObjectInstances) { if (inst.Type.ZHeight == 3) { inst.Draw(batch, time); } } batch.End(); // particles partSystem.Draw(batch, time); batch.Begin(); // --- HUD --- // agents DrawExtAgent(batch, player.GetAgentAmmount(0), 16); DrawExtAgent(batch, player.GetAgentAmmount(1), 34); DrawExtAgent(batch, player.GetAgentAmmount(2), 52); // health var hp = Math.Min(64, (int)(player.HP * 0.64)); if (hp > 0) { batch.Draw(hudBars, new Vector2(96, 624 - hp), new Rectangle(48, 64 - hp, 12, hp), Color.White); } // temperature var temp = heatMap.GetHeat(player.Position.ToPoint()); var h = Math.Min(50, (int)(temp / 4f)); if (h > 0) { batch.Draw(hudBars, new Vector2(115, 617 - h), new Rectangle(60, 64 - h, 4, h), Color.White); } batch.End(); batch.Begin(); // walls for (var x = 0; x < 32; ++x) { for (var y = 0; y < 17; ++y) { if (walls[x, y] == 0) { continue; } batch.Draw( wallsTex, new Vector2(x * 32, y * 32), new Rectangle((walls[x, y] & 0x0F) * 32, 0, 32, 32), Color.White ); } } if (paused) { batch.Draw(pauseScreen, Vector2.Zero, Color.White); } // cursor batch.Draw( cursor, MouseHelper.Pos, new Rectangle(0, 0, 16, 16), Color.White, ( time.TotalGameTime.Milliseconds / 1000f + (time.TotalGameTime.Seconds % 2 == 1 ? 1 : 0) ) * MathHelper.Pi, new Vector2(8), 1, SpriteEffects.None, 0); batch.End(); }