/// <summary> /// 清除路径 /// </summary> public void ClearPath() { if (currentPathExists) { HexagonCell current = currentPathTo; while (current != currentPathFrom) { current.SetLabel(null); current.DisableHighlight(); current = current.PathFrom; } current.DisableHighlight(); currentPathExists = false; } currentPathFrom = currentPathTo = null; }
/// <summary> /// 高亮路径 /// </summary> /// <param name="speed"></param> private void ShowPath(int speed) { if (currentPathExists) { HexagonCell current = this.currentPathTo; while (current != currentPathFrom) { int turn = (current.Distance - 1) / speed; current.SetLabel(turn.ToString()); current.EnableHighlight(Color.white); current = current.PathFrom; } } currentPathFrom.EnableHighlight(Color.blue); currentPathTo.EnableHighlight(Color.red); }