예제 #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();
        }
예제 #2
0
        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();
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }
예제 #6
0
 internal MoveCommand(Creature creature, Direction direction)
     : base(creature)
 {
     this.direction = direction;
 }
예제 #7
0
 internal AttackCommand(Creature creature, Creature enemy)
     : base(creature)
 {
     this.enemy = enemy;
 }
예제 #8
0
 internal IdleCommand(Creature creature)
     : base(creature)
 {
 }
예제 #9
0
 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;
 }
예제 #10
0
 internal Command(Creature creature)
 {
     Creature = creature;
 }
예제 #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;
        }
예제 #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;
 }
예제 #13
0
 protected void Hit(Creature enemy)
 {
     var command = new AttackCommand(this, enemy);
     commands.Add(command);
 }