public List <PointField> doUpdate(bool oneloop = false) { List <PointField> returnList = new List <PointField>(); while (this.newEntries.Count > 0) { this.currentlyChecking = this.newEntries.Dequeue(); List <System.Drawing.Point> pointList = getConnectedItems(this.currentlyChecking); if (pointList.Count > 1) { List <LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> > RouteList = handleListOfConnectedPoints(pointList, this.currentlyChecking); foreach (LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> nodeList in RouteList) { if (nodeList.Count >= 1) { PointField field = findClosed(nodeList); if (field != null) { returnList.Add(field); } } } } this.currentField[this.currentlyChecking.Y, this.currentlyChecking.X] = this.currentlyChecking.GameTeam; } return(returnList); }
private List <System.Drawing.Point> getConnectedItems(RoomBattleBanzaiTileStateUpdate update) { List <System.Drawing.Point> ConnectedItems = new List <System.Drawing.Point>(); int x = update.X; int y = update.Y; if (true) { if (this[y - 1, x - 1] && this.currentField[y - 1, x - 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x - 1, y - 1)); } if (this[y - 1, x + 1] && this.currentField[y - 1, x + 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x + 1, y - 1)); } if (this[y + 1, x - 1] && this.currentField[y + 1, x - 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x - 1, y + 1)); } if (this[y + 1, x + 1] && this.currentField[y + 1, x + 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x + 1, y + 1)); } } if (this[y - 1, x] && this.currentField[y - 1, x] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x, y - 1)); } if (this[y + 1, x] && this.currentField[y + 1, x] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x, y + 1)); } if (this[y, x - 1] && this.currentField[y, x - 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x - 1, y)); } if (this[y, x + 1] && this.currentField[y, x + 1] == update.GameTeam) { ConnectedItems.Add(new System.Drawing.Point(x + 1, y)); } return(ConnectedItems); }
private List <LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> > handleListOfConnectedPoints(List <System.Drawing.Point> pointList, RoomBattleBanzaiTileStateUpdate update) { List <LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> > returnList = new List <LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> >(); int amount = 0; foreach (System.Drawing.Point begin in pointList) { amount++; if (amount == pointList.Count / 2 + 1) { return(returnList); } foreach (System.Drawing.Point end in pointList) { if (begin == end) { continue; } LinkedList <AStarSolver <RoomBattleBallGameField> .PathNode> list = this.astarSolver.Search(end, begin); if (list != null) { returnList.Add(list); } } } return(returnList); }