示例#1
0
        // Update is called once per frame
        private void Update()
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                string countdownText     = "";
                int    countdownFontSize = 60;

                countdown--;
                switch (countdown)
                {
                case 4:
                    countdownText     = "READY";
                    countdownFontSize = 80;
                    UISound.Play(countdown1);
                    break;

                case 3:
                    countdownText     = "STEADY";
                    countdownFontSize = 100;
                    UISound.Play(countdown1);
                    break;

                case 2:
                    countdownText     = "GET SET";
                    countdownFontSize = 120;
                    UISound.Play(countdown1);
                    break;

                case 1:
                    countdownText     = "GO FAST";
                    countdownFontSize = 160;
                    UISound.Play(countdown2);
                    if (OnCountdownFinished != null)
                    {
                        OnCountdownFinished(this, new System.EventArgs());
                    }
                    break;

                case 0:
                    Destroy(gameObject);
                    break;
                }

                countdownLabel.text = countdownText;
                targetFontSize      = countdownFontSize;

                timer = 1f;
                if (countdown == 1)
                {
                    timer = 2f;
                }
            }

            currentFontSize         = Mathf.Lerp(currentFontSize, targetFontSize, Time.deltaTime * 10);
            countdownLabel.fontSize = (int)currentFontSize;
        }
示例#2
0
        private void TargetPlayer_Respawned(object sender, EventArgs e)
        {
            UISound.Play(respawnSound);

            checkpointTimeField.text = "Respawn lap time penalty";
            checkpointTimeField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

            checkpointTimeDiffField.color = Color.red;
            checkpointTimeDiffField.text  = "+" + Utils.GetTimeString(TimeSpan.FromSeconds(5));
            checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);
        }
示例#3
0
        private void TargetPlayer_NextCheckpointPassed(object sender, NextCheckpointPassArgs e)
        {
            UISound.Play(checkpointSound);
            checkpointTimeField.text = Utils.GetTimeString(e.CurrentLapTime);
            checkpointTimeField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

            if (TargetPlayer.LapRecordsEnabled)
            {
                CharacterTier tier      = ActiveData.Characters[targetPlayer.Character].tier;
                string        sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
                int           stage     = ActiveData.Stages.Where(a => a.sceneName == sceneName).First().id;

                float time = (float)e.CurrentLapTime.TotalSeconds;

                RaceRecord bestRecord = ActiveData.RaceRecords
                                        .Where(a => a.Tier == tier && a.Stage == stage && a.GameVersion == GameVersion.AS_FLOAT && a.WasTesting == GameVersion.IS_TESTING)
                                        .OrderBy(a => a.Time)
                                        .FirstOrDefault();

                if (bestRecord != null)
                {
                    float diff = time - bestRecord.CheckpointTimes[e.IndexOfPreviousCheckpoint];

                    bool     faster   = diff < 0;
                    TimeSpan diffSpan = TimeSpan.FromSeconds(Mathf.Abs(diff));

                    checkpointTimeDiffField.text  = (faster ? "-" : "+") + Utils.GetTimeString(diffSpan);
                    checkpointTimeDiffField.color = faster ? Color.blue : Color.red;
                    checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

                    if (e.IndexOfPreviousCheckpoint == StageReferences.Active.checkpoints.Length - 1 && faster)
                    {
                        checkpointTimeDiffField.text = "New lap record!";
                    }
                }
                else
                {
                    if (e.IndexOfPreviousCheckpoint == StageReferences.Active.checkpoints.Length - 1)
                    {
                        checkpointTimeDiffField.text  = "Lap record set!";
                        checkpointTimeDiffField.color = Color.blue;
                        checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);
                    }
                }
            }
        }
示例#4
0
    public void playSound2D(string theSoundName)
    {
        for (int i = 0; i < _allPlayableSound.Count; i++)
        {
            if (_allPlayableSound[i].name == theSoundName)
            {
                GameObject sound = new GameObject("UI Sound");
                sound.transform.position = Vector3.zero;
                UISound sp = sound.AddComponent <UISound>();
                sp.transform.parent = _soundsParent.transform;
                sp.Init();
                sp.Play(_allPlayableSound[i].clip, _allPlayableSound[i].loop);
                return;
            }
        }

        Debug.LogError("Could not find sound " + theSoundName + " to play it 2D");
    }
        private void Update()
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                string countdownText     = "";
                int    countdownFontSize = 60;

                countdown--;
                switch (countdown)
                {
                case 4:
                    countdownText = "READY";
                    if (blue)
                    {
                        countdownText = "I'M";
                    }
                    countdownFontSize = 80;
                    UISound.Play(countdown1);
                    break;

                case 3:
                    countdownText = "STEADY";
                    if (blue)
                    {
                        countdownText = "BLUE";
                    }
                    countdownFontSize = 100;
                    UISound.Play(countdown1);
                    break;

                case 2:
                    countdownText = "GET SET";
                    if (blue)
                    {
                        countdownText = "DA BA DEE";
                    }
                    countdownFontSize = 120;
                    UISound.Play(countdown1);
                    break;

                case 1:
                    countdownText = "GO FAST";
                    if (blue)
                    {
                        countdownText = "DA BA DYE";
                    }
                    countdownFontSize = 160;
                    UISound.Play(countdown2);
                    if (OnCountdownFinished != null)
                    {
                        OnCountdownFinished(this, new System.EventArgs());
                    }
                    if (esport)
                    {
                        esport.StartTheShit();
                    }

                    else if (green)
                    {
                        green.StartTheShit();
                    }
                    else if (blue)
                    {
                        blue.StartTheShit();
                    }
                    else if (red)
                    {
                        red.StartTheShit();
                    }
                    break;

                case 0:
                    Destroy(gameObject);
                    break;
                }

                countdownLabel.text = countdownText;
                targetFontSize      = countdownFontSize;

                timer = 1f;
                if (countdown == 1)
                {
                    timer = 2f;
                }
            }

            currentFontSize         = Mathf.Lerp(currentFontSize, targetFontSize, Time.deltaTime * 10);
            countdownLabel.fontSize = (int)currentFontSize;
        }