Skip to content

Commit

Permalink
판정 및 속도 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
zmonteiro committed May 31, 2020
1 parent 946d6fb commit d649d15
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ RhythmGame/.vs/
*.csproj
*.sln
RhythmGame/obj/
RhythmGame/Temp/
5 changes: 3 additions & 2 deletions RhythmGame/Assets/Scenes/GameScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion RhythmGame/Assets/Script/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion RhythmGame/Assets/Script/Key.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
9 changes: 6 additions & 3 deletions RhythmGame/Assets/Script/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand All @@ -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();
}
}
}
15 changes: 13 additions & 2 deletions RhythmGame/Assets/Script/NoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Note> Notes = new List<Note>();
public static List<Key> Keys = new List<Key>();


public float noteSpeedTimeRatio = 1f;

public Transform noteParent;
public Note notePrefab;

Expand All @@ -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<Note>();
script.Init(_keyCode);
script.Init(_keyCode, NOTE_DEFAULT_SPEED * noteSpeedTimeRatio);
Notes.Add(script);
}
}

0 comments on commit d649d15

Please sign in to comment.