private void SearchTick_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (!_searching)
     {
         _searching = true;
         if (!InternalPlayground.StillContainsItem())
         {
             _searchTick.Stop();
         }
         SearchItems();
         _searching = false;
     }
 }
        private void SearchItems()
        {
            _itemPositions.Clear();
            _pointsToSearch.Clear();
            _pointsToSearch.Enqueue(InternalPlayground.Pawn.Location);


            while (_pointsToSearch.Any())
            {
                Point p = _pointsToSearch.Dequeue();

                if (!InternalPlayground.IsItem(p))
                {
                    var upperNeighbour = p.UpperNeighbour();
                    var lowerNeighbour = p.LowerNeighbour();
                    var leftNeighbour  = p.LeftNeighbour();
                    var rightNeighbour = p.RightNeighbour();

                    if (InternalPlayground.FieldAccessible(upperNeighbour))
                    {
                        AddPointIfNotExistent(upperNeighbour, p);
                    }

                    if (InternalPlayground.FieldAccessible(lowerNeighbour))
                    {
                        AddPointIfNotExistent(lowerNeighbour, p);
                    }

                    if (InternalPlayground.FieldAccessible(leftNeighbour))
                    {
                        AddPointIfNotExistent(leftNeighbour, p);
                    }

                    if (InternalPlayground.FieldAccessible(rightNeighbour))
                    {
                        AddPointIfNotExistent(rightNeighbour, p);
                    }
                }
                else
                {
                    CreatePath(p);
                    break;
                }
            }
        }
        private void CreatePath(Point itemPosition)
        {
            Stack <Point> wayFromOrigin = new Stack <Point>();

            wayFromOrigin.Push(itemPosition);
            Point fromPoint = itemPosition;

            while (fromPoint != InternalPlayground.Pawn.Location)
            {
                fromPoint = (Point)_itemPositions[fromPoint];
                if (fromPoint != InternalPlayground.Pawn.Location)
                {
                    wayFromOrigin.Push(fromPoint);
                }
            }

            while (wayFromOrigin.Any())
            {
                Point moveToPoint = wayFromOrigin.Pop();
                InternalPlayground.MovePawn(moveToPoint);
                Thread.Sleep(1000);
            }
        }
 public void MoveRight()
 {
     InternalPlayground.MovePawnRight();
 }
 public void MoveLeft()
 {
     InternalPlayground.MovePawnLeft();
 }
 public void MoveDown()
 {
     InternalPlayground.MovePawnDown();
 }
 public void MoveUp()
 {
     InternalPlayground.MovePawnUp();
 }