Exemplo n.º 1
0
        public void SetLevelFromLevelAsText()
        {
            level = new Dictionary <Vector2Int, int>();

            if (levelAsTextData == "")
            {
                return;
            }

            string[] lar = levelAsTextData.Split(',');
            tridSize = new TridSize(int.Parse(lar[0]), int.Parse(lar[1]), int.Parse(lar[2]), int.Parse(lar[3]), int.Parse(lar[4]));
            int index = 5;//starting index where our level data begins.

            palette = new Color[tridSize.colors];
            for (int i = 0; i < tridSize.colors; i++)
            {
                Color c = Color.black;
                ColorUtility.TryParseHtmlString(lar[5 + i], out c);
                palette[i] = c;
                index++;
            }
            //
            HintItem.palette = palette;
            //
            for (int i = index; i < lar.Length - 2; i = i + 3)
            {
                if (lar[i] != "" && lar[i + 1] != "" && lar[i + 2] != "")
                {
                    Vector2Int p = new Vector2Int(int.Parse(lar[i]), int.Parse(lar[i + 1]));
                    level[p] = int.Parse(lar[i + 2]);
                }
            }
        }
Exemplo n.º 2
0
        void SpawnGrid(TridSize gs)
        {
            ClearData();
            //our origin will be if we extended the hexagon into a triangle alllll the way out to the bottom left.
            //so the bottom row is y = 0.
            //For the actual bottom row, it starts at some offset that we have to figure out, and that is the bottomLeft size.
            Vector2Int origin = Vector2Int.zero;

            //idfk guys something about the triangles being points up or down or where the origin should be. it works.
            if (gs._bottomLeft != 0)
            {
                origin.x = gs._bottomLeft;
                if (gs._bottomLeft % 2 == 0)
                {
                    origin.x = gs._bottomLeft + gs._bottom + 1;
                }
            }
            Triangle   o         = new Triangle(origin);
            Vector2Int lastValid = origin;

            AddTriangle(o); //lets start somewhere and march around.
            Triangle t = o; //stamping triangle to march.

            //lets make the bottom row.
            //triangles on a side with n triangle faces at the side = 2n-2
            for (int i = 0; i < gs.bottomTris; i++)
            {
                t = new Triangle(Triangle.MarchHorizontal(t.position, 1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                }
                ;
            }
            //bottom right edge
            for (int i = 0; i < gs.bottomRightTris; i++)
            {
                t = new Triangle(Triangle.MarchPositiveSlope(t.position, 1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                }
                ;
            }
            //topRight edge
            for (int i = 0; i < gs.topRightTris; i++)
            {
                t = new Triangle(Triangle.MarchNegativeSlope(t.position, -1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                }
            }
            //top edge
            for (int i = 0; i < gs.topTris; i++)
            {
                t = new Triangle(Triangle.MarchHorizontal(t.position, -1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                    //
                }
                ;
            }
            //top left edge
            for (int i = 0; i < gs.topLeftTris; i++)
            {
                t = new Triangle(Triangle.MarchPositiveSlope(t.position, -1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                }
                ;
            }
            //bottlmLeft edge
            for (int i = 0; i < gs.bottomLeftTris; i++)
            {
                t = new Triangle(Triangle.MarchNegativeSlope(t.position, 1));
                if (AddTriangle(t))
                {
                    lastValid = t.position;
                }
                ;
            }


            //Alright so we have the outline.
            SpawnFill();

            IdentifyPuzzleEdges();
        }