106 lines
2.8 KiB
C#
106 lines
2.8 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Ichni.RhythmGame
|
|||
|
|
{
|
|||
|
|
public class PlayingRecorder
|
|||
|
|
{
|
|||
|
|
public int perfectCount;
|
|||
|
|
public int goodCount;
|
|||
|
|
public int badCount;
|
|||
|
|
public int missCount;
|
|||
|
|
public int totalCount;
|
|||
|
|
|
|||
|
|
public float accuracy;
|
|||
|
|
|
|||
|
|
public int currentCombo;
|
|||
|
|
public int maxCombo;
|
|||
|
|
|
|||
|
|
public bool isFullCombo;
|
|||
|
|
public bool isAllPerfect;
|
|||
|
|
|
|||
|
|
public void Initialize()
|
|||
|
|
{
|
|||
|
|
perfectCount = 0;
|
|||
|
|
goodCount = 0;
|
|||
|
|
badCount = 0;
|
|||
|
|
missCount = 0;
|
|||
|
|
totalCount = 0;
|
|||
|
|
accuracy = 100f;
|
|||
|
|
currentCombo = 0;
|
|||
|
|
maxCombo = 0;
|
|||
|
|
isFullCombo = true;
|
|||
|
|
isAllPerfect = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void UpdateAccuracy()
|
|||
|
|
{
|
|||
|
|
float baseValue = perfectCount + goodCount * 0.7f + badCount * 0.3f;
|
|||
|
|
if (totalCount > 0)
|
|||
|
|
{
|
|||
|
|
accuracy = baseValue / totalCount * 100f;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
accuracy = 100f; // 如果没有任何击打,准确率为100%
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AddCombo()
|
|||
|
|
{
|
|||
|
|
currentCombo++;
|
|||
|
|
maxCombo = Mathf.Max(maxCombo, currentCombo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ResetCombo()
|
|||
|
|
{
|
|||
|
|
currentCombo = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddPerfect()
|
|||
|
|
{
|
|||
|
|
perfectCount++;
|
|||
|
|
totalCount++;
|
|||
|
|
AddCombo();
|
|||
|
|
UpdateAccuracy();
|
|||
|
|
GameManager.instance.gameUIController.UpdateAccuracy(accuracy);
|
|||
|
|
GameManager.instance.gameUIController.UpdateCombo(currentCombo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddGood()
|
|||
|
|
{
|
|||
|
|
goodCount++;
|
|||
|
|
totalCount++;
|
|||
|
|
AddCombo();
|
|||
|
|
UpdateAccuracy();
|
|||
|
|
isAllPerfect = false;
|
|||
|
|
GameManager.instance.gameUIController.UpdateAccuracy(accuracy);
|
|||
|
|
GameManager.instance.gameUIController.UpdateCombo(currentCombo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddBad()
|
|||
|
|
{
|
|||
|
|
badCount++;
|
|||
|
|
totalCount++;
|
|||
|
|
ResetCombo();
|
|||
|
|
UpdateAccuracy();
|
|||
|
|
isFullCombo = false;
|
|||
|
|
isAllPerfect = false;
|
|||
|
|
GameManager.instance.gameUIController.UpdateAccuracy(accuracy);
|
|||
|
|
GameManager.instance.gameUIController.UpdateCombo(currentCombo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddMiss()
|
|||
|
|
{
|
|||
|
|
missCount++;
|
|||
|
|
totalCount++;
|
|||
|
|
ResetCombo();
|
|||
|
|
UpdateAccuracy();
|
|||
|
|
isFullCombo = false;
|
|||
|
|
isAllPerfect = false;
|
|||
|
|
GameManager.instance.gameUIController.UpdateAccuracy(accuracy);
|
|||
|
|
GameManager.instance.gameUIController.UpdateCombo(currentCombo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|