Example #1
0
        public List<PointField> doUpdate(bool oneloop = false)
        {
            List<PointField> returnList = new List<PointField>();
            while (newEntries.Count > 0)
            {
                currentlyChecking = newEntries.Dequeue();

                List<Point> pointList = getConnectedItems(currentlyChecking);
                if (pointList.Count > 1)
                {
                    List<LinkedList<AStarSolver<GameField>.PathNode>> RouteList = handleListOfConnectedPoints(pointList, currentlyChecking);

                    foreach (LinkedList<AStarSolver<GameField>.PathNode> nodeList in RouteList)
                    {
                        if (nodeList.Count >= 4)
                        {
                            PointField field = findClosed(nodeList);
                            if (field != null)
                            {
                                returnList.Add(field);
                            }
                        }
                    }
                }
                this.currentField[currentlyChecking.y, currentlyChecking.x] = currentlyChecking.value;
            }
            return returnList;
        }
Example #2
0
        private List <LinkedList <AStarSolver <GameField> .PathNode> > handleListOfConnectedPoints(List <Point> pointList, GametileUpdate update)
        {
            List <LinkedList <AStarSolver <GameField> .PathNode> > returnList = new List <LinkedList <AStarSolver <GameField> .PathNode> >();
            int amount = 0;

            foreach (Point begin in pointList)
            {
                amount++;
                if (amount == pointList.Count / 2 + 1)
                {
                    return(returnList);
                }
                foreach (Point end in pointList)
                {
                    if (begin == end)
                    {
                        continue;
                    }
                    LinkedList <AStarSolver <GameField> .PathNode> list = astarSolver.Search(end, begin);
                    if (list != null)
                    {
                        returnList.Add(list);
                    }
                }
            }
            return(returnList);
        }
Example #3
0
 private List<LinkedList<AStarSolver<GameField>.PathNode>> handleListOfConnectedPoints(List<Point> pointList, GametileUpdate update)
 {
     List<LinkedList<AStarSolver<GameField>.PathNode>> returnList = new List<LinkedList<AStarSolver<GameField>.PathNode>>();
     int amount = 0;
     foreach (Point begin in pointList)
     {
         amount++;
         if (amount == pointList.Count / 2 + 1)
             return returnList;
         foreach (Point end in pointList)
         {
             if (begin == end)
                 continue;
             LinkedList<AStarSolver<GameField>.PathNode> list = astarSolver.Search(end, begin);
             if (list != null)
             {
                 returnList.Add(list);
             }
         }
     }
     return returnList;
 }
Example #4
0
        private List<Point> getConnectedItems(GametileUpdate update)
        {
            List<Point> ConnectedItems = new List<Point>();
            int x = update.x;
            int y = update.y;
            if (diagonal)
            {
                if (this[y - 1, x - 1] && currentField[y - 1, x - 1] == update.value)
                {
                    ConnectedItems.Add(new Point(x - 1, y - 1));
                }
                if (this[y - 1, x + 1] && currentField[y - 1, x + 1] == update.value)
                {
                    ConnectedItems.Add(new Point(x + 1, y - 1));
                }
                if (this[y + 1, x - 1] && currentField[y + 1, x - 1] == update.value)
                {
                    ConnectedItems.Add(new Point(x - 1, y + 1));
                }
                if (this[y + 1, x + 1] && currentField[y + 1, x + 1] == update.value)
                {
                    ConnectedItems.Add(new Point(x + 1, y + 1));
                }
            }

            if (this[y - 1, x] && currentField[y - 1, x] == update.value)
            {
                ConnectedItems.Add(new Point(x, y - 1));
            }
            if (this[y + 1, x] && currentField[y + 1, x] == update.value)
            {
                ConnectedItems.Add(new Point(x, y + 1));
            }
            if (this[y, x - 1] && currentField[y, x - 1] == update.value)
            {
                ConnectedItems.Add(new Point(x - 1, y));
            }
            if (this[y, x + 1] && currentField[y, x + 1] == update.value)
            {
                ConnectedItems.Add(new Point(x + 1, y));
            }

            return ConnectedItems;
        }