Commit 57d3c6af authored by gstuitje's avatar gstuitje
Browse files

Now you can select a song.

parent a4b45621
<Properties StartupConfiguration="{67A4F128-F6AC-CD88-DA35-F29416A0792A}|">
<MonoDevelop.Ide.ItemProperties.Assembly-CSharp PreferredExecutionTarget="Unity.Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/MimeScripts/SpawnKeys.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/MimeScripts/SongSelect.cs">
<Files>
<File FileName="Assets/Scripts/DaytimeScripts/DaytimeManager.cs" Line="1" Column="1" />
<File FileName="Assets/Scripts/MimeScripts/SpawnKeys.cs" Line="153" Column="18" />
<File FileName="Assets/Scripts/MimeScripts/SpawnKeys.cs" Line="92" Column="29" />
<File FileName="Assets/Scripts/MimeScripts/SongSelect.cs" Line="14" Column="9" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
......
......@@ -26,4 +26,16 @@ right 15.25
up 15.4
left 15.6
up 15.8
down 16
\ No newline at end of file
down 16
left 16.25
right 16.5
left 16.75
left 17.6
right 17.9
down 18.8
up 19
up 19.55
down 19.85
left 20.4
right 20.7
up 22.25
\ No newline at end of file
......@@ -5,18 +5,21 @@ using UnityEngine.SceneManagement;
public class SongSelect : MonoBehaviour {
private SpawnKeys keySpawner;
// Use this for initialization
void Start () {
keySpawner = GameObject.FindWithTag("LevelMaster").GetComponent<SpawnKeys>();
}
public void playSong1(){
keySpawner.Bavaria();
gameObject.SetActive(false);
}
public void playSong2()
{
keySpawner.Tarantell();
gameObject.SetActive(false);
}
public void playSong3()
......
......@@ -10,6 +10,7 @@ public class SpawnKeys : MonoBehaviour {
public float skip;
public float volumeFade;
private bool songSet = false;
private string song = "default";
private float startTime;
private bool endSong = false;
......@@ -26,37 +27,7 @@ public class SpawnKeys : MonoBehaviour {
// Use this for initialization
void Start () {
levelManager = GetComponent<LevelManager>();
startTime = Time.time;
int count = 0;
//Same as above but uses queues, will have to parse
//string of timings into a float later on.
print("Queue version!");
foreach (string line in songFile.text.Split('\n'))
{
if (count != 0)
{
songKeys.Enqueue(line.Split(' '));
}else{
song = line.Split(' ')[0];
songWaitTime = float.Parse(line.Split(' ')[1]);
}
count++;
}
nextKey = songKeys.Dequeue();
//print out queue
//while (songKeys.Count > 0)
//{
// string[] x = songKeys.Dequeue();
// print(x[0] + " " + x[1]);
//}
AudioClip songAudio = Resources.Load<AudioClip>(song);
songWaitTime = songWaitTime / arrowPrefab.GetComponent<Key>().speed;
StartCoroutine(playSong(songAudio, songWaitTime));
}
......@@ -84,6 +55,43 @@ public class SpawnKeys : MonoBehaviour {
}
void Update () {
if(songSet == true){
levelManager = GetComponent<LevelManager>();
startTime = Time.time;
int count = 0;
//Same as above but uses queues, will have to parse
//string of timings into a float later on.
print("Queue version!");
foreach (string line in songFile.text.Split('\n'))
{
if (count != 0)
{
songKeys.Enqueue(line.Split(' '));
}
else
{
song = line.Split(' ')[0];
print("Song: " + song);
songWaitTime = float.Parse(line.Split(' ')[1]);
}
count++;
}
nextKey = songKeys.Dequeue();
//print out queue
//while (songKeys.Count > 0)
//{
// string[] x = songKeys.Dequeue();
// print(x[0] + " " + x[1]);
//}
AudioClip songAudio = Resources.Load<AudioClip>(song);
songWaitTime = songWaitTime / arrowPrefab.GetComponent<Key>().speed;
StartCoroutine(playSong(songAudio, songWaitTime));
songSet = false;
}
if(endSong == true){
music.volume -= (volumeFade * Time.deltaTime);
}
......@@ -151,10 +159,13 @@ public class SpawnKeys : MonoBehaviour {
}
public void Bavaria(){
songFile = Resources.Load<TextAsset>("Bavaria");
print(songFile);
songSet = true;
}
public void Tarantell(){
songFile = Resources.Load<TextAsset>("Tarantella");
songSet = true;
}
}
Markdown is supported
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