private int GetDistanceValue(PathfindingNode start, PathfindingNode goal) { int horizontalDisance = Mathf.Abs(start.GetX() - goal.GetX()); int verticalDisance = Mathf.Abs(start.GetY() - goal.GetY()); int remaining = Mathf.Abs(horizontalDisance - verticalDisance); return(DiagonalMovePrice * Mathf.Min(horizontalDisance, verticalDisance) + HorizontalMovePrice * remaining); }
//I have grown very tired of this project. It was supposed to be a fun way for the club to work and learn together, but I am the only one who does any work. I spend my little free time working on this project that I don't have any passion for and it is crushing to me. I feel that if I stop working I will let the club down. Even when I spend my free time on other things I just feel bad fro not having worked on this project when I had the time. I am sad. private List <PathfindingNode> FindNeighbor(PathfindingNode centerNode) { List <PathfindingNode> neighbors = new List <PathfindingNode>(); if (centerNode.GetX() - 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX() - 1, centerNode.GetY())); if (centerNode.GetY() - 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX() - 1, centerNode.GetY() - 1)); } if (centerNode.GetY() + 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX() - 1, centerNode.GetY() + 1)); } } if (centerNode.GetX() + 1 < grid.GetGridWidth()) { neighbors.Add(GetNode(centerNode.GetX() + 1, centerNode.GetY())); if (centerNode.GetY() - 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX() + 1, centerNode.GetY() - 1)); } if (centerNode.GetY() + 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX() + 1, centerNode.GetY() + 1)); } } if (centerNode.GetY() - 1 >= 0) { neighbors.Add(GetNode(centerNode.GetX(), centerNode.GetY() - 1)); } if (centerNode.GetY() + 1 < grid.GetGridHeight()) { neighbors.Add(GetNode(centerNode.GetX(), centerNode.GetY() + 1)); } return(neighbors); }