Example #1
0
    public void StartButtonClicked()
    {
        System.GC.Collect();
//		GameStateManager.Instance.NumBerOfGame = 0;
        showPanels.gameTitleText.SetActive(false);
        GameStateManager.Instance.IsStarted = true;                                                     //keep loading the starting scene
        GameStateManager.Instance.StartGame();
//		Debug.Log(GameStateManager.HighScore);
        GameStateManager.Instance.Restart();
        updateScore.ChangeLiveScore();

        textColor.ChooseTextColor();
        //If changeMusicOnStart is true, fade out volume of music group of AudioMixer by calling FadeDown function of PlayMusic, using length of fadeColorAnimationClip as time.
        //To change fade time, change length of animation "FadeToColor"
        if (changeMusicOnStart)
        {
            playMusic.FadeDown(fadeColorAnimationClip.length);
        }

        //If changeScenes is true, start fading and change scenes halfway through animation when screen is blocked by FadeImage
        if (changeScenes)
        {
            //Use invoke to delay calling of LoadDelayed by half the length of fadeColorAnimationClip
            Invoke("LoadDelayed", fadeColorAnimationClip.length * .5f);

            //Set the trigger of Animator animColorFade to start transition to the FadeToOpaque state.
            animColorFade.SetTrigger("fade");
        }

        //If changeScenes is false, call StartGameInScene
        else
        {
            //Call the StartGameInScene function to start game without loading a new scene.
            StartGameInScene();
        }
    }