public void Update(IAtlas atlas, ITilesetTable table) { if (Heat < 0) { // first update - fire starts Heat = 0.2f; atlas.RegisterHeatSource(this); NextUpdateAfter = 60; } if (Heat >= MAX_HEAT && m_counter > 1000) { // fourth update - fire is extinguished. Heat = 0; NextUpdateAfter = 0; var fireplace = new Fireplace(table, Position); atlas.UnregisterHeatSource(this); atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplace); return; } if (Heat < MAX_HEAT) { // second update - fire is growing Heat += 0.4f; } if (Heat >= MAX_HEAT) { // third update - fire is stable IEnumerable <GameActorPosition> gameActorPositions = atlas.ActorsAt((Vector2)Position, LayerType.All); foreach (GameActorPosition gameActorPosition in gameActorPositions) { ICombustibleGameActor combustible = gameActorPosition.Actor as ICombustibleGameActor; if (combustible != null) { combustible.Burn(gameActorPosition, atlas, table); } } m_counter++; } }
public void Update(IAtlas atlas, ITilesetTable table) { if (Heat < 0) { // first update - fire starts Heat = 0.2f; atlas.RegisterHeatSource(this); NextUpdateAfter = 60; } if (Heat >= MAX_HEAT && m_counter > 1000) { // fourth update - fire is extinguished. Heat = 0; NextUpdateAfter = 0; var fireplace = new Fireplace(table, Position); atlas.UnregisterHeatSource(this); atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplace); return; } if (Heat < MAX_HEAT) { // second update - fire is growing Heat += 0.4f; } if(Heat >= MAX_HEAT) { // third update - fire is stable IEnumerable<GameActorPosition> gameActorPositions = atlas.ActorsAt((Vector2) Position, LayerType.All); foreach (GameActorPosition gameActorPosition in gameActorPositions) { ICombustibleGameActor combustible = gameActorPosition.Actor as ICombustibleGameActor; if (combustible != null) { combustible.Burn(gameActorPosition, atlas, table); } } m_counter++; } }