예제 #1
0
        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);
            }
        }
예제 #2
0
 void ClearData()
 {
     lineRenderer.Reset();
     if (trid != null)
     {
         //destroy all triangle objects
         foreach (Triangle t in trid.Values)
         {
             Destroy(t.drawingObject);
         }
     }
     //destroy all hint drawing objects
     hintDisplay.Reset();
     //reset our data
     puzzleEdges    = new PuzzleEdges();
     trid           = new Dictionary <Vector2Int, Triangle>();
     trisByCentroid = new Dictionary <Vector2, Triangle>();
     //
     //garbage collection should do the rest.
 }
예제 #3
0
        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!");
                }
            }
        }