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
Nov 13, 2019
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:
m_EditorClassIdentifier
:
ringUIPrefab
:
{
fileID
:
8100479809720507869
,
guid
:
13fc3a8405d796e4e87e099e870cc446
,
type
:
3
}
hitEffectPrefabs
:
[]
scoreText
:
{
fileID
:
0
}
comboText
:
{
fileID
:
0
}
---
!u!4
&571765379
stripped
Transform
:
m_CorrespondingSourceObject
:
{
fileID
:
447954
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
...
...
@@ -478,6 +479,17 @@ MonoBehaviour:
-
{
fileID
:
4640709078173886797
,
guid
:
578b592ddecefcb40961f3c98b2c3df7
,
type
:
3
}
-
{
fileID
:
4734231541000158426
,
guid
:
416e07754d262cc4d87d8a3525a57b3f
,
type
:
3
}
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
Transform
:
m_ObjectHideFlags
:
0
...
...
@@ -734,6 +746,11 @@ PrefabInstance:
propertyPath
:
m_LocalEulerAnglesHint.z
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
114000011957598740
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
type
:
3
}
propertyPath
:
inputSource
value
:
2
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
dc06161b6d97feb419f45f03b62e14b9
,
type
:
3
}
---
!u!1
&2112533737
stripped
...
...
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
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:
RhythmKata/Assets/Scripts/Core/Level.cs
View file @
f79dc081
...
...
@@ -11,12 +11,39 @@ class Level
notes
.
Enqueue
(
note
);
}
public
void
HandleInput
(
double
time
)
public
void
HandleInput
(
PlayerInput
input
)
{
foreach
(
var
note
in
notes
)
{
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
);
}
}
}
...
...
RhythmKata/Assets/Scripts/Core/Note.cs
View file @
f79dc081
...
...
@@ -26,7 +26,52 @@ abstract class Note
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
private
static
readonly
float
NOTE_SHOW_TIMING
=
5
;
...
...
@@ -65,26 +110,18 @@ abstract class Note
note
=
new
ForwardNote
();
handType
=
HandType
.
Right
;
break
;
case
"13"
:
// 1p third lane:
REAR
LEFT HAND
case
"13"
:
// 1p third lane:
EDGE
LEFT HAND
note
=
new
EdgeNote
();
handType
=
HandType
.
Left
;
break
;
case
"14"
:
// 1p forth lane:
REAR
RIGHT HAND
case
"14"
:
// 1p forth lane:
EDGE
RIGHT HAND
note
=
new
EdgeNote
();
handType
=
HandType
.
Right
;
break
;
//case "15": // 1p fifth lane: EDGE LEFT HAND
// handType = HandType.Left;
// break;
//case "16": // 1p sixth lane: EDGE RIGHT HAND
// handType = HandType.Right;
// break;
// add action notes
// TODO : add action notes
default
:
return
null
;
...
...
@@ -135,15 +172,7 @@ class ForwardNote : Note
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
...
...
@@ -157,11 +186,6 @@ class RearNote : Note
{
throw
new
NotImplementedException
();
}
public
override
void
Judge
(
double
time
)
{
}
}
class
EdgeNote
:
Note
...
...
@@ -198,11 +222,6 @@ class EdgeNote : Note
{
return
1
;
}
public
override
void
Judge
(
double
time
)
{
}
}
public
enum
NoteType
...
...
RhythmKata/Assets/Scripts/EdgeNoteObject.cs
View file @
f79dc081
...
...
@@ -22,7 +22,7 @@ public class EdgeNoteObject : NoteObject
}
}
public
override
void
NoteHit
(
NoteHitType
type
)
public
override
void
NoteHit
(
JudgeResult
type
)
{
}
...
...
RhythmKata/Assets/Scripts/ForwardNoteObject.cs
View file @
f79dc081
...
...
@@ -66,7 +66,7 @@ public class ForwardNoteObject : NoteObject
Destroy
(
ring
.
gameObject
);
}
public
override
void
NoteHit
(
NoteHitType
type
)
public
override
void
NoteHit
(
JudgeResult
type
)
{
base
.
NoteHit
(
type
);
}
...
...
RhythmKata/Assets/Scripts/GameManager.cs
View file @
f79dc081
...
...
@@ -27,7 +27,7 @@ public class GameManager : MonoBehaviour
}
private
void
UpdateScore
(
NoteHitType
type
,
int
score
)
private
void
UpdateScore
(
JudgeResult
type
,
int
score
)
{
Score
+=
score
;
}
...
...
RhythmKata/Assets/Scripts/IngameUIManager.cs
View file @
f79dc081
...
...
@@ -14,7 +14,7 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
{
NoteObject
.
OnNoteHit
+=
OnNoteHit
;
}
public
void
OnNoteHit
(
NoteHitType
type
)
public
void
OnNoteHit
(
JudgeResult
type
)
{
}
...
...
RhythmKata/Assets/Scripts/NoteObject.cs
View file @
f79dc081
...
...
@@ -4,18 +4,10 @@ using System.Collections.Generic;
using
UnityEngine
;
using
UnityEngine.UI
;
public
enum
NoteHitType
{
PERFECT
,
PERFECT_OTHER_HAND
,
HIT
,
HIT_OTHER_HAND
,
MISS
}
public
abstract
class
NoteObject
:
MonoBehaviour
{
public
static
Action
<
NoteHitType
>
OnNoteHit
;
public
static
Action
<
JudgeResult
>
OnNoteHit
;
protected
float
remainedTime
;
public
Vector3
startPoint
{
get
{
return
endPoint
+
new
Vector3
(
0
,
0
,
50
);
}
}
...
...
@@ -34,10 +26,10 @@ public abstract class NoteObject : MonoBehaviour
remainedTime
=
maxRemainedTime
;
}
public
virtual
void
NoteHit
(
NoteHitType
typ
e
)
public
virtual
void
NoteHit
(
JudgeResult
judg
e
)
{
OnNoteHit
?.
Invoke
(
typ
e
);
Instantiate
(
PlayEngine
.
inst
.
hitEffectPrefabs
[(
int
)
type
],
transform
.
position
,
Quaternion
.
identity
);
OnNoteHit
?.
Invoke
(
judg
e
);
Instantiate
(
PlayEngine
.
inst
.
hitEffectPrefabs
[(
int
)
(
judge
.
type
)
],
transform
.
position
,
Quaternion
.
identity
);
//Destroy(gameObject);
}
...
...
RhythmKata/Assets/Scripts/PlayEngine.cs
View file @
f79dc081
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
using
Valve.VR
;
using
System
;
[
RequireComponent
(
typeof
(
AudioSource
))]
public
class
PlayEngine
:
SingletonBehaviour
<
PlayEngine
>
...
...
@@ -10,7 +11,7 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public
ForwardNoteObject
ForwardNoteObject
;
public
EdgeNoteObject
[]
EdgeNoteObjects
=
new
EdgeNoteObject
[
4
];
private
double
startTime
;
private
Level
level
;
private
AudioSource
audioSource
;
...
...
@@ -28,7 +29,9 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
public
GameObject
explosion
;
public
SteamVR_Action_Boolean
fire
;
public
SteamVR_Input_Sources
inputSource
;
public
SteamVR_Input_Sources
leftHand
;
public
SteamVR_Input_Sources
rightHand
;
public
void
Start
()
{
audioSource
=
GetComponent
<
AudioSource
>();
...
...
@@ -66,15 +69,38 @@ public class PlayEngine : SingletonBehaviour<PlayEngine>
{
if
(
level
!=
null
)
{
var
time
=
AudioSettings
.
dspTime
-
startDspTime
;
level
.
UpdateNotes
(
time
);
// level.HandleInput(time);
/*
if (fire.GetStateDown(inputSource)) {
AudioSource.PlayClipAtPoint(gunSfx, Vector3.zero);
level.HandleInput(time);
var
playbackTime
=
AudioSettings
.
dspTime
-
startDspTime
;
level
.
UpdateNotes
(
playbackTime
);
PlayerInput
input
=
new
PlayerInput
();
input
.
time
=
playbackTime
;
// 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
))
...
...
@@ -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
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