|
@@ -18,13 +18,7 @@ public class SoundGameController : MonoBehaviour
|
|
|
float gameStartTime;
|
|
|
float GameEndTime;
|
|
|
// 游戏得分统计
|
|
|
- int score = 0;
|
|
|
- int combo = 0;
|
|
|
- int PerfectCount = 0;
|
|
|
- int GoodCount = 0;
|
|
|
- int PoorCount = 0;
|
|
|
- int MissCount = 0;
|
|
|
- int totalCount = 0;
|
|
|
+ int score, combo, maxCombo, NGCombo, perfectCount, goodCount, poorCount, missCount, totalCount;
|
|
|
|
|
|
// TapOrSwipe 触控检测
|
|
|
Vector2 pressDownPosition = new Vector2(0, 0);
|
|
@@ -39,6 +33,8 @@ public class SoundGameController : MonoBehaviour
|
|
|
{
|
|
|
string soundTrackString = soundTrackJson.text;
|
|
|
soundTrackManager.ImportFromJson(soundTrackString);
|
|
|
+ soundTrackManager.GenRandomActions();
|
|
|
+ // soundTrackManager.speed = 4;
|
|
|
}
|
|
|
notePrefabSwipe = Resources.Load<GameObject>("WalkDogs/Note/NoteSwipe");
|
|
|
notePrefabTap = Resources.Load<GameObject>("WalkDogs/Note/NoteTap");
|
|
@@ -55,7 +51,7 @@ public class SoundGameController : MonoBehaviour
|
|
|
IEnumerator PlaySoundGame()
|
|
|
{
|
|
|
// 加载音乐
|
|
|
- AudioClip audioClip = Resources.Load<AudioClip>(soundTrackManager.resource);
|
|
|
+ AudioClip audioClip = Resources.Load<AudioClip>(soundTrackManager.soundTrack);
|
|
|
AudioSource audioSource = gameObject.AddComponent<AudioSource>();
|
|
|
audioSource.clip = audioClip;
|
|
|
audioSource.Play();
|
|
@@ -83,26 +79,36 @@ public class SoundGameController : MonoBehaviour
|
|
|
if (note.isActive && !note.isTapped && Time.time > TapTimeDeadline)
|
|
|
{
|
|
|
note.isTapped = true;
|
|
|
- MissCount++;
|
|
|
- Debug.Log("Miss!" + Time.time + " Tap time deadline: " + TapTimeDeadline + " total miss:" + MissCount);
|
|
|
+ missCount++;
|
|
|
+ NGCombo++;
|
|
|
+ Debug.Log("Miss!" + Time.time + " Tap time deadline: " + TapTimeDeadline + " total miss:" + missCount);
|
|
|
Debug.Log("index of note:" + soundTrackManager.soundAction.IndexOf(note));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 检测游戏是否结束并统计分数
|
|
|
- totalCount = PerfectCount + GoodCount + PoorCount + MissCount;
|
|
|
+ totalCount = perfectCount + goodCount + poorCount + missCount;
|
|
|
if (totalCount == soundTrackManager.soundAction.Count)
|
|
|
{
|
|
|
GameEndTime = Time.time;
|
|
|
Debug.Log("Game Over!");
|
|
|
- Debug.Log($"Perfect: {PerfectCount}, Good: {GoodCount}, Poor: {PoorCount}, Miss: {MissCount}");
|
|
|
+ Debug.Log($"Perfect: {perfectCount}, Good: {goodCount}, Poor: {poorCount}, Miss: {missCount}");
|
|
|
Debug.Log($"Total Count: {totalCount}");
|
|
|
Debug.Log($"Score: {score}");
|
|
|
Debug.Log($"Combo: {combo}");
|
|
|
+ Debug.Log($"Max Combo: {maxCombo}");
|
|
|
// 结束游戏
|
|
|
break; // 跳出 while 循环
|
|
|
}
|
|
|
+
|
|
|
+ // 当NGCombo大于5时,播放音效提示
|
|
|
+ if (NGCombo > 5)
|
|
|
+ {
|
|
|
+ SoundGameEffectController.Instance.PlaySoundEffect(0);
|
|
|
+ NGCombo = 0;
|
|
|
+ }
|
|
|
+
|
|
|
yield return new WaitForSeconds(0.01f);
|
|
|
}
|
|
|
yield return null;
|
|
@@ -119,7 +125,7 @@ public class SoundGameController : MonoBehaviour
|
|
|
{
|
|
|
note = Instantiate(notePrefabSwipe);
|
|
|
}
|
|
|
- note.gameObject.name = noteName;
|
|
|
+ note.gameObject.name = "note_" + noteName;
|
|
|
NoteController noteController = note.GetComponent<NoteController>();
|
|
|
noteController.speed = soundTrackManager.speed;
|
|
|
noteController.hitTime = hitTime;
|
|
@@ -206,8 +212,13 @@ public class SoundGameController : MonoBehaviour
|
|
|
{
|
|
|
score += 100;
|
|
|
combo++;
|
|
|
- PerfectCount++;
|
|
|
- Debug.Log("Perfect!" + Time.time + " total perfect:" + PerfectCount);
|
|
|
+ if (combo > maxCombo)
|
|
|
+ {
|
|
|
+ maxCombo = combo;
|
|
|
+ }
|
|
|
+ perfectCount++;
|
|
|
+ NGCombo = 0;
|
|
|
+ Debug.Log("Perfect!" + Time.time + " total perfect:" + perfectCount);
|
|
|
string noteName = soundTrackManager.soundAction.IndexOf(note).ToString();
|
|
|
DestroyNote(noteName);
|
|
|
}
|
|
@@ -215,8 +226,9 @@ public class SoundGameController : MonoBehaviour
|
|
|
{
|
|
|
score += 30;
|
|
|
combo = 0;
|
|
|
- GoodCount++;
|
|
|
- Debug.Log("Good!" + Time.time + " total good:" + GoodCount);
|
|
|
+ goodCount++;
|
|
|
+ NGCombo = 0;
|
|
|
+ Debug.Log("Good!" + Time.time + " total good:" + goodCount);
|
|
|
string noteName = soundTrackManager.soundAction.IndexOf(note).ToString();
|
|
|
DestroyNote(noteName);
|
|
|
}
|
|
@@ -224,15 +236,17 @@ public class SoundGameController : MonoBehaviour
|
|
|
{
|
|
|
score += 10;
|
|
|
combo = 0;
|
|
|
- PoorCount++;
|
|
|
- Debug.Log("Poor!" + Time.time + " total poor:" + PoorCount);
|
|
|
+ poorCount++;
|
|
|
+ NGCombo++;
|
|
|
+ Debug.Log("Poor!" + Time.time + " total poor:" + poorCount);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
combo = 0;
|
|
|
- MissCount++;
|
|
|
- Debug.Log("Wrong!" + Time.time + " total miss:" + MissCount);
|
|
|
+ missCount++;
|
|
|
+ NGCombo++;
|
|
|
+ Debug.Log("Wrong!" + Time.time + " total miss:" + missCount);
|
|
|
}
|
|
|
Debug.Log("index of note:" + soundTrackManager.soundAction.IndexOf(note));
|
|
|
break;
|
|
@@ -243,7 +257,7 @@ public class SoundGameController : MonoBehaviour
|
|
|
|
|
|
private void DestroyNote(string noteName)
|
|
|
{
|
|
|
- GameObject note = GameObject.Find(noteName);
|
|
|
+ GameObject note = GameObject.Find("note_" + noteName);
|
|
|
if (note != null)
|
|
|
{
|
|
|
Destroy(note);
|