Esempio n. 1
0
    void OnGUI()
    {
        int minutes = Mathf.FloorToInt(currentTimer / 60F);
        int seconds = Mathf.FloorToInt(currentTimer - minutes * 60);

        if (currentTimer == 0)
        {
            FontSizeOverRide *= 2;
        }

        if (countDownPlayer1.GetComponent <Text>().text != "")
        {
            int size = (int)Mathf.PingPong(Time.time * timeScale, FontSizeOverRide);
            if (size < minimumFontSize)
            {
                size = minimumFontSize;
            }
            countDownPlayer1.GetComponent <Text>().fontSize = countDownPlayer2.GetComponent <Text>().fontSize = size;
        }

        if (!beginTimer)
        {
            countDownPlayer1.GetComponent <Text>().text = countDownPlayer2.GetComponent <Text>().text = seconds.ToString();
        }
        else
        {
            if (currentTimer <= 1f)
            {
                // Nitro is disabled while counting down
                SCR_Nitro policeNitroScript = GameObject.FindGameObjectWithTag("PoliceCar").GetComponent <SCR_Nitro>();
                SCR_Nitro truckNitroScript  = GameObject.FindGameObjectWithTag("DonutTruck").GetComponent <SCR_Nitro>();
                // Nitro is enabled here
                policeNitroScript.SetCountDownIsOver(true);
                truckNitroScript.SetCountDownIsOver(true);

                if (SCR_ButtonMaster.Player1 == "Police")
                {
                    countDownPlayer1.GetComponent <Text>().text = "Fight";
                    countDownPlayer2.GetComponent <Text>().text = "Survive";
                }
                else
                {
                    countDownPlayer2.GetComponent <Text>().text = "Survive";
                    countDownPlayer1.GetComponent <Text>().text = "Fight";
                }
            }
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (_IsHit == false)    // Not hit yet
        {
            if (collision.transform.CompareTag("PoliceCar"))
            {
                SCR_Nitro policeNitroScript = collision.transform.GetComponent <SCR_Nitro>();
                policeNitroScript.AddPropNitro();
                Debug.Log("Gave reward nitro  nitro.");
                SCR_FlashUI.FlashNitroUIPolice.FlashImage();
                if (_Respawn != null)
                {
                    _Respawn.IsHit();
                }
                _IsHit = true;
                ParticleEffect();
                if (HitSound != null)
                {
                    HitSound.clip = HitClip;
                    HitSound.Play();
                }
            }
            else if (collision.transform.CompareTag("DonutTruck"))
            {
                SCR_Nitro DonutTruckNitroScript = collision.transform.GetComponent <SCR_Nitro>();
                DonutTruckNitroScript.AddPropNitro();
                SCR_FlashUI.FlashNitroUITruck.FlashImage();
                if (GetComponent <SCR_PropRespawn>() != null)
                {
                    GetComponent <SCR_PropRespawn>().IsHit();
                }

                if (_Respawn != null)
                {
                    _Respawn.IsHit();
                }
                _IsHit = true;

                ParticleEffect();
                GameObject.FindWithTag("AbilityManager").GetComponent <SCR_CaptureTheFlagg>().ActivateBonusPoints = true;
                if (HitSound != null)
                {
                    HitSound.clip = HitClip;
                    HitSound.Play();
                }
            }
        }
    }