Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
ButtonPusher
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
Button Pusher
ButtonPusher
Commits
ea1802aa
Commit
ea1802aa
authored
7 years ago
by
16이상민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
3958d258
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
39 deletions
+40
-39
Judge.cs
Assets/Script/Judge.cs
+7
-16
JudgeManager.cs
Assets/Script/JudgeManager.cs
+33
-23
No files found.
Assets/Script/Judge.cs
View file @
ea1802aa
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
UnityEngine
;
...
...
@@ -14,16 +12,15 @@ public class Judge
new
Judge
(
"MISS"
)
{
Color
=
Color
.
red
,
IsBreak
=
true
}
};
private
Judge
()
internal
Judge
()
{
ButtonTimingRange
=
0f
;
ButtonTimingRange
=
0f
;
Score
=
0
;
IsBreak
=
false
;
Color
=
Color
.
black
;
}
private
Judge
(
string
name
)
:
this
()
{
Name
=
name
;
}
internal
Judge
(
string
name
)
:
this
()
{
Name
=
name
;
}
public
string
Name
{
get
;
private
set
;
}
...
...
@@ -39,20 +36,14 @@ public class Judge
public
static
Judge
TestJudge
(
Note
note
,
float
elapsedTime
,
bool
end
=
false
,
bool
test
=
false
)
{
float
timing
=
end
?
note
.
EndTiming
:
note
.
StartTiming
;
float
difference
=
Mathf
.
Abs
(
elapsedTime
-
timing
)
;
float
difference
=
elapsedTime
-
timing
;
if
(
test
)
Debug
.
Log
(
elapsedTime
-
timing
);
Debug
.
Log
(
difference
);
foreach
(
Judge
judge
in
JudgeList
)
{
if
(
difference
<
judge
.
ButtonTimingRange
)
{
return
judge
;
}
}
var
result
=
JudgeList
.
Where
(
x
=>
Mathf
.
Abs
(
difference
)
<
x
.
ButtonTimingRange
).
ToList
();
return
JudgeList
.
Last
()
;
return
result
.
Count
==
0
?
JudgeList
.
Last
()
:
result
[
0
]
;
}
public
static
bool
IsNonEmptyMiss
(
Note
note
,
float
elapsedTime
,
bool
end
=
false
)
...
...
This diff is collapsed.
Click to expand it.
Assets/Script/JudgeManager.cs
View file @
ea1802aa
...
...
@@ -95,7 +95,7 @@ public class JudgeManager : MonoBehaviour
judgeText
.
SetActive
(
false
);
MotionGuageReset
();
LoadNotes
(
GameManager
.
Instance
.
CurrentTrack
.
Notes
);
LoadNotes
();
Instantiate
(
GameManager
.
Instance
.
defaultSound
);
}
...
...
@@ -271,8 +271,10 @@ public class JudgeManager : MonoBehaviour
judgeText
.
GetComponent
<
Text
>().
color
=
judge
.
Color
;
}
private
void
LoadNotes
(
List
<
Note
>
notes
)
private
void
LoadNotes
()
{
var
notes
=
GameManager
.
Instance
.
CurrentTrack
.
Notes
;
foreach
(
Note
note
in
notes
)
{
GameObject
obj
=
Instantiate
(
...
...
@@ -280,35 +282,43 @@ public class JudgeManager : MonoBehaviour
noteobj
.
transform
)
as
GameObject
;
if
(
note
is
MotionNote
&&
!
note
.
IsLong
)
obj
.
transform
.
SetParent
(
smobj
.
transform
);
else
if
(
note
is
MotionNote
&&
note
.
IsLong
)
obj
.
transform
.
SetParent
(
lmobj
.
transform
);
else
if
(
note
.
Type
==
NoteType
.
MeasureLine
||
note
.
Type
==
NoteType
.
BeatLine
)
obj
.
transform
.
SetParent
(
offset
.
transform
);
SetNoteParent
(
note
,
obj
);
if
(
note
.
IsLong
)
{
float
length
=
note
.
Length
*
ScrollSpeed
;
StretchLongNote
(
note
,
obj
);
var
holdTransform
=
obj
.
transform
.
GetChild
(
1
)
.
GetComponent
<
RectTransform
>();
var
endTransform
=
obj
.
transform
.
GetChild
(
2
)
.
GetComponent
<
RectTransform
>();
holdTransform
.
SetSizeWithCurrentAnchors
(
RectTransform
.
Axis
.
Horizontal
,
length
);
holdTransform
.
position
+=
new
Vector3
(
length
/
2
,
0
,
0
);
endTransform
.
position
+=
new
Vector3
(
length
,
0
,
0
);
}
obj
.
transform
.
position
+=
initialPos
+
new
Vector3
(
note
.
StartTiming
*
ScrollSpeed
,
0
,
0
);
obj
.
transform
.
position
+=
initialPos
+
(
Vector3
.
right
*
(
note
.
StartTiming
*
ScrollSpeed
));
obj
.
AddComponent
<
Note
.
Controller
>().
Instance
=
note
;
}
}
void
SetNoteParent
(
Note
note
,
GameObject
obj
)
{
if
(
note
is
MotionNote
&&
!
note
.
IsLong
)
obj
.
transform
.
SetParent
(
smobj
.
transform
);
else
if
(
note
is
MotionNote
&&
note
.
IsLong
)
obj
.
transform
.
SetParent
(
lmobj
.
transform
);
else
if
(
note
.
Type
==
NoteType
.
MeasureLine
||
note
.
Type
==
NoteType
.
BeatLine
)
obj
.
transform
.
SetParent
(
offset
.
transform
);
}
void
StretchLongNote
(
Note
note
,
GameObject
obj
)
{
float
length
=
note
.
Length
*
ScrollSpeed
;
var
holdTransform
=
obj
.
transform
.
GetChild
(
1
)
.
GetComponent
<
RectTransform
>();
var
endTransform
=
obj
.
transform
.
GetChild
(
2
)
.
GetComponent
<
RectTransform
>();
holdTransform
.
SetSizeWithCurrentAnchors
(
RectTransform
.
Axis
.
Horizontal
,
length
);
holdTransform
.
position
+=
new
Vector3
(
length
/
2
,
0
,
0
);
endTransform
.
position
+=
new
Vector3
(
length
,
0
,
0
);
}
private
bool
onResult
=
false
;
private
void
ShowResult
()
...
...
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