Exemple #1
0
    //private void Update()
    //{
    //if (Input.GetKeyDown("z") || Input.GetKeyDown("x")) {
    //    audioManager.sfxPlay();
    //    playerAnimation.PlayAnimation(PlayerAnimation.AnimationType.Attack);

    //    environmentSpeedControl = 0f;

    //    // Check judgement
    //    if (limiter > 0)
    //    {
    //        float value = map.CheckJudgement(player.notePos);
    //        scoreType.text = score.HitResult(value, true);
    //        player.Hit();
    //        limiter--;
    //    }
    //}
    //}

    public void OnPlayerHit(int answer)
    {
        audioManager.sfxPlay();
        playerAnimation.PlayAnimation(PlayerAnimation.AnimationType.Attack);

        environmentSpeedControl = 0f;

        if (limiter > 0)
        {
            if (answer == choicesManager.problem.result)
            {
                float  value  = map.CheckJudgement(player.notePos);
                string result = score.HitResult(value, true);
                scoreType.text = result;
                choicesManager.CheckFor();
                player.Hit();
            }
            else
            {
                float value = map.CheckJudgement(player.notePos);
                scoreType.text = score.HitResult(value, false);
                choicesManager.CheckFor();
                player.Hit();
            }
            limiter--;
        }
    }
    void Miss()
    {
        playerAnimation.PlayAnimation(PlayerAnimation.AnimationType.Hurt);
        health--;

        checkHealth();

        notePos++;
        choicesManager.CheckFor();
        control.scoreType.text = "Miss";
        GameObject note = GameObject.Find("Note");

        note.name = "Note(Missed)";
    }
Exemple #3
0
    private void Update()
    {
        // Void Update
        // Call spawner method to spawn notes according to time set in judgementTime data
        // Check judgement score in another script where key pressed is detected
        if (isPlaying)
        {
            // Audio sync
            // If when the next frame grab dspTime same, then grab time from unscaledDeltaTime instead
            if (AudioSettings.dspTime == lastDspTime)
            {
                songPosition += Time.unscaledDeltaTime;
            }
            else
            {
                songPosition = (float)AudioSettings.dspTime - dspSongTime;
            }

            lastDspTime = (float)AudioSettings.dspTime;

            // Debug Test
            //if (songPosition >= judgementTime[test].time + (universalOffset/1000) && test < judgementTime.Length - 1)
            //{
            //    //sfx.Play();
            //    test++;
            //}

            // Spawner
            if (songPosition >= judgementTime[pos].time - timeGap + (universalOffset / 1000) && pos < judgementTime.Length - 1)
            {
                if (once)
                {
                    choicesManager.CheckFor();
                    once = false;
                }
                float time = Mathf.Abs((judgementTime[pos].time - songPosition));
                spawner.Spawn(pos, time, judgementTime[pos].regenerate);
                pos++;
            }
        }
    }