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 PickUp(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable = null) { if (gameAction is PickUp || gameAction is LayDown) { gameAction.Resolve(new GameActorPosition(this, position, LayerType.Object), atlas, tilesetTable); } }
private bool PerformPickup(IAtlas atlas, ITilesetTable tilesetTable) { // check tile in front of List <GameActorPosition> targets = GetInteractableTilesInFrontOf(atlas); // if no tile, check objects if (targets.Count == 0) { targets = GetInteractableObjectsInFrontOf(atlas); } if (targets.Count == 0) { return(false); } foreach (GameActorPosition target in targets) { IPickableGameActor interactableTarget = target.Actor as IPickableGameActor; if (interactableTarget == null) { continue; } GameAction pickUpAction = new PickUp(this); interactableTarget.PickUp(atlas, pickUpAction, target.Position, tilesetTable); RemoveSpeed(target); return(true); } return(false); }
private void Ignite(IAtlas atlas, ITilesetTable tilesetTable) { var fireplaceBurning = new FireplaceBurning(tilesetTable, Position); atlas.ReplaceWith(ThisGameActorPosition(LayerType.OnGroundInteractable), fireplaceBurning); atlas.RegisterToAutoupdate(fireplaceBurning); }
public void Update(IAtlas atlas, ITilesetTable table) { List <Vector2I> free = atlas.FreePositionsAround(Position, LayerType.Obstacle | LayerType.Object).ToList(); if (free.Count == 0) { return; } // filter out position with PathTiles free = free.Where(x => atlas.ActorsAt((Vector2)x, LayerType.Background).First().Actor.GetType() != typeof(PathTile)).ToList(); if (free.Count == 0) { return; } Vector2I targetPosition = free[m_rng.Next(free.Count)]; object[] args = { table, targetPosition }; Fruit fruit = (Fruit)Activator.CreateInstance(typeof(T), args); GameActorPosition fruitPosition = new GameActorPosition(fruit, new Vector2(targetPosition), LayerType.ObstacleInteractable); atlas.Add(fruitPosition); NextUpdateAfter = m_updatePeriod; }
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 ISwitchableGameActor Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table) { RcDoorClosed closedDoor = new RcDoorClosed(table, Position); bool added = atlas.Add(new GameActorPosition(closedDoor, (Vector2)Position, LayerType.ObstacleInteractable), true); if (!added) return this; atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.OnGroundInteractable)); return closedDoor; }
private bool PerformLayDown(IAtlas atlas, ITilesetTable tilesetTable) { Vector2 positionInFrontOf = atlas.PositionInFrontOf(this, 1); GameAction layDownAction = new LayDown(this); Tool.PickUp(atlas, layDownAction, positionInFrontOf, tilesetTable); return(true); }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable) { var interact = gameAction as Interact; if (interact != null) { Ignite(atlas, tilesetTable); } }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable) { var doorOpened = new SimpleDoorOpened(tilesetTable); bool added = atlas.Add(new GameActorPosition(doorOpened, position, LayerType.OnGroundInteractable)); if (added) { atlas.Remove(new GameActorPosition(this, position, LayerType.ObstacleInteractable)); } }
protected Tile(ITilesetTable tilesetTable) { if (tilesetTable == null) throw new ArgumentNullException("tilesetTable"); Contract.EndContractBlock(); string typeName = GetType().Name; TilesetId = tilesetTable.TileNumber(typeName); }
public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable) { if (SomeoneOnTile) { return; } NextUpdateAfter = 60; atlas.RegisterToAutoupdate(this); }
public void Use(GameActorPosition senderPosition, IAtlas atlas, ITilesetTable tilesetTable) { IEnumerable<GameActorPosition> actorsInFrontOf = atlas.ActorsInFrontOf(senderPosition.Actor as ICharacter).ToList(); if (actorsInFrontOf.Select(x => x.Actor).Contains(Switchable as GameActor)) { GameActorPosition switchable = actorsInFrontOf.First(x => x.Actor == Switchable); Switch(switchable, atlas, tilesetTable); } }
public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table) { ICanPickGameObject picker = Sender as ICanPickGameObject; IPickableGameActor pickItem = target.Actor as IPickableGameActor; if (picker == null || pickItem == null) return; if (picker.AddToInventory(pickItem)) atlas.Remove(target); }
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 Use(GameActorPosition senderPosition, IAtlas atlas, ITilesetTable tilesetTable) { IEnumerable <GameActorPosition> actorsInFrontOf = atlas.ActorsInFrontOf(senderPosition.Actor as ICharacter).ToList(); if (actorsInFrontOf.Select(x => x.Actor).Contains(Switchable as GameActor)) { GameActorPosition switchable = actorsInFrontOf.First(x => x.Actor == Switchable); Switch(switchable, atlas, 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 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; }
protected Tile(ITilesetTable tilesetTable) { if (tilesetTable == null) { throw new ArgumentNullException("tilesetTable"); } Contract.EndContractBlock(); string typeName = GetType().Name; TilesetId = tilesetTable.TileNumber(typeName); }
public void Update(IAtlas atlas, ITilesetTable table) { List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { IAvatar avatar = gameActor as IAvatar; if (avatar != null) avatar.Rested += TWConfig.Instance.BedRechargeRate; } }
public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table) { if (target.Actor is Apple || target.Actor is Pear) { atlas.Remove(target); } var switcher = target.Actor as ISwitcherGameActor; if (switcher != null) { switcher.Switch(target, atlas, table); } }
public void Update(IAtlas atlas, ITilesetTable table) { List <IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { var avatar = gameActor as IAvatar; if (avatar != null) { avatar.Energy += ENERGY_RECHARGED; } } }
public void Update(IAtlas atlas, ITilesetTable table) { List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { var avatar = gameActor as IAvatar; if (avatar != null) { avatar.Energy -= ENERGY_FOR_STEP_OR_WAIT_A_SECOND_ON_POISON; } } }
public void Update(IAtlas atlas, ITilesetTable table) { List <IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { IAvatar avatar = gameActor as IAvatar; if (avatar != null) { avatar.Rested += TWConfig.Instance.BedRechargeRate; } } }
public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table) { ICanPickGameObject picker = Sender as ICanPickGameObject; IPickableGameActor pickItem = target.Actor as IPickableGameActor; if (picker == null || pickItem == null) { return; } if (picker.AddToInventory(pickItem)) { atlas.Remove(target); } }
public void Update(IAtlas atlas, ITilesetTable table) { List <IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { var avatar = gameActor as IAvatar; if (avatar != null) { avatar.Energy -= ENERGY_FOR_STEP_OR_WAIT_A_SECOND_ON_POISON; } } }
public void Update(IAtlas atlas, ITilesetTable table) { List<IGameObject> gameActorPositions = atlas.StayingOnTile(Position); SomeoneOnTile = gameActorPositions.Any(); foreach (IGameObject gameActor in gameActorPositions) { var avatar = gameActor as IAvatar; if (avatar != null) { avatar.Energy += ENERGY_RECHARGED; } } }
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) { var temperatureAround = atlas.Temperature(Position); //LogAvatarStatus(atlas, temperatureAround); float oldEnergy = Energy; LoseEnergy(); BalanceTemperature(temperatureAround, oldEnergy - Energy); LoseRest(); if (Interact) { InteractWithAllInteractablesInFrontOf(atlas, table); Interact = false; return; } if (PickUp) { if (Tool == null) { PerformPickup(atlas, table); } else { PerformLayDown(atlas, table); } PickUp = false; return; } if (UseTool) { var usable = Tool as IUsableGameActor; if (usable != null) { usable.Use(new GameActorPosition(this, Position, LayerType.Object), atlas, table); } } }
public override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table) { ICanPickGameObject picker = Sender as ICanPickGameObject; ICharacter character = Sender as ICharacter; if (picker == null || character == null) { return; } Vector2 positionInFrontOf = target.Position; // solving case when positions where character should place tile collides with character's position if (target.Actor is Tile) { Tile tile = (target.Actor as Tile); IPhysicalEntity physicalEntity = tile.GetPhysicalEntity(new Vector2I(positionInFrontOf)); bool collidesWithSource = physicalEntity.CollidesWith(character.PhysicalEntity); if (collidesWithSource) { /* <- change to //* to switch * // to the center of current tile * character.Position = Vector2.Floor(character.Position) + Vector2.One/2; * * /*/ // back WRT his direction do { character.Position = Physics.Utils.Move(character.Position, character.Direction, -0.01f); } while (physicalEntity.CollidesWith(character.PhysicalEntity)); // */ } } GameActorPosition toLayDown = new GameActorPosition(target.Actor, positionInFrontOf, target.Layer); bool added = atlas.Add(toLayDown, true); if (added) { picker.RemoveFromInventory(); } }
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); }
private void InteractWithAllInteractablesInFrontOf(IAtlas atlas, ITilesetTable table) { List <GameActorPosition> tilesInFrontOf = GetInteractableTilesInFrontOf(atlas); foreach (GameActorPosition tileInFrontOf in tilesInFrontOf) { if (tileInFrontOf != null) { var interactable = tileInFrontOf.Actor as IInteractableGameActor; if (interactable != null) { interactable.ApplyGameAction(atlas, new Interact(this), tileInFrontOf.Position, table); } if (tileInFrontOf.Actor is Fruit) { EatFruit(tileInFrontOf); } } } }
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 override void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable table) { ICanPickGameObject picker = Sender as ICanPickGameObject; ICharacter character = Sender as ICharacter; if (picker == null || character == null) return; Vector2 positionInFrontOf = target.Position; // solving case when positions where character should place tile collides with character's position if (target.Actor is Tile) { Tile tile = (target.Actor as Tile); IPhysicalEntity physicalEntity = tile.GetPhysicalEntity(new Vector2I(positionInFrontOf)); bool collidesWithSource = physicalEntity.CollidesWith(character.PhysicalEntity); if (collidesWithSource) { /* <- change to //* to switch // to the center of current tile character.Position = Vector2.Floor(character.Position) + Vector2.One/2; /*/ // back WRT his direction do { character.Position = Physics.Utils.Move(character.Position, character.Direction, -0.01f); } while (physicalEntity.CollidesWith(character.PhysicalEntity)); // */ } } GameActorPosition toLayDown = new GameActorPosition(target.Actor, positionInFrontOf, target.Layer); bool added = atlas.Add(toLayDown, true); if (added) { picker.RemoveFromInventory(); } }
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 PoisonuosTile(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable, position) { Ctor(); }
public void ObjectDetected(IGameObject gameObject, IAtlas atlas, ITilesetTable tilesetTable) { if(SomeoneOnTile) return; NextUpdateAfter = 60; atlas.RegisterToAutoupdate(this); }
public Obstacle(ITilesetTable tilesetTable) : base(tilesetTable) { }
public void Update(IAtlas atlas, ITilesetTable table) { atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.ObstacleInteractable)); }
public SimpleDoorClosed(ITilesetTable tilesetTable) : base(tilesetTable) { }
public ISwitchableGameActor Switch(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table) { RcDoorClosed closedDoor = new RcDoorClosed(table, Position); bool added = atlas.Add(new GameActorPosition(closedDoor, (Vector2)Position, LayerType.ObstacleInteractable), true); if (!added) { return(this); } atlas.Remove(new GameActorPosition(this, (Vector2)Position, LayerType.OnGroundInteractable)); return(closedDoor); }
public void Burn(GameActorPosition gameActorPosition, IAtlas atlas, ITilesetTable table) { atlas.Remove(gameActorPosition); }
public TileDetectorRegister(IAtlas atlas, ITilesetTable tilesetTable) { m_atlas = atlas; m_tilesetTable = tilesetTable; }
public RcDoorOpened(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable, position) { }
protected DynamicTile(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable) { Position = position; }
public RoomTile(ITilesetTable tilesetTable) : base(tilesetTable) { }
public Pear(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable, position) { Init(); }
public void ApplyGameAction(IAtlas atlas, GameAction gameAction, Vector2 position, ITilesetTable tilesetTable) { gameAction.Resolve(new GameActorPosition(this, position, LayerType.ObstacleInteractable), atlas, tilesetTable); }
public Trap(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable, position) { }
protected StaticTile(ITilesetTable tilesetTable) : base(tilesetTable) { }
/// <summary> /// Resolve implements default action implementation (where applicable) /// </summary> /// <param name="target">Target of the action</param> /// <param name="atlas"></param> /// <param name="tilesetTable"></param> public abstract void Resolve(GameActorPosition target, IAtlas atlas, ITilesetTable tilesetTable);
public Pinecone(ITilesetTable tilesetTable, Vector2I position) : base(tilesetTable, position) { }