public void DrawPuzzleHint(PuzzleEdges puzzleEdges) { edgeTriangleToHint = new Dictionary <Vector2Int, HintItem[]>();//for comparisons foreach (Triangle t in puzzleEdges.edgeTriangleToSolutionMap.Keys) { int[] solution = puzzleEdges.edgeTriangleToSolutionMap[t]; HintItem[] hint = TriddlePuzzle.GetHintFromSolution(solution); edgeTriangleToHint.Add(t.position, hint);// Draw(hint, PuzzleEdges.EdgeToSolutionDir(puzzleEdges.EdgeTriangleIsOn(t)), t); } }
public void ComparePuzzleHint(PuzzleEdges puzzleEdges, Vector2Int updatedPos) { Triangle test = triangleGridSystem.GetTriangle(updatedPos); Debug.Log("we have: " + test.edgesForThisTriangle.Count + " to check. it should be 3?"); for (int q = 0; q < test.edgesForThisTriangle.Count; q++) { //q is an arbitrary letter cus i use i lower inside this loop. Vector2Int etpos = test.edgesForThisTriangle[q]; Vector2Int[] row = puzzleEdges.edgeTriangleToRowOfTrianglesMap[etpos]; Debug.Log("Checking edge of length: " + row.Length); int[] maybeSolution = triangleGridSystem.GetCurrentValuesFromList(row); HintItem[] maybeHint = TriddlePuzzle.GetHintFromSolution(maybeSolution); //We should write our own comparator. but thats not even the closest thing to being the ugliest part about the code in this project. bool hintIsCorrect = true; if (maybeHint.Length != edgeTriangleToHint[etpos].Length) { //these aint the same. hintIsCorrect = false; //break; } for (int i = 0; i < maybeHint.Length; i++) { if (edgeTriangleToHint[etpos].Length < i) { if (maybeHint[i].q != edgeTriangleToHint[etpos][i].q || maybeHint[i].status != edgeTriangleToHint[etpos][i].status) { hintIsCorrect = false; // break; } hintIsCorrect = false; } } if (hintIsCorrect) { Debug.Log("a hint is correct!"); } } }