コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if(gameWon && !win.isPlaying && (Input.GetButtonDown("Jump") || Input.GetButtonDown("Cancel") || Input.GetButtonDown("Submit"))){
            Application.LoadLevel(0);
        }

        if (totalCoins > 0) {

            text.text = coins.ToString () + " / " + totalCoins.ToString ();

            if (coins == totalCoins && !soundPlayed) {
                win.Play ();
                soundPlayed = true;
                if(playerAva != null){
                    playerAva.onPause ();
                    playerAva.GetComponent<Rigidbody> ().velocity = new Vector3 (0, 0, 0);
                } else {
                    playerAva = GameObject.Find ("DudeGuy").GetComponent<Avatar>();
                    playerAva.onPause ();
                    playerAva.GetComponent<Rigidbody> ().velocity = new Vector3 (0, 0, 0);
                }

                for (int i = 0; i < levelMusic.Length; i++) {
                    if (levelMusic [i].isPlaying) {
                        levelMusic [i].Stop ();
                    }
                }

            } else if (coins == totalCoins && soundPlayed && !win.isPlaying) {
                int currentLevel = Application.loadedLevel;
                Debug.Log(Application.levelCount);
                if(Application.levelCount - 1 > currentLevel){
                    Application.LoadLevel(currentLevel+1);
                } else {
                    gameWon = true;
                }
            }

        } else {
            text.text = "No Coins";
        }
    }