public void TryToMove(BioBotEntity entity, int deltaX, int deltaY) { var destinationX = entity.X + deltaX; var destinationY = entity.Y + deltaY; if (destinationX < 0 || destinationX >= this.width || destinationY < 0 || destinationY >= this.height || !this.isWalkable[destinationX, destinationY]) { return; } else if (this.Monsters.Any(m => m.X == destinationX && m.Y == destinationY)) { // NB: monsters will fight each other to get to you :/ var target = this.Monsters.Single(m => m.X == destinationX && m.Y == destinationY); target.Add(new DamageComponent(entity.Get <FightComponent>().Strength - target.Get <FightComponent>().Toughness)); } else if (this.Player.X == destinationX && this.Player.Y == destinationY) { Player.Add(new DamageComponent(entity.Get <FightComponent>().Strength - Player.Get <FightComponent>().Toughness)); } else { // Clear, so move. entity.X = destinationX; entity.Y = destinationY; } }
override public void Add(BioBotEntity e) { if (e.Get <MovementBehaviourComponent>() != null) { base.Add(e); } }