From d649d1534e31269071ca8a57cdaf7bbd49183aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=84=EC=9D=B8=EC=9E=AC?= Date: Sun, 31 May 2020 16:46:31 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=90=EC=A0=95=20=EB=B0=8F=20=EC=86=8D?= =?UTF-8?q?=EB=8F=84=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + RhythmGame/Assets/Scenes/GameScene.unity | 5 +++-- RhythmGame/Assets/Script/GameManager.cs | 2 +- RhythmGame/Assets/Script/Key.cs | 5 ++++- RhythmGame/Assets/Script/Note.cs | 9 ++++++--- RhythmGame/Assets/Script/NoteManager.cs | 15 +++++++++++++-- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 3275e11..e7e6ea3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ RhythmGame/.vs/ *.csproj *.sln RhythmGame/obj/ +RhythmGame/Temp/ diff --git a/RhythmGame/Assets/Scenes/GameScene.unity b/RhythmGame/Assets/Scenes/GameScene.unity index 24b99e3..497d2a8 100644 --- a/RhythmGame/Assets/Scenes/GameScene.unity +++ b/RhythmGame/Assets/Scenes/GameScene.unity @@ -949,7 +949,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -131.68996, y: -273.5} + m_AnchoredPosition: {x: -183.5, y: -273.5} m_SizeDelta: {x: 51.81, y: 29.09} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &797820704 @@ -1113,7 +1113,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -183.49995, y: -273.5} + m_AnchoredPosition: {x: -131.69, y: -273.5} m_SizeDelta: {x: 51.81, y: 29.09} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &838006373 @@ -1733,6 +1733,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6783b20efc7935048a74046f12c86a71, type: 3} m_Name: m_EditorClassIdentifier: + noteSpeedTimeRatio: 3.5 noteParent: {fileID: 240215890} notePrefab: {fileID: 6996883081265278090, guid: d51cefa488feb7a47bbf6001461f6980, type: 3} diff --git a/RhythmGame/Assets/Script/GameManager.cs b/RhythmGame/Assets/Script/GameManager.cs index 2d46ded..bb0e57f 100644 --- a/RhythmGame/Assets/Script/GameManager.cs +++ b/RhythmGame/Assets/Script/GameManager.cs @@ -95,7 +95,7 @@ private void Update() for(int i = currentSong.noteDatas.Count - 1; i >= 0; i--) { var item = currentSong.noteDatas[i]; - if (Mathf.Abs((float)(item.time - videoPlayer.time)) < 0.05f) + if (Mathf.Abs((float)((item.time - (NoteManager.NOTE_START_POSITION / (NoteManager.NOTE_DEFAULT_SPEED * NoteManager.Instance.noteSpeedTimeRatio))) - videoPlayer.time)) < 0.05f) { NoteManager.Instance.MakeNote(item.keyCode); currentSong.noteDatas.RemoveAt(i); diff --git a/RhythmGame/Assets/Script/Key.cs b/RhythmGame/Assets/Script/Key.cs index 3d915da..7471cdd 100644 --- a/RhythmGame/Assets/Script/Key.cs +++ b/RhythmGame/Assets/Script/Key.cs @@ -18,12 +18,15 @@ void Update() if(Input.GetKeyDown(keyCode)) // 누른 시점 { NoteManager.Notes.RemoveAll(t => t == null); - foreach (var note in NoteManager.Notes.Where(t => t.keyCode == keyCode)) + foreach (var note in NoteManager.Notes.Where(t => t.keyCode == keyCode) + .OrderBy(t => Mathf.Abs(this.transform.position.y - t.transform.position.y))) { var dif = Mathf.Abs(this.transform.position.y - note.transform.position.y); if (dif > 50f) continue; + note.Hit(dif); + break; } } diff --git a/RhythmGame/Assets/Script/Note.cs b/RhythmGame/Assets/Script/Note.cs index 9611df6..f72cbf1 100644 --- a/RhythmGame/Assets/Script/Note.cs +++ b/RhythmGame/Assets/Script/Note.cs @@ -15,10 +15,10 @@ public void Init(KeyCode _keyCode, float _speed = 300f) public void Hit(float dif) { - if (dif > 50f) + if (dif > NoteManager.NOTE_MISS_TUNEL * NoteManager.Instance.noteSpeedTimeRatio) return; - if(dif > 30f) // 30.1f ~ 50 사이는 미스 + if(dif > NoteManager.NOTE_PERFECT_TUNEL * NoteManager.Instance.noteSpeedTimeRatio) // 30.1f ~ 50 사이는 미스 { GameManager.Instance.missCount++; } @@ -39,7 +39,10 @@ void Update() { transform.Translate(Vector3.down * speed * Time.deltaTime); - if(transform.position.y < -320) + if (transform.position.y < -320) + { + GameManager.Instance.missCount++; Remove(); + } } } diff --git a/RhythmGame/Assets/Script/NoteManager.cs b/RhythmGame/Assets/Script/NoteManager.cs index 10ce08a..b769e7f 100644 --- a/RhythmGame/Assets/Script/NoteManager.cs +++ b/RhythmGame/Assets/Script/NoteManager.cs @@ -18,9 +18,20 @@ public static NoteManager Instance private static NoteManager _instance; #endregion + + public const float NOTE_START_POSITION = 800f; + public const float NOTE_DEFAULT_SPEED = 300f; + public const float NOTE_PERFECT_TUNEL = 50f; + public const float NOTE_MISS_TUNEL = 30f; + + + public static List Notes = new List(); public static List Keys = new List(); + + public float noteSpeedTimeRatio = 1f; + public Transform noteParent; public Note notePrefab; @@ -35,10 +46,10 @@ public void MakeNote(KeyCode _keyCode) } var obj = Instantiate(notePrefab.gameObject, noteParent); - obj.transform.position = target.transform.position + Vector3.up * 800f; + obj.transform.position = target.transform.position + Vector3.up * NOTE_START_POSITION; obj.transform.localScale = target.transform.localScale; var script = obj.GetComponent(); - script.Init(_keyCode); + script.Init(_keyCode, NOTE_DEFAULT_SPEED * noteSpeedTimeRatio); Notes.Add(script); } }