예제 #1
0
    public void setScoreDetails()
    {
        string path = Application.persistentDataPath + "/JigsawPuzzle.xml";

        puz = gameController.GetComponent <JigsawPuzzle> ();
        if (puz.gameLevel == 2)
        {
            LevelDataUpdate.UpdateEasy(finalScore, time, path);
        }

        if (puz.gameLevel == 3)
        {
            LevelDataUpdate.UpdateNormal(finalScore, time, path);
        }

        if (puz.gameLevel == 4)
        {
            LevelDataUpdate.UpdateHard(finalScore, time, path);
        }


        correct_guess_count.text = correctGuesses.ToString();
        wrong_guess_count.text   = wrongGuesses.ToString();
        total_guess_count.text   = totalGuesses.ToString();
        correct_guess_score.text = (50 * correctGuesses).ToString("+#;-#;0");
        wrong_guess_score.text   = score_wrong.ToString("+#;-#;0");
        time_used.text           = timeused_in_String;
        total_score.text         = finalScore.ToString();
        bonus1.text = score_time.ToString("+#;-#;0");
        bonus2.text = bonus_acc.ToString("+#;-#;0");
    }
예제 #2
0
    void Awake()
    {
        GameObject scriptObj = GameObject.Find("GameController");

        puz_2                = scriptObj.GetComponent <JigsawPuzzle>();
        num_pieces           = puz_2.gameLevel * puz_2.gameLevel;
        piece_width          = (int)puz_2.piece_w;
        piece_width_with_gap = piece_width + 50;
        pieces               = new Image[num_pieces];
        int lengthx = (piece_width_with_gap * (puz_2.gameLevel * puz_2.gameLevel));

        pieceListStartPosX = -lengthx / 2 + piece_width_with_gap / 2;
        float posX = pieceListStartPosX;

        pieceList = new List <Piece> ();

        int[] randomIntArray = new int[num_pieces];
        for (int a = 0; a < randomIntArray.Length; a++)
        {
            randomIntArray [a] = a;
        }

        for (int b = 0; b < randomIntArray.Length; b++)
        {
            int temp   = randomIntArray [b];
            int random = Random.Range(b, randomIntArray.Length);
            randomIntArray [b]      = randomIntArray[random];
            randomIntArray [random] = temp;
        }

        for (int i = 0; i < randomIntArray.Length; i++)
        {
            print(randomIntArray [i]);
        }

        for (int i = 0; i < num_pieces; i++)
        {
            int randomIndex = randomIntArray [i];

            string name = "piece" + randomIndex;
            if (puz_2.newSpriteArray == null)
            {
                print("null");
            }
            Piece p = new Piece(randomIndex, name, puz_2.newSpriteArray [randomIndex], (GameObject)Instantiate(piecePrefab, panel, false));
            p.setLocalPos(new Vector3(posX, 0, 0));
            posX += piece_width_with_gap;
            p.setPieceSize(puz_2.piece_w, puz_2.piece_h);
            pieceList.Add(p);
        }

        pieceDistance = pieceList [1].rectTransform.anchoredPosition.x - pieceList [0].rectTransform.anchoredPosition.x;

        foreach (Piece p in pieceList)
        {
            print(p.getPieceID() + p.getPieceName());
        }
    }
예제 #3
0
    void Awake()
    {
        audioControll = GameObject.Find("AudioController").GetComponent <AudioControll> ();

        updateOn        = true;
        puz             = gameController.GetComponent <JigsawPuzzle> ();
        score_Text.text = score.ToString();
        time            = 0.0f;
        isGameEnd       = false;
    }
        public void JigsawPuzzleTest()
        {
            List <Piece> pieces;
            List <Tuple <Edge, Edge> > fittedEdges;

            Setup(out pieces, out fittedEdges);

            JigsawPuzzle puzzle = new JigsawPuzzle(4, 4, pieces);

            puzzle.SetFittedEdges(fittedEdges);

            var solution = puzzle.Solve();

            Print(solution);
        }
예제 #5
0
 public void LoadJigsawPuzzle()
 {
     isLoading       = true;
     generatedPieces = new GameObject[puzzlePieceCount.x * puzzlePieceCount.y];
     loadingRoutine  = StartCoroutine(JigsawPuzzle.Generate(puzzlePieceCount.x, puzzlePieceCount.y, puzzleSize.x, puzzleSize.z, puzzleSize.y, 5, seed, jigsawParent, generatedPieces, puzzleFaceMat, puzzleSideMat, puzzleBackMat, true, OnPuzzleLoadingPercent, OnPuzzleLoadCompleted));
 }
예제 #6
0
 void Start()
 {
     StartCoroutine(JigsawPuzzle.Generate(columns, rows, width, height, depth, bezierSmoothness, seed, transform, null, faceMaterial, sideMaterial, bottomMaterial, true));
     //JigsawPuzzle.Generate(columns, rows, width, height, depth, bezierSmoothness, transform, faceMaterial, sideMaterial, bottomMaterial, true);
 }