Esempio n. 1
0
        public override void Move(MovableComponent movable, int direction)
        {
            var position = movable.IntPosition;

            while (MovableComponent.CanMove(position + Constants.Directions[direction]))
            {
                position += Constants.Directions[direction];
            }

            movable.Move(position);
        }
Esempio n. 2
0
 public override void Idle(MovableComponent movable)
 {
     foreach (var i in new int[] { 0, 2, 1, 3 })
     {
         var direction = (movable.Direction + i) % 4;
         if (movable.CanMove(direction))
         {
             movable.Move(direction);
             return;
         }
     }
 }
Esempio n. 3
0
        private void Move()
        {
            var index = this.index;

            do
            {
                var direction = sequence[index] - '0';
                if (checks[direction])
                {
                    movable.Move(direction);
                    this.index = index;
                    break;
                }
                else
                {
                    index = (index + 1) % sequence.Length;
                }
            } while (index != this.index);
        }
Esempio n. 4
0
 public virtual void Move(MovableComponent movable, int direction) =>
 movable.Move(direction);