private void Ignite(IAtlas atlas, ITilesetTable tilesetTable) { var fireplaceBurning = new FireplaceBurning(tilesetTable, Position); atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplaceBurning); atlas.RegisterToAutoupdate(fireplaceBurning); }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null) { if (!(gameAction is UsePickaxe)) return; UsePickaxe usePickaxe = (UsePickaxe)gameAction; if (Math.Abs(usePickaxe.Damage) < 0.00001f) return; if (usePickaxe.Damage >= 1.0f) { atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable)); return; } atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DamagedWall(usePickaxe.Damage, tilesetTable, Vector2I.Zero)); }
public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table) { var leverOn = new LeverSwitchOn(table, Position); atlas.ReplaceWith(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable), leverOn); if (Switchable == null) return; leverOn.Switchable = Switchable.Switch(null, atlas, table); }
public void Update(IAtlas atlas, ITilesetTable table) { List<IGameObject> stayingOnTile = atlas.StayingOnTile(Position); if (stayingOnTile.Count != 0) return; atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable), new TrapCharged(table, Position)); NextUpdateAfter = 0; }
public void Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table) { var leverOff = new LeverSwitchOff(table, Position); atlas.ReplaceWith(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable), leverOff); if (Switchable == null) { return; } leverOff.Switchable = Switchable.Switch(null, atlas, table) as ISwitchableGameActor; }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null) { if (!(gameAction is UsePickaxe)) { return; } UsePickaxe usePickaxe = (UsePickaxe)gameAction; if (Math.Abs(usePickaxe.Damage) < 0.00001f) { return; } if (usePickaxe.Damage >= 1.0f) { atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable)); return; } atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DamagedWall(usePickaxe.Damage, tilesetTable, Vector2I.Zero)); }
public void Update(IAtlas atlas, ITilesetTable table) { List <IGameObject> stayingOnTile = atlas.StayingOnTile(Position); if (stayingOnTile.Count != 0) { return; } atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable), new TrapCharged(table, Position)); NextUpdateAfter = 0; }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null) { UsePickaxe action = gameAction as UsePickaxe; if (action != null) { UsePickaxe usePickaxe = action; Health -= usePickaxe.Damage; } if (Health <= 0f) atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable)); }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null) { UsePickaxe action = gameAction as UsePickaxe; if (action != null) { UsePickaxe usePickaxe = action; Health -= usePickaxe.Damage; } if (Health <= 0f) { atlas.ReplaceWith(new GameActorPosition(this, position, LayerType.ObstacleInteractable), new DestroyedWall(tilesetTable)); } }
public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable) { var avatar = gameObject as IAvatar; if (avatar != null) { avatar.Energy -= ENERGY_FOR_STEP_ON_TRAP; } var forwardMovable = gameObject as IForwardMovable; if (forwardMovable != null) { forwardMovable.ForwardSpeed = 0; } gameObject.Position = Vector2.Floor(gameObject.Position) + Vector2.One/2; var trapDischarged = new TrapDischarged(tilesetTable, Position); atlas.RegisterToAutoupdate(trapDischarged); atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable), trapDischarged); }
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++; } }
public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable) { var avatar = gameObject as IAvatar; if (avatar != null) { avatar.Energy -= ENERGY_FOR_STEP_ON_TRAP; } var forwardMovable = gameObject as IForwardMovable; if (forwardMovable != null) { forwardMovable.ForwardSpeed = 0; } gameObject.Position = Vector2.Floor(gameObject.Position) + Vector2.One / 2; var trapDischarged = new TrapDischarged(tilesetTable, Position); atlas.RegisterToAutoupdate(trapDischarged); atlas.ReplaceWith(new GameActorPosition(this, new Vector2(Position), LayerType.OnGroundInteractable), trapDischarged); }