Exemple #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);
            }
        }
Exemple #2
0
        public void SetPuzzleSolution(TriddlePuzzle p)
        {
            Dictionary <Vector2Int, int> level = new Dictionary <Vector2Int, int>();

            foreach (KeyValuePair <Vector2Int, Triangle> vt in trid)
            {
                level.Add(vt.Key, vt.Value.status);
            }
            //
            p.t_solution  = puzzleEdges.GetSolutionsForEdge(LevelEdge.top, level);
            p.tl_solution = puzzleEdges.GetSolutionsForEdge(LevelEdge.topLeft, level);
            p.tr_solution = puzzleEdges.GetSolutionsForEdge(LevelEdge.topRight, level);
            p.b_solution  = puzzleEdges.GetSolutionsForEdge(LevelEdge.bottom, level);
            p.br_solution = puzzleEdges.GetSolutionsForEdge(LevelEdge.bottomRight, level);
            p.bl_solution = puzzleEdges.GetSolutionsForEdge(LevelEdge.bottomLeft, level);
            //
            p.level = level;//not sure about this one.
            //
        }
Exemple #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!");
                }
            }
        }