Exemple #1
0
        internal IReadOnlyList<Item> FindNear(Creature creature)
        {
            var items = from item in arena.InternalItems
                        where CalculateDistance(creature, item) <= MaxDistance
                        select item;

            return items.ToList();
        }
        internal IReadOnlyList<Creature> FindNear(Creature creature)
        {
            var creatures = from c in arena.Creatures
                            where c != creature && CalculateDistance(creature, c) <= MaxDistance
                            select c;

            return creatures.ToList();
        }
Exemple #3
0
        internal override bool PickUp(Creature creature)
        {
            Arena.Log.Add(String.Format(
                "{0} picks up an armor.",
                creature.Name));

            creature.Defense = defense;
            creature.SkipTurnCount += 2;
            return true;
        }
Exemple #4
0
        internal override bool PickUp(Creature creature)
        {
            Arena.Log.Add(String.Format(
                "{0} picks up a weapon.",
                creature.Name));

            creature.Attack = attack;
            creature.SkipTurnCount = 1;
            return true;
        }
Exemple #5
0
        internal override bool PickUp(Creature creature)
        {
            if (creature.Health < 10)
            {
                Arena.Log.Add(String.Format(
                    "{0} picks up a health pack and receives {1} HP.",
                    creature.Name,
                    healthPoints));

                creature.Health += healthPoints;
                creature.SkipTurnCount += 3;
                return true;
            }

            return false;
        }
 internal MoveCommand(Creature creature, Direction direction)
     : base(creature)
 {
     this.direction = direction;
 }
 internal AttackCommand(Creature creature, Creature enemy)
     : base(creature)
 {
     this.enemy = enemy;
 }
 internal IdleCommand(Creature creature)
     : base(creature)
 {
 }
 private int CalculateDistance(Creature creature, Creature candidate)
 {
     int xDistance = Math.Abs(creature.X - candidate.X);
     int yDistance = Math.Abs(creature.Y - candidate.Y);
     return xDistance + yDistance;
 }
Exemple #10
0
 internal Command(Creature creature)
 {
     Creature = creature;
 }
Exemple #11
0
        private bool IsCloseTo(Creature creature, int x, int y)
        {
            int xDistance = Math.Abs(creature.X - x);
            int yDistance = Math.Abs(creature.Y - y);

            return xDistance + yDistance < 10;
        }
Exemple #12
0
 private int CalculateDistance(Creature creature, Item item)
 {
     int xDistance = Math.Abs(creature.X - item.X);
     int yDistance = Math.Abs(creature.Y - item.Y);
     return xDistance + yDistance;
 }
Exemple #13
0
 protected void Hit(Creature enemy)
 {
     var command = new AttackCommand(this, enemy);
     commands.Add(command);
 }