Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RhythmKata
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
13정준영
RhythmKata
Commits
f79dc081
Commit
f79dc081
authored
5 years ago
by
13정준영
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
judge system wip
parent
42090253
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
182 additions
and
61 deletions
+182
-61
mergescene.unity
RhythmKata/Assets/Scenes/mergescene.unity
+18
-1
Judge.cs
RhythmKata/Assets/Scripts/Core/Judge.cs
+21
-0
Judge.cs.meta
RhythmKata/Assets/Scripts/Core/Judge.cs.meta
+11
-0
Level.cs
RhythmKata/Assets/Scripts/Core/Level.cs
+29
-2
Note.cs
RhythmKata/Assets/Scripts/Core/Note.cs
+51
-32
EdgeNoteObject.cs
RhythmKata/Assets/Scripts/EdgeNoteObject.cs
+1
-1
ForwardNoteObject.cs
RhythmKata/Assets/Scripts/ForwardNoteObject.cs
+1
-1
GameManager.cs
RhythmKata/Assets/Scripts/GameManager.cs
+1
-1
IngameUIManager.cs
RhythmKata/Assets/Scripts/IngameUIManager.cs
+1
-1
NoteObject.cs
RhythmKata/Assets/Scripts/NoteObject.cs
+4
-12
PlayEngine.cs
RhythmKata/Assets/Scripts/PlayEngine.cs
+44
-10
No files found.
RhythmKata/Assets/Scenes/mergescene.unity
View file @
f79dc081
...
@@ -401,7 +401,8 @@ MonoBehaviour:
...
@@ -401,7 +401,8 @@ MonoBehaviour:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
ringUIPrefab
:
{
fileID
:
8100479809720507869
,
guid
:
13fc3a8405d796e4e87e099e870cc446
,
ringUIPrefab
:
{
fileID
:
8100479809720507869
,
guid
:
13fc3a8405d796e4e87e099e870cc446
,
type
:
3
}
type
:
3
}
hitEffectPrefabs
:
[]
scoreText
:
{
fileID
:
0
}
comboText
:
{
fileID
:
0
}
---
!u!4
&571765379
stripped
---
!u!4
&571765379
stripped
Transform
:
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
447954
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
m_CorrespondingSourceObject
:
{
fileID
:
447954
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
...
@@ -478,6 +479,17 @@ MonoBehaviour:
...
@@ -478,6 +479,17 @@ MonoBehaviour:
-
{
fileID
:
4640709078173886797
,
guid
:
578b592ddecefcb40961f3c98b2c3df7
,
type
:
3
}
-
{
fileID
:
4640709078173886797
,
guid
:
578b592ddecefcb40961f3c98b2c3df7
,
type
:
3
}
-
{
fileID
:
4734231541000158426
,
guid
:
416e07754d262cc4d87d8a3525a57b3f
,
type
:
3
}
-
{
fileID
:
4734231541000158426
,
guid
:
416e07754d262cc4d87d8a3525a57b3f
,
type
:
3
}
test
:
0
test
:
0
hitEffectPrefabs
:
-
{
fileID
:
5999576302179210679
,
guid
:
39e07a022f545624db4f9f7a8480a8d3
,
type
:
3
}
-
{
fileID
:
5740315542072016546
,
guid
:
e640eeafa4d7b8645b26c885d7eba308
,
type
:
3
}
-
{
fileID
:
5740315542072016546
,
guid
:
e640eeafa4d7b8645b26c885d7eba308
,
type
:
3
}
gunSfx
:
{
fileID
:
8300000
,
guid
:
7eb98e62c3fbe5344aa72ecad87ce5cc
,
type
:
3
}
explosion
:
{
fileID
:
0
}
fire
:
actionPath
:
needsReinit
:
0
leftHand
:
1
rightHand
:
2
---
!u!4
&1011486260
---
!u!4
&1011486260
Transform
:
Transform
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -734,6 +746,11 @@ PrefabInstance:
...
@@ -734,6 +746,11 @@ PrefabInstance:
propertyPath
:
m_LocalEulerAnglesHint.z
propertyPath
:
m_LocalEulerAnglesHint.z
value
:
0
value
:
0
objectReference
:
{
fileID
:
0
}
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
114000011957598740
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
type
:
3
}
propertyPath
:
inputSource
value
:
2
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
type
:
3
}
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
type
:
3
}
---
!u!1
&2112533737
stripped
---
!u!1
&2112533737
stripped
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/Core/Judge.cs
0 → 100644
View file @
f79dc081
public
enum
JudgeType
{
Perfect
=
100
,
Hit
=
10
,
Miss
=
0
,
Ignore
=
-
1
// the note is too far
}
public
enum
HitType
{
Hit
=
100
,
Near
=
10
,
Miss
=
0
}
public
struct
JudgeResult
{
public
JudgeType
type
;
public
bool
correctHand
;
public
bool
near
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/Core/Judge.cs.meta
0 → 100644
View file @
f79dc081
fileFormatVersion: 2
guid: f56e8b159c512ab4186397e4e523837f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/Core/Level.cs
View file @
f79dc081
...
@@ -11,12 +11,39 @@ class Level
...
@@ -11,12 +11,39 @@ class Level
notes
.
Enqueue
(
note
);
notes
.
Enqueue
(
note
);
}
}
public
void
HandleInput
(
double
time
)
public
void
HandleInput
(
PlayerInput
input
)
{
{
foreach
(
var
note
in
notes
)
foreach
(
var
note
in
notes
)
{
{
if
(
note
.
Active
)
if
(
note
.
Active
)
note
.
Judge
(
time
);
{
var
judge
=
new
JudgeResult
();
var
hit
=
note
.
CheckHit
(
input
.
ray
);
Debug
.
Log
(
input
.
ray
);
judge
.
near
=
false
;
judge
.
type
=
JudgeType
.
Ignore
;
switch
(
hit
)
{
case
HitType
.
Hit
:
judge
.
type
=
note
.
JudgeTiming
(
input
.
time
);
break
;
case
HitType
.
Near
:
if
(
note
.
JudgeTiming
(
input
.
time
)
>=
JudgeType
.
Hit
)
{
judge
.
type
=
JudgeType
.
Miss
;
}
judge
.
near
=
true
;
break
;
case
HitType
.
Miss
:
judge
.
near
=
false
;
break
;
}
note
.
HandleJudge
(
judge
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/Core/Note.cs
View file @
f79dc081
...
@@ -26,7 +26,52 @@ abstract class Note
...
@@ -26,7 +26,52 @@ abstract class Note
noteObject
=
CreateNoteObjectImpl
();
noteObject
=
CreateNoteObjectImpl
();
}
}
public
abstract
void
Judge
(
double
time
);
// override this function to implement per-note judgement.
public
virtual
JudgeType
JudgeTiming
(
double
time
)
{
double
delta
=
time
-
this
.
Time
;
var
timing
=
Math
.
Abs
(
delta
);
var
early
=
delta
<
0
;
if
(
timing
<
0.5
)
{
return
JudgeType
.
Perfect
;
}
else
if
(
timing
<
1.0
)
{
return
JudgeType
.
Hit
;
}
else
if
(
timing
<
1.5
&&
early
)
{
return
JudgeType
.
Miss
;
}
else
{
return
JudgeType
.
Ignore
;
}
}
public
virtual
HitType
CheckHit
(
Ray
ray
)
{
// add near support
if
(
noteObject
.
IsHit
(
ray
))
{
return
HitType
.
Hit
;
}
else
{
return
HitType
.
Miss
;
}
}
public
void
HandleJudge
(
JudgeResult
judge
)
{
if
(
judge
.
type
!=
JudgeType
.
Ignore
)
{
Debug
.
Log
(
System
.
Enum
.
GetName
(
typeof
(
JudgeType
),
judge
.
type
));
noteObject
.
NoteHit
(
judge
);
}
}
// TODO: Refactort this
// TODO: Refactort this
private
static
readonly
float
NOTE_SHOW_TIMING
=
5
;
private
static
readonly
float
NOTE_SHOW_TIMING
=
5
;
...
@@ -65,26 +110,18 @@ abstract class Note
...
@@ -65,26 +110,18 @@ abstract class Note
note
=
new
ForwardNote
();
note
=
new
ForwardNote
();
handType
=
HandType
.
Right
;
handType
=
HandType
.
Right
;
break
;
break
;
case
"13"
:
// 1p third lane:
REAR
LEFT HAND
case
"13"
:
// 1p third lane:
EDGE
LEFT HAND
note
=
new
EdgeNote
();
note
=
new
EdgeNote
();
handType
=
HandType
.
Left
;
handType
=
HandType
.
Left
;
break
;
break
;
case
"14"
:
// 1p forth lane:
REAR
RIGHT HAND
case
"14"
:
// 1p forth lane:
EDGE
RIGHT HAND
note
=
new
EdgeNote
();
note
=
new
EdgeNote
();
handType
=
HandType
.
Right
;
handType
=
HandType
.
Right
;
break
;
break
;
//case "15": // 1p fifth lane: EDGE LEFT HAND
// handType = HandType.Left;
// TODO : add action notes
// break;
//case "16": // 1p sixth lane: EDGE RIGHT HAND
// handType = HandType.Right;
// break;
// add action notes
default
:
default
:
return
null
;
return
null
;
...
@@ -135,15 +172,7 @@ class ForwardNote : Note
...
@@ -135,15 +172,7 @@ class ForwardNote : Note
throw
new
ArgumentException
(
"wrong data"
);
throw
new
ArgumentException
(
"wrong data"
);
}
}
public
override
void
Judge
(
double
time
)
{
if
(
Math
.
Abs
(
time
-
this
.
Time
)
<
0.5
)
{
noteObject
.
NoteHit
(
NoteHitType
.
PERFECT
);
//var obj = MonoBehaviour.Instantiate(PlayEngine.inst.explosion);
//obj.transform.position = noteObject.transform.position;
}
}
}
}
class
RearNote
:
Note
class
RearNote
:
Note
...
@@ -157,11 +186,6 @@ class RearNote : Note
...
@@ -157,11 +186,6 @@ class RearNote : Note
{
{
throw
new
NotImplementedException
();
throw
new
NotImplementedException
();
}
}
public
override
void
Judge
(
double
time
)
{
}
}
}
class
EdgeNote
:
Note
class
EdgeNote
:
Note
...
@@ -198,11 +222,6 @@ class EdgeNote : Note
...
@@ -198,11 +222,6 @@ class EdgeNote : Note
{
{
return
1
;
return
1
;
}
}
public
override
void
Judge
(
double
time
)
{
}
}
}
public
enum
NoteType
public
enum
NoteType
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/EdgeNoteObject.cs
View file @
f79dc081
...
@@ -22,7 +22,7 @@ public class EdgeNoteObject : NoteObject
...
@@ -22,7 +22,7 @@ public class EdgeNoteObject : NoteObject
}
}
}
}
public
override
void
NoteHit
(
NoteHitType
type
)
public
override
void
NoteHit
(
JudgeResult
type
)
{
{
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/ForwardNoteObject.cs
View file @
f79dc081
...
@@ -66,7 +66,7 @@ public class ForwardNoteObject : NoteObject
...
@@ -66,7 +66,7 @@ public class ForwardNoteObject : NoteObject
Destroy
(
ring
.
gameObject
);
Destroy
(
ring
.
gameObject
);
}
}
public
override
void
NoteHit
(
NoteHitType
type
)
public
override
void
NoteHit
(
JudgeResult
type
)
{
{
base
.
NoteHit
(
type
);
base
.
NoteHit
(
type
);
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/GameManager.cs
View file @
f79dc081
...
@@ -27,7 +27,7 @@ public class GameManager : MonoBehaviour
...
@@ -27,7 +27,7 @@ public class GameManager : MonoBehaviour
}
}
private
void
UpdateScore
(
NoteHitType
type
,
int
score
)
private
void
UpdateScore
(
JudgeResult
type
,
int
score
)
{
{
Score
+=
score
;
Score
+=
score
;
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/IngameUIManager.cs
View file @
f79dc081
...
@@ -14,7 +14,7 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
...
@@ -14,7 +14,7 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
{
{
NoteObject
.
OnNoteHit
+=
OnNoteHit
;
NoteObject
.
OnNoteHit
+=
OnNoteHit
;
}
}
public
void
OnNoteHit
(
NoteHitType
type
)
public
void
OnNoteHit
(
JudgeResult
type
)
{
{
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/NoteObject.cs
View file @
f79dc081
...
@@ -4,18 +4,10 @@ using System.Collections.Generic;
...
@@ -4,18 +4,10 @@ using System.Collections.Generic;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.UI
;
using
UnityEngine.UI
;
public
enum
NoteHitType
{
PERFECT
,
PERFECT_OTHER_HAND
,
HIT
,
HIT_OTHER_HAND
,
MISS
}
public
abstract
class
NoteObject
:
MonoBehaviour
public
abstract
class
NoteObject
:
MonoBehaviour
{
{
public
static
Action
<
NoteHitType
>
OnNoteHit
;
public
static
Action
<
JudgeResult
>
OnNoteHit
;
protected
float
remainedTime
;
protected
float
remainedTime
;
public
Vector3
startPoint
{
get
{
return
endPoint
+
new
Vector3
(
0
,
0
,
50
);
}
}
public
Vector3
startPoint
{
get
{
return
endPoint
+
new
Vector3
(
0
,
0
,
50
);
}
}
...
@@ -34,10 +26,10 @@ public abstract class NoteObject : MonoBehaviour
...
@@ -34,10 +26,10 @@ public abstract class NoteObject : MonoBehaviour
remainedTime
=
maxRemainedTime
;
remainedTime
=
maxRemainedTime
;
}
}
public
virtual
void
NoteHit
(
NoteHitType
typ
e
)
public
virtual
void
NoteHit
(
JudgeResult
judg
e
)
{
{
OnNoteHit
?.
Invoke
(
typ
e
);
OnNoteHit
?.
Invoke
(
judg
e
);
Instantiate
(
PlayEngine
.
inst
.
hitEffectPrefabs
[(
int
)
type
],
transform
.
position
,
Quaternion
.
identity
);
Instantiate
(
PlayEngine
.
inst
.
hitEffectPrefabs
[(
int
)
(
judge
.
type
)
],
transform
.
position
,
Quaternion
.
identity
);
//Destroy(gameObject);
//Destroy(gameObject);
}
}
...
...
This diff is collapsed.
Click to expand it.
RhythmKata/Assets/Scripts/PlayEngine.cs
View file @
f79dc081
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
Valve.VR
;
using
Valve.VR
;
using
System
;
[
RequireComponent
(
typeof
(
AudioSource
))]
[
RequireComponent
(
typeof
(
AudioSource
))]
public
class
PlayEngine
:
SingletonBehaviour
<
PlayEngine
>
public
class
PlayEngine
:
SingletonBehaviour
<
PlayEngine
>
...
@@ -10,7 +11,7 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
...
@@ -10,7 +11,7 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public
ForwardNoteObject
ForwardNoteObject
;
public
ForwardNoteObject
ForwardNoteObject
;
public
EdgeNoteObject
[]
EdgeNoteObjects
=
new
EdgeNoteObject
[
4
];
public
EdgeNoteObject
[]
EdgeNoteObjects
=
new
EdgeNoteObject
[
4
];
private
double
startTime
;
private
double
startTime
;
private
Level
level
;
private
Level
level
;
private
AudioSource
audioSource
;
private
AudioSource
audioSource
;
...
@@ -28,7 +29,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
...
@@ -28,7 +29,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public
GameObject
explosion
;
public
GameObject
explosion
;
public
SteamVR_Action_Boolean
fire
;
public
SteamVR_Action_Boolean
fire
;
public
SteamVR_Input_Sources
inputSource
;
public
SteamVR_Input_Sources
leftHand
;
public
SteamVR_Input_Sources
rightHand
;
public
void
Start
()
public
void
Start
()
{
{
audioSource
=
GetComponent
<
AudioSource
>();
audioSource
=
GetComponent
<
AudioSource
>();
...
@@ -66,15 +69,38 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
...
@@ -66,15 +69,38 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
{
{
if
(
level
!=
null
)
if
(
level
!=
null
)
{
{
var
time
=
AudioSettings
.
dspTime
-
startDspTime
;
var
playbackTime
=
AudioSettings
.
dspTime
-
startDspTime
;
level
.
UpdateNotes
(
time
);
level
.
UpdateNotes
(
playbackTime
);
// level.HandleInput(time);
/*
PlayerInput
input
=
new
PlayerInput
();
if (fire.GetStateDown(inputSource)) {
input
.
time
=
playbackTime
;
AudioSource.PlayClipAtPoint(gunSfx, Vector3.zero);
level.HandleInput(time);
// FIXME: fire.GetStateDown causes error
try
// when no VR device is available, SteamVR causes an error.
{
if
(
Input
.
GetMouseButtonDown
(
0
)
||
fire
.
GetStateDown
(
leftHand
))
{
AudioSource
.
PlayClipAtPoint
(
gunSfx
,
Vector3
.
zero
);
input
.
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
Debug
.
DrawRay
(
input
.
ray
.
origin
,
input
.
ray
.
direction
*
10
,
Color
.
yellow
);
input
.
hand
=
HandType
.
Left
;
level
.
HandleInput
(
input
);
}
if
(
Input
.
GetMouseButtonDown
(
1
)
||
fire
.
GetStateDown
(
rightHand
))
{
AudioSource
.
PlayClipAtPoint
(
gunSfx
,
Vector3
.
zero
);
input
.
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
input
.
hand
=
HandType
.
Right
;
level
.
HandleInput
(
input
);
}
}
catch
(
NullReferenceException
e
)
{
if
(
e
.
Source
!=
"SteamVR"
)
// ignore SteamVR, rethrow otherwise
{
throw
e
;
}
}
}
*/
}
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
LeftArrow
))
if
(
Input
.
GetKeyDown
(
KeyCode
.
LeftArrow
))
...
@@ -90,3 +116,11 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
...
@@ -90,3 +116,11 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
}
}
}
}
}
}
public
class
PlayerInput
{
// TODO: make'em properties
public
Ray
ray
;
public
HandType
hand
;
public
double
time
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment