Esempio n. 1
0
 void Start()
 {
     beepLight = GetComponentInChildren <Light>();
     rb        = GetComponent <Rigidbody>();
     rb.AddForce(1000f * direction.normalized);
     soundManager = GameObject.Find("InRaceSoundPlayer").GetComponent <InRaceSoundManager>();
 }
Esempio n. 2
0
    void Update()
    {
        if (currentState == State.RaceBegin)
        {
            raceBeginChrono += Time.deltaTime;

            if (raceBeginChrono >= raceBeginTime - 2 &&
                camController.currentMode == CameraController.CameraMode.RaceBegin)
            {
                camController.SetMode(CameraController.CameraMode.PositionBehindPlayer);
            }
            else if (raceBeginChrono >= raceBeginTime)
            {
                SetState(State.CountDown);
            }
        }
        else if (currentState == State.CountDown)
        {
            countDownChrono += Time.deltaTime;
            if (countDownChrono < 3)
            {
                countDownText.text = (3 - ((int)countDownChrono)).ToString();

                float fract = countDownChrono - ((int)countDownChrono); // Scale animation
                float scale = 1.0f - fract;
                countDownText.GetComponent <RectTransform>().localScale = new Vector3(scale, scale, scale);
            }
            else if (!goText.enabled)
            {
                goText.enabled = true;
                goText.GetComponent <Animator>().SetTrigger("FadeOut");
            }
            else
            {
                SetState(State.InRace);
            }
        }
        else if (currentState == State.InRace)
        {
        }
        else if (currentState == State.RaceFinished)
        {
            positionText.fontSize = ((int)Mathf.Lerp(positionText.fontSize, maxPositionTextSize, 5.0f * Time.deltaTime));
        }

        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.P))
        {
            InRaceSoundManager.PlayPauseSound();
            if (currentState == State.Paused)
            {
                UnPause();
            }
            else
            {
                SetState(State.Paused);
            }
        }
    }