-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameManager.cs
More file actions
54 lines (47 loc) · 1.66 KB
/
GameManager.cs
File metadata and controls
54 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
public GameObject AimCube;
public MuseDataHandler MuseData;
public Transform[] GuitarStrings;
public Material AimCubeSelected;
public Material AimCubeUnSelected;
public ScoreManager scoreManager;
public AudioSource audioSource;
private int CurrentString;
private float AimCubeSize = 0;
// Use this for initialization
void Start () {
CurrentString = 0;
audioSource = this.GetComponent<AudioSource>();
AimCube.transform.position = GuitarStrings[CurrentString].position;
InvokeRepeating("OutputTime", 1f, 0.2f); //1s delay, repeat every 1s
audioSource.PlayDelayed(4.55f);
}
void OutputTime()
{
if (MuseData.GetEEGData_blink() == 1 && MuseData.GetEEGData_jaw() == 0)
{
CurrentString = (CurrentString + 1) % 4;
AimCube.transform.position = GuitarStrings[CurrentString].position;
}
if (MuseData.GetEEGData_jaw() == 1)
{
AimCube.GetComponent<Renderer>().material = AimCubeSelected;
Debug.Log("Taking a shot");
scoreManager.Shoot(CurrentString);
//Debug.Log("Selected");
}
if (MuseData.GetEEGData_jaw() == 0)
{
AimCube.GetComponent<Renderer>().material = AimCubeUnSelected;
//Debug.Log("Unselected");
}
}
// Update is called once per frame
void Update () {
AimCubeSize = MuseData.GetEEGData_gamma();
AimCube.transform.localScale = new Vector3(AimCubeSize, AimCubeSize, 0.002f);
}
}