Commit d86db40e authored by mmaluschnig's avatar 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
......@@ -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
......
......@@ -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);
}
}
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment