Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gstuitje
RingMaster
Commits
d86db40e
Commit
d86db40e
authored
Jan 19, 2019
by
mmaluschnig
Browse files
Simon now plays notes to a 'metronome' tune (but has a chance to not play because he's a bear).
parent
5af15c0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
RingMaster/RingMaster/Assets/Scenes/SimonTheBear.unity
View file @
d86db40e
...
...
@@ -807,6 +807,9 @@ MonoBehaviour:
m_EditorClassIdentifier
:
note
:
{
fileID
:
1472882270331014
,
guid
:
926e7a0b8d8d84ab8b306dcfd69c418c
,
type
:
2
}
noteManager
:
{
fileID
:
1447931352
}
turnTime
:
8
notePlaySpeed
:
0.3
notePlayChance
:
0.3
---
!u!1
&857273187
GameObject
:
m_ObjectHideFlags
:
0
...
...
RingMaster/RingMaster/Assets/Scripts/SimonScripts/SimonGameManager.cs
View file @
d86db40e
...
...
@@ -11,16 +11,24 @@ public class SimonGameManager : MonoBehaviour {
}
public
static
void
PlayerPlayed
(
GameObject
note
){
GameObject
sNote
=
simonNotes
.
Dequeue
();
Note
simonNote
=
sNote
.
GetComponent
<
Note
>();
Note
playerNote
=
note
.
GetComponent
<
Note
>();
if
(
simonNote
.
type
==
playerNote
.
type
){
print
(
"GOOD"
);
if
(
simonNotes
.
Count
>
0
)
{
GameObject
sNote
=
simonNotes
.
Dequeue
();
Note
simonNote
=
sNote
.
GetComponent
<
Note
>();
Note
playerNote
=
note
.
GetComponent
<
Note
>();
if
(
simonNote
.
type
==
playerNote
.
type
)
{
print
(
"GOOD"
);
}
else
{
print
(
"BAD"
);
}
Destroy
(
sNote
);
}
else
{
print
(
"
BAD
"
);
print
(
"
Dont be hasty master Hobbit
"
);
}
Destroy
(
sNote
);
}
}
RingMaster/RingMaster/Assets/Scripts/SimonScripts/SimonScript.cs
View file @
d86db40e
...
...
@@ -9,31 +9,48 @@ public class SimonScript : MonoBehaviour
public
GameObject
note
;
public
NoteManager
noteManager
;
public
float
turnTime
=
8
;
bool
simonsTurn
;
float
playTime
;
float
nextNotePlay
;
public
float
notePlaySpeed
=
0.3f
;
public
float
notePlayChance
=
0.3f
;
private
string
[]
keys
=
new
string
[]
{
"Q"
,
"W"
,
"E"
,
"R"
,
"T"
,
"Y"
};
// Use this for initialization
void
Start
()
{
simonsTurn
=
true
;
nextNotePlay
=
Time
.
time
;
}
// Update is called once per frame
void
Update
()
{
if
(
Time
.
time
-
playTime
>
8
){
//simon plays for 'turnTime' seconds then waits patiently like a well trained bear
if
(
Time
.
time
-
playTime
>
turnTime
){
setSimonsturn
(
false
);
}
if
(
simonsTurn
)
{
if
((
Time
.
time
-
playTime
)
%
2
<
0.01f
)
{
//simon will attempt to play every 'notePlaySpeed' seconds
if
(
Time
.
time
>
nextNotePlay
)
{
noteManager
.
spawnSimonNote
(
keys
[
Random
.
Range
(
0
,
6
)]);
nextNotePlay
+=
notePlaySpeed
;
//however hes a bear so he screws up a lot
if
(
Random
.
Range
(
0f
,
1f
)
<
notePlayChance
)
{
playRandomNote
();
}
}
}
}
void
playRandomNote
(){
noteManager
.
spawnSimonNote
(
keys
[
Random
.
Range
(
0
,
6
)]);
}
public
void
setSimonsturn
(
bool
turn
){
simonsTurn
=
turn
;
playTime
=
Time
.
time
;
...
...
Write
Preview
Supports
Markdown
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