Esempio n. 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;
        }
Esempio n. 2
0
		public List<PointField> doUpdate(bool oneloop = false)
		{
			List<PointField> list = new List<PointField>();
			while (this.newEntries.Count > 0)
			{
				this.currentlyChecking = this.newEntries.Dequeue();
				List<Point> connectedItems = this.getConnectedItems(this.currentlyChecking);
				if (connectedItems.Count > 1)
				{
					List<LinkedList<AStarSolver<GameField>.PathNode>> list2 = this.handleListOfConnectedPoints(connectedItems, this.currentlyChecking);
					foreach (LinkedList<AStarSolver<GameField>.PathNode> current in list2)
					{
						if (current.Count >= 4)
						{
							PointField pointField = this.findClosed(current);
							if (pointField != null)
							{
								list.Add(pointField);
							}
						}
					}
				}
				this.currentField[this.currentlyChecking.y, this.currentlyChecking.x] = this.currentlyChecking.value;
			}
			return list;
		}
Esempio n. 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;
 }
Esempio n. 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;
        }
Esempio n. 5
0
		private List<Point> getConnectedItems(GametileUpdate update)
		{
			List<Point> list = new List<Point>();
			int x = update.x;
			int y = update.y;
			checked
			{
				if (this.diagonal)
				{
					if (this[y - 1, x - 1] && this.currentField[y - 1, x - 1] == update.value)
					{
						list.Add(new Point(x - 1, y - 1));
					}
					if (this[y - 1, x + 1] && this.currentField[y - 1, x + 1] == update.value)
					{
						list.Add(new Point(x + 1, y - 1));
					}
					if (this[y + 1, x - 1] && this.currentField[y + 1, x - 1] == update.value)
					{
						list.Add(new Point(x - 1, y + 1));
					}
					if (this[y + 1, x + 1] && this.currentField[y + 1, x + 1] == update.value)
					{
						list.Add(new Point(x + 1, y + 1));
					}
				}
				if (this[y - 1, x] && this.currentField[y - 1, x] == update.value)
				{
					list.Add(new Point(x, y - 1));
				}
				if (this[y + 1, x] && this.currentField[y + 1, x] == update.value)
				{
					list.Add(new Point(x, y + 1));
				}
				if (this[y, x - 1] && this.currentField[y, x - 1] == update.value)
				{
					list.Add(new Point(x - 1, y));
				}
				if (this[y, x + 1] && this.currentField[y, x + 1] == update.value)
				{
					list.Add(new Point(x + 1, y));
				}
				return list;
			}
		}
Esempio n. 6
0
		private List<LinkedList<AStarSolver<GameField>.PathNode>> handleListOfConnectedPoints(List<Point> pointList, GametileUpdate update)
		{
			List<LinkedList<AStarSolver<GameField>.PathNode>> list = new List<LinkedList<AStarSolver<GameField>.PathNode>>();
			int num = 0;
			checked
			{
				foreach (Point current in pointList)
				{
					num++;
					if (num == pointList.Count / 2 + 1)
					{
						return list;
					}
					foreach (Point current2 in pointList)
					{
						if (!(current == current2))
						{
							LinkedList<AStarSolver<GameField>.PathNode> linkedList = this.astarSolver.Search(current2, current);
							if (linkedList != null)
							{
								list.Add(linkedList);
							}
						}
					}
				}
				return list;
			}
		}