Esempio n. 1
0
    void Start()
    {
        // Get the last game score
        float score = PlayerPrefsX.GetFloatList("highScore") [(PlayerPrefsX.GetFloatList("highScore").Count) - 1];

        scoreText.text = Mathf.Floor(score / 60).ToString("00") + ":" + (score % 60).ToString("00");
    }
Esempio n. 2
0
    void cardComparison(List <int> list)
    {
        cardScript.canPlayCard = false;

        int x = 0;

        // if the 2 flipped cards are the same
        if (cards [list[0]].GetComponent <cardScript> ().cardValue == cards [list[1]].GetComponent <cardScript> ().cardValue)
        {
            x = 2;             // card are the same

            // Hide the cards
            (cards [list[0]]).transform.localScale = new Vector3(0, 0, 0);
            (cards [list[1]]).transform.localScale = new Vector3(0, 0, 0);

            GameObject.Find("musicManager").GetComponent <musicPlayer> ().matchSound.Play();
            _matches--;             // decrement left matches
            matchText.text = _matches.ToString();

            if (_matches == 0)               // game is over
            // Add highscore
            {
                var highScores = new List <float>();
                highScores = PlayerPrefsX.GetFloatList("highScore");
                highScores.Add(gameTime);
                PlayerPrefsX.SetFloatArray("highScore", highScores.ToArray());
                Debug.Log(((PlayerPrefsX.GetFloatArray("highScore")[0]).ToString()));

                // Load win scene
                SceneManager.LoadScene("winScene");
            }
        }

        for (int i = 0; i < list.Count; i++)
        {
            // if the the 2 cards are the same state = 2
            // Cards won't flip again
            // Else state = 0
            cards [list[i]].GetComponent <cardScript> ().state = x;
            cards [list [i]].GetComponent <cardScript> ().check();
        }
    }