private void CheckingPoints(byte direction, ShrunkNode[,] shrunkMap) { if (ShrunkWorldBuilder.xLegitShrunkMap(newPoint.X, 0) && ShrunkWorldBuilder.yLegitShrunkMap(newPoint.Y, 0)) { if (!(IsSearched[newPoint.X, newPoint.Y])) //if it hasnt been searched add it to the list { if (direction == directionFrom[currentPoint.X, currentPoint.Y]) { CalculateNewScores(false, shrunkMap); } else { CalculateNewScores(true, shrunkMap); } AddToList(direction); } else// it has been searched. lets remove the old one from the list { CalculateNewScores(false, shrunkMap); if (newPointScore < score[newPoint.X, newPoint.Y]) //this one is better { AddToList(direction); RemoveFromList(); } } } }
private void AddNewPoints(Dictionary <int, AStarNode> toCheckList, Dictionary <int, AStarNode> checkedNodeList, Point workingPoint, AStarNode workingNode, int findTownId) { for (byte i = 0; i < 8; i += 2) { Point newPoint = workingPoint + AngleStuff.directionPoint[i]; if (ShrunkWorldBuilder.xLegitShrunkMap(newPoint.X, 0) && ShrunkWorldBuilder.yLegitShrunkMap(newPoint.Y, 0)) { if (shrunkMap[newPoint.X, newPoint.Y].townId == findTownId) { //we found it... lets add this cheapy to the list so it will always grab it next time int id = GetOneD(newPoint); toCheckList.Add(id, new AStarNode(id, GetOneD(workingPoint), 1, 1, i, false)); break; } else { if (!IsInLists(newPoint, toCheckList, checkedNodeList)) { int tileScore = shrunkMap[newPoint.X, newPoint.Y].pathScore; int id = GetOneD(newPoint); toCheckList.Add(id, new AStarNode(id, GetOneD(workingPoint), CalcNScore(tileScore, workingNode, i != workingNode.directionFrom), CalcHScore(newPoint), i, false)); } } } } }
private void UpdateNewPoints(ShrunkNode[,] shrunkMap, int findTownId) { for (byte i = 0; i < 8; i += 2) { newPoint = AngleStuff.AddPointToDirection(currentPoint, i); CheckingPoints(i, shrunkMap); if (ShrunkWorldBuilder.xLegitShrunkMap(newPoint.X, 0) && ShrunkWorldBuilder.yLegitShrunkMap(newPoint.Y, 0)) { if (shrunkMap[newPoint.X, newPoint.Y].townId == findTownId) { found = true; currentPoint = newPoint; break; } } } }