コード例 #1
0
    /// <summary>
    /// Initialize the needed parameters for a new game.
    /// </summary>
    public void Initialize()
    {
        _isGameOver  = false;
        _currLap     = 0;
        _lapsTime    = new float[_lapsTexts.Length];
        _currLapTime = 0;
        _totalTime   = 0;
        _isFinished  = false;

        _currHighScore      = PlayerPrefs.GetFloat(HIGH_SCORE_KEY);
        _highScoreText.text = string.Format(LAP_TIME_FORMAT, (int)(_currHighScore / 60), _currHighScore % 60);
        _recording          = LoadRecording();

        foreach (Text lapText in _lapsTexts)
        {
            lapText.text = string.Format(LAP_TIME_FORMAT, 0, 0);
        }

        _player.transform.position = _spawnPoint.transform.position;
        _player.transform.rotation = _spawnPoint.transform.rotation;
        _player.GetComponent <Rigidbody>().velocity = Vector3.zero;

        RecordMovement recording = _player.GetComponent <RecordMovement>();

        if (recording != null)
        {
            recording.ResetRecording();
            recording.StartRecording();
        }

        StartCoroutine("PlaySoundtrack");
    }
コード例 #2
0
    /// <summary>
    /// End the game.
    /// </summary>
    public void GameOver()
    {
        _isGameOver = true;
        if (_isFinished)
        {
            if (_currHighScore > _totalTime || _currHighScore <= 0)
            {
                PlayerPrefs.SetFloat(HIGH_SCORE_KEY, _totalTime);
                PlayerPrefs.Save();

                RecordMovement recording = _player.GetComponent <RecordMovement>();
                if (recording != null)
                {
                    recording.StopRecording();
                    SaveRecording(recording.GetRecording());
                    recording.ResetRecording();
                }
            }
        }

        _menu.PauseGame();
    }
コード例 #3
0
 // Start is called before the first frame update
 private void Awake()
 {
     path    += filename;
     timeline = GameObject.FindGameObjectWithTag("Human").GetComponent <RecordMovement>();
 }