Example #1
0
// Countdown function
    void F_Countdown()
    {
        Timer -= Time.deltaTime;
        string seconds = Mathf.Floor(Timer % 60).ToString("0");


        if (txt_Countdown && LastTimer != seconds && Timer >= 0)
        {
            int tmpINt = int.Parse(seconds);
            txt_Countdown.text = list_Txt [list_Txt.Count - 1 - tmpINt];

            if (_audio && list_Audio [list_Txt.Count - 1 - tmpINt] != null)
            {
                _audio.clip = list_Audio [list_Txt.Count - 1 - tmpINt];
                _audio.Play();
            }


            if (gameManager && seconds == "0")
            {
                gameManager.RaceStart();
            }
        }
        else if (txt_Countdown && LastTimer != seconds)
        {
            txt_Countdown.text = "";
        }
        LastTimer = seconds;
    }
Example #2
0
    // Countdown function



    void F_Countdown()
    {
        if (PlayerPrefs.GetString("Which_GameMode") == "OnlineMultiPlayer")
        {
#if PHOTON_UNITY_NETWORKING
            if (countdownTimer == null)
            {
                GameObject tmpObj = GameObject.Find("GM_Photon");
                if (tmpObj)
                {
                    countdownTimer = tmpObj.GetComponent <MCR.MCRPhotonCountdown>();
                }
                if (tmpObj)
                {
                    countdownTimer.F_InitStartTime();
                }
            }



            if (countdownTimer && countdownTimer.b_InitStartTime)
            {
                Timer = int.Parse((string)countdownTimer.returnPhotonCountdown());
                if (txt_Countdown && LastTimer != countdownTimer.returnPhotonCountdown() && Timer >= 0)
                {
                    int tmpINt = int.Parse((string)countdownTimer.returnPhotonCountdown());
                    txt_Countdown.text = list_Txt[list_Txt.Count - 1 - tmpINt];

                    if (_audio && list_Audio[list_Txt.Count - 1 - tmpINt] != null)
                    {
                        _audio.clip = list_Audio[list_Txt.Count - 1 - tmpINt];
                        _audio.Play();
                    }


                    if (gameManager && countdownTimer.returnPhotonCountdown() == "0")
                    {
                        gameManager.RaceStart();
                    }
                }
                else if (txt_Countdown && LastTimer != countdownTimer.returnPhotonCountdown())
                {
                    txt_Countdown.text = "";
                }

                LastTimer = countdownTimer.returnPhotonCountdown();
            }
#endif
        }
        else
        {
            Timer -= Time.deltaTime;
            string seconds = Mathf.Floor(Timer % 60).ToString("0");


            if (txt_Countdown && LastTimer != seconds && Timer >= 0)
            {
                int tmpINt = int.Parse(seconds);
                txt_Countdown.text = list_Txt[list_Txt.Count - 1 - tmpINt];

                if (_audio && list_Audio[list_Txt.Count - 1 - tmpINt] != null)
                {
                    _audio.clip = list_Audio[list_Txt.Count - 1 - tmpINt];
                    _audio.Play();
                }


                if (gameManager && seconds == "0")
                {
                    gameManager.RaceStart();
                }
            }
            else if (txt_Countdown && LastTimer != seconds)
            {
                txt_Countdown.text = "";
            }
            LastTimer = seconds;
        }
    }