예제 #1
0
파일: GameField.cs 프로젝트: BjkGkh/Boon
        public List<PointField> doUpdate()
        {
            var returnList = new List<PointField>();
            while (_newEntries.Count > 0)
            {
                currentlyChecking = _newEntries.Dequeue();

                List<Point> pointList = getConnectedItems(currentlyChecking);
                if (pointList == null)
                    return null;

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

                    foreach (var nodeList in RouteList)
                    {
                        if (nodeList.Count >= 4)
                        {
                            PointField field = findClosed(nodeList);
                            if (field != null)
                            {
                                returnList.Add(field);
                            }
                        }
                    }
                }

                currentField[currentlyChecking.y, currentlyChecking.x] = currentlyChecking.value;

            }
            return returnList;
        }
예제 #2
0
파일: GameField.cs 프로젝트: BjkGkh/Boon
        private List<Point> getConnectedItems(GametileUpdate update)
        {
            if (update == null)
                return null;

            var 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;
        }