Beispiel #1
0
    private void CreatePuzzle(string word)
    {
        var puzzle = PuzzleMaker.MakePuzzle(word);
        var startY = -1 * puzzle.height / 2;
        var startX = -1 * puzzle.width / 2;
        var start  = new Vector2(startX, y: startY);

        for (var x = 0; x < puzzle.width; x++)
        {
            for (var y = 0; y < puzzle.height; y++)
            {
                var fy = start.y + y;
                var fx = start.x + x;

                if (y % 2 == 0)
                {
                    fx += 0.5f;
                }

                var pos  = new Vector2(fx, fy);
                var img2 = ImgDir + puzzle.puzzleData[x, y] + ".png";
                var go   = Instantiate(hexPrefab, pos, Quaternion.identity);
                go.GetComponent <SpriteRenderer>().sprite = LoadNewSprite(img2);
                go.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            }
        }
    }
Beispiel #2
0
    public void LoadPuzzle(string word)
    {
        _words = word.ToUpper(new CultureInfo("tr-TR", false)).Split(' ').ToList();
        foreach (Transform child in PuzzleParentTransform)
        {
            Destroy(child.gameObject);
        }

        var sentence = Regex.Replace(word.ToUpper(new CultureInfo("tr-TR", false)), @"\s+", "");

        _currentPuzzle = PuzzleMaker.MakePuzzle(sentence);
    }