//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // _CORE PROCESSES_ // START // Use this for initialization void Start() { Application.targetFrameRate = 60; //currentSong = Overseer.selectedSong; currentSong = TestSong.getTestSong(); Overseer.songScore = 0; Debug.Log(currentSong.SongName); Debug.Log(currentSong.LoopList[0].SongName); currentLoop = currentSong.LoopList[0]; loopRepetition = 1; timer = new TimingManager(currentLoop.BeatsPerMinute); graphics = GameObject.FindObjectOfType <GraphicsManager>(); levels = GameObject.FindObjectOfType <LevelManager>(); inputManager = GameObject.FindObjectOfType <InputManager>(); sounds = GameObject.FindObjectOfType <SoundManager>(); score = FindObjectOfType <ScoreController>(); beatNo = timer.currentBeat(); // Find the first edge. currentEdge = currentLoop.EdgeList[0]; currentNode = currentEdge.FromNode; endNode = currentLoop.NodeList[currentLoop.NodeList.Count - 1]; if (currentNode.StartNode) { startNode = currentNode; //Debug.Log("All loaded, we're good to go! - " + ((double)(Time.time - TimingManager.StartTime)).ToString()); //Debug.Log(currentNode.NodeName + " " + CurrentNode.NodeType.ToString()); } playerEdge = currentEdge; playerNode = currentNode; graphics.beginGraphicsProcess(); loaded = true; }
// DELETE LOOP // This deletes the current loop from the song. public void deleteLoop() { for (int i = currentSong.LoopList.IndexOf(currentLoop) + 1; i < currentSong.LoopList.Count; i++) { currentSong.LoopList[i].LoopNumber--; } int index = currentSong.LoopList.IndexOf(currentLoop); listofLOAB.Remove(index + 1); if (listofLOAB.Count > index + 1) { for (int i = index + 2; i < listofLOAB.Count; i++) { listofLOAB[i - 1] = listofLOAB[i]; } } listofLOUB.Remove(index + 1); if (listofLOUB.Count > index + 1) { for (int i = index + 2; i < listofLOUB.Count; i++) { listofLOUB[i - 1] = listofLOUB[i]; } } currentSong.LoopList.RemoveAt(index); currentLoop = currentSong.LoopList[index - 1]; closeAreYouSureWindow(); updateGraphics(); }
// SONG HAS BEEN IMPORTED // This method runs all the things that get a loop set up for when a new song is imported public void songHasBeenImported() { currentLoop = currentSong.LoopList[0]; listofLOAB.Clear(); listofLOUB.Clear(); listofUsedBeats = new List <float>(); foreach (DataTypes.Loop loop in currentSong.LoopList) { listofAvailableBeats = new List <float>(); listofUsedBeats = new List <float>(); listofLOAB[loop.LoopNumber] = listofAvailableBeats; listofLOUB[loop.LoopNumber] = listofUsedBeats; populateLoAB(); foreach (DataTypes.Node node in loop.NodeList) { foreach (float time in node.TimePosition) { if (listofAvailableBeats.Contains(time)) { listofAvailableBeats.Remove(time); listofUsedBeats.Add(time); } } } } hitNo = 0; rollNo = 0; snareNo = 0; selectedNode = null; isAcceptNodeSet = false; acceptToBeHighlighted = false; foreach (DataTypes.Node node in currentLoop.NodeList) { if (node.NodeType == DataTypes.NodeType.HIT) { hitNo++; } else if (node.NodeType == DataTypes.NodeType.ROLL) { rollNo++; } else if (node.NodeType == DataTypes.NodeType.SNARE) { snareNo++; } if (node.AcceptNode == true) { isAcceptNodeSet = true; } nodeToBeHighlighted = false; } if (currentLoop.NodeList.Exists(o => o.AcceptNode == true)) { isAcceptNodeSet = true; acceptToBeHighlighted = true; } updateGraphics(); }
void Awake() { hitNo = 0; snareNo = 0; rollNo = 0; isAcceptNodeSet = false; nodeToBeHighlighted = false; acceptToBeHighlighted = false; currentSong = new DataTypes.Song(); currentLoop = new DataTypes.Loop(); currentLoop.LoopNumber = 1; currentSong.LoopList.Add(currentLoop); canvas = FindObjectOfType <Canvas>(); listofAvailableBeats = new List <float>(); populateLoAB(); listofUsedBeats = new List <float>(); listofLOAB = new Dictionary <int, List <float> >(); listofLOAB[1] = listofAvailableBeats; listofLOUB = new Dictionary <int, List <float> >(); listofLOUB[1] = listofUsedBeats; nodePositionsNodePos = new Dictionary <DataTypes.Node, Vector3>(); nodePositionsPosNode = new Dictionary <Vector3, DataTypes.Node>(); listOfNodeLocations = new List <Vector3>(); listOfInstantiatedNodes = new List <GameObject>(); listOfInstantiatedLines = new List <GameObject>(); }
// IMPORT SONG // This method takes in a string and parses it to form a new song. public DataTypes.Song importSong(string song) { // Break up the elements of the "song" string - we can't rely on newLines via // Unity's stupid multiline fields. string[] splitSong = song.Split(new char[]{';'}); DataTypes.Song newSong = new DataTypes.Song(); DataTypes.Loop newLoop = new DataTypes.Loop(); DataTypes.Node newNode = new DataTypes.Node(); foreach (string songInfo in splitSong){ if(songInfo.StartsWith("SONG NAME")){ newSong.SongName = songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1)); } else if (songInfo.StartsWith("LOOP START")){ newLoop = new DataTypes.Loop(); } else if (songInfo.StartsWith("LOOP NUMBER")){ newLoop.LoopNumber = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("LOOP REPETITIONS")){ newLoop.Repetitions = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("LOOP BPM")){ newLoop.BeatsPerMinute = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("NODE START")){ newNode = new DataTypes.Node(); } else if (songInfo.StartsWith("NODE NAME")){ newNode.NodeName = songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1)); } else if (songInfo.StartsWith("NODE TYPE")){ newNode.NodeType = (DataTypes.NodeType)System.Enum.Parse(typeof(DataTypes.NodeType), songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("NODE LOOP NUMBER")){ newNode.LoopNumber = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("NODE TIME POSITION")){ newNode.TimePosition.Add(float.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1)))); } else if (songInfo.StartsWith("NODE IS START")){ newNode.StartNode = bool.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("NODE IS ACCEPT")){ newNode.AcceptNode = bool.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<')+1))); } else if (songInfo.StartsWith("NODE END")){ newLoop.NodeList.Add(newNode); newNode = new DataTypes.Node(); } else if (songInfo.StartsWith("LOOP END")){ newSong.LoopList.Add(newLoop); newLoop = new DataTypes.Loop(); } } return newSong; }
// SWITCH LOOP // This switches the current loop back or forward. public void switchLoop(int i) { if (currentLoop.LoopNumber == 1 && i == -1) { return; } else if (i == 1 || i == -1) { if (i == 1) { currentLoop = currentSong.LoopList[currentLoop.LoopNumber]; } else { currentLoop = currentSong.LoopList[currentLoop.LoopNumber - 2]; } listofAvailableBeats = listofLOAB[currentLoop.LoopNumber]; listofUsedBeats = listofLOUB[currentLoop.LoopNumber]; if (listofAvailableBeats.Count == 0 && listofUsedBeats.Count == 0) { populateLoAB(); } hitNo = 0; rollNo = 0; snareNo = 0; selectedNode = null; isAcceptNodeSet = false; foreach (DataTypes.Node node in currentLoop.NodeList) { if (node.NodeType == DataTypes.NodeType.HIT) { hitNo++; } else if (node.NodeType == DataTypes.NodeType.ROLL) { rollNo++; } else if (node.NodeType == DataTypes.NodeType.SNARE) { snareNo++; } if (node.AcceptNode == true) { isAcceptNodeSet = true; } nodeToBeHighlighted = false; } } else { Debug.Log("Error: switchLoop"); } // TODO: Graphical representation. updateGraphics(); }
// NEW LOOP // This creates a new loop. public void newLoop() { DataTypes.Loop newloop = new DataTypes.Loop(); newloop.SongName = currentSong.SongName; newloop.LoopNumber = currentSong.LoopList.Count + 1; newloop.BeatsPerMinute = currentSong.LoopList[currentSong.LoopList.Count - 1].BeatsPerMinute; listofLOAB[newloop.LoopNumber] = new List <float>(); listofLOUB[newloop.LoopNumber] = new List <float>(); currentSong.LoopList.Add(newloop); }
public void beginGraphicsProcess() { stateMachine = GameObject.FindObjectOfType <StateMachine>(); //theCamera = GameObject.FindObjectOfType<Camera>(); line = GetComponent <LineRenderer>(); currentLoop = stateMachine.CurrentLoop; currentNode = stateMachine.CurrentNode; nodes = currentLoop.NodeList; edges = currentLoop.EdgeList; drawGraph(nodes); }
public void beginGraphicsProcess() { stateMachine = GameObject.FindObjectOfType<StateMachine>(); //theCamera = GameObject.FindObjectOfType<Camera>(); line = GetComponent<LineRenderer>(); currentLoop = stateMachine.CurrentLoop; currentNode = stateMachine.CurrentNode; nodes = currentLoop.NodeList; edges = currentLoop.EdgeList; drawGraph(nodes); }
/*// RESET LOOP * // This method resets the current loop. * IEnumerator resetLoop(){ * resetting = true; * bool timeToReset = false; * while (!timeToReset){ * if ((beatNo-1.1f) % 1.0f == 0.0f){ * timeToReset = true; * timer.resetTimer(); * StartCoroutine("ResetTransition"); * } * yield return null; * } * * //currentEdge = new DataTypes.Edge(currentNode, currentLoop.NodeList[0]); * //playerEdge = currentEdge; * if(currentNode = playerNode){ * ScoreController.addToTotal(); * } * ScoreController.resetLoopScore(); * * resetting = false; * * }*/ // LOAD NEXT LOOP // This method loads the next loop in the song sequence and creates an edge // to transition between the two. public IEnumerator loadNextLoop() { int oldLoopIndex = currentSong.LoopList.FindIndex(i => i == currentLoop); currentLoop = currentSong.LoopList[oldLoopIndex + 1]; currentEdge = new DataTypes.Edge(currentNode, currentLoop.NodeList[0]); playerEdge = currentEdge; loopRepetition = 1; bool LNLfinished = false; while (!LNLfinished) { if (timer.currentElapsed() % 1.0f == 0.0f) { timer.resetTimer(); LNLfinished = true; } yield return(null); } }
void Awake() { hitNo = 0; snareNo = 0; rollNo = 0; isAcceptNodeSet = false; nodeToBeHighlighted = false; acceptToBeHighlighted = false; currentSong = new DataTypes.Song(); currentLoop = new DataTypes.Loop(); currentLoop.LoopNumber = 1; currentSong.LoopList.Add(currentLoop); canvas = FindObjectOfType<Canvas>(); listofAvailableBeats = new List<float>(); populateLoAB(); listofUsedBeats = new List<float>(); listofLOAB = new Dictionary<int, List<float>>(); listofLOAB[1] = listofAvailableBeats ; listofLOUB = new Dictionary<int, List<float>>(); listofLOUB[1] = listofUsedBeats; nodePositionsNodePos = new Dictionary<DataTypes.Node, Vector3>(); nodePositionsPosNode = new Dictionary<Vector3, DataTypes.Node>(); listOfNodeLocations = new List<Vector3>(); listOfInstantiatedNodes = new List<GameObject>(); listOfInstantiatedLines = new List<GameObject>(); }
// SWITCH LOOP // This switches the current loop back or forward. public void switchLoop(int i) { if (currentLoop.LoopNumber == 1 && i == -1){ return; } else if (i == 1 || i == -1){ if (i == 1){ currentLoop = currentSong.LoopList[currentLoop.LoopNumber]; } else { currentLoop = currentSong.LoopList[currentLoop.LoopNumber - 2]; } listofAvailableBeats = listofLOAB[currentLoop.LoopNumber]; listofUsedBeats = listofLOUB[currentLoop.LoopNumber]; if (listofAvailableBeats.Count == 0 && listofUsedBeats.Count == 0){ populateLoAB(); } hitNo = 0; rollNo = 0; snareNo = 0; selectedNode = null; isAcceptNodeSet = false; foreach (DataTypes.Node node in currentLoop.NodeList){ if (node.NodeType == DataTypes.NodeType.HIT){hitNo++;} else if(node.NodeType == DataTypes.NodeType.ROLL){rollNo++;} else if (node.NodeType == DataTypes.NodeType.SNARE){snareNo++;} if (node.AcceptNode == true){isAcceptNodeSet = true;} nodeToBeHighlighted = false; } } else { Debug.Log ("Error: switchLoop"); } // TODO: Graphical representation. updateGraphics(); }
// SONG HAS BEEN IMPORTED // This method runs all the things that get a loop set up for when a new song is imported public void songHasBeenImported() { currentLoop = currentSong.LoopList[0]; listofLOAB.Clear(); listofLOUB.Clear(); listofUsedBeats = new List<float>(); foreach (DataTypes.Loop loop in currentSong.LoopList){ listofAvailableBeats = new List<float>(); listofUsedBeats = new List<float>(); listofLOAB[loop.LoopNumber] = listofAvailableBeats; listofLOUB[loop.LoopNumber] = listofUsedBeats; populateLoAB(); foreach(DataTypes.Node node in loop.NodeList){ foreach(float time in node.TimePosition){ if (listofAvailableBeats.Contains(time)){ listofAvailableBeats.Remove(time); listofUsedBeats.Add(time); } } } } hitNo = 0; rollNo = 0; snareNo = 0; selectedNode = null; isAcceptNodeSet = false; acceptToBeHighlighted = false; foreach (DataTypes.Node node in currentLoop.NodeList){ if (node.NodeType == DataTypes.NodeType.HIT){hitNo++;} else if(node.NodeType == DataTypes.NodeType.ROLL){rollNo++;} else if (node.NodeType == DataTypes.NodeType.SNARE){snareNo++;} if (node.AcceptNode == true){isAcceptNodeSet = true;} nodeToBeHighlighted = false; } if(currentLoop.NodeList.Exists(o => o.AcceptNode == true)){ isAcceptNodeSet = true; acceptToBeHighlighted = true; } updateGraphics(); }
// NEW LOOP // This creates a new loop. public void newLoop() { DataTypes.Loop newloop = new DataTypes.Loop(); newloop.SongName = currentSong.SongName; newloop.LoopNumber = currentSong.LoopList.Count + 1; newloop.BeatsPerMinute = currentSong.LoopList[currentSong.LoopList.Count - 1].BeatsPerMinute; listofLOAB[newloop.LoopNumber] = new List<float>(); listofLOUB[newloop.LoopNumber] = new List<float>(); currentSong.LoopList.Add(newloop); }
// DELETE LOOP // This deletes the current loop from the song. public void deleteLoop() { for (int i = currentSong.LoopList.IndexOf(currentLoop)+ 1; i < currentSong.LoopList.Count; i++){ currentSong.LoopList[i].LoopNumber--; } int index = currentSong.LoopList.IndexOf(currentLoop); listofLOAB.Remove(index + 1); if (listofLOAB.Count > index + 1){ for (int i = index + 2; i < listofLOAB.Count; i++){ listofLOAB[i-1] = listofLOAB[i]; } } listofLOUB.Remove(index + 1); if (listofLOUB.Count > index + 1){ for (int i = index + 2; i < listofLOUB.Count; i++){ listofLOUB[i-1] = listofLOUB[i]; } } currentSong.LoopList.RemoveAt(index); currentLoop = currentSong.LoopList[index - 1]; closeAreYouSureWindow(); updateGraphics(); }
/*// RESET LOOP // This method resets the current loop. IEnumerator resetLoop(){ resetting = true; bool timeToReset = false; while (!timeToReset){ if ((beatNo-1.1f) % 1.0f == 0.0f){ timeToReset = true; timer.resetTimer(); StartCoroutine("ResetTransition"); } yield return null; } //currentEdge = new DataTypes.Edge(currentNode, currentLoop.NodeList[0]); //playerEdge = currentEdge; if(currentNode = playerNode){ ScoreController.addToTotal(); } ScoreController.resetLoopScore(); resetting = false; }*/ // LOAD NEXT LOOP // This method loads the next loop in the song sequence and creates an edge // to transition between the two. public IEnumerator loadNextLoop() { int oldLoopIndex = currentSong.LoopList.FindIndex(i => i == currentLoop); currentLoop = currentSong.LoopList[oldLoopIndex + 1]; currentEdge = new DataTypes.Edge(currentNode,currentLoop.NodeList[0]); playerEdge = currentEdge; loopRepetition = 1; bool LNLfinished = false; while (!LNLfinished){ if (timer.currentElapsed() % 1.0f == 0.0f){ timer.resetTimer(); LNLfinished = true; } yield return null; } }
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // _CORE PROCESSES_ // START // Use this for initialization void Start() { Application.targetFrameRate = 60; //currentSong = Overseer.selectedSong; currentSong = TestSong.getTestSong(); Overseer.songScore = 0; Debug.Log (currentSong.SongName); Debug.Log(currentSong.LoopList[0].SongName); currentLoop = currentSong.LoopList[0]; loopRepetition = 1; timer = new TimingManager(currentLoop.BeatsPerMinute); graphics = GameObject.FindObjectOfType<GraphicsManager>(); levels = GameObject.FindObjectOfType<LevelManager>(); inputManager = GameObject.FindObjectOfType<InputManager>(); sounds = GameObject.FindObjectOfType<SoundManager>(); score = FindObjectOfType<ScoreController>(); beatNo = timer.currentBeat(); // Find the first edge. currentEdge = currentLoop.EdgeList[0]; currentNode = currentEdge.FromNode; endNode = currentLoop.NodeList[currentLoop.NodeList.Count - 1]; if (currentNode.StartNode){ startNode = currentNode; //Debug.Log("All loaded, we're good to go! - " + ((double)(Time.time - TimingManager.StartTime)).ToString()); //Debug.Log(currentNode.NodeName + " " + CurrentNode.NodeType.ToString()); } playerEdge = currentEdge; playerNode = currentNode; graphics.beginGraphicsProcess(); loaded = true; }
// IMPORT SONG // This method takes in a string and parses it to form a new song. public DataTypes.Song importSong(string song) { // Break up the elements of the "song" string - we can't rely on newLines via // Unity's stupid multiline fields. string[] splitSong = song.Split(new char[] { ';' }); DataTypes.Song newSong = new DataTypes.Song(); DataTypes.Loop newLoop = new DataTypes.Loop(); DataTypes.Node newNode = new DataTypes.Node(); foreach (string songInfo in splitSong) { if (songInfo.StartsWith("SONG NAME")) { newSong.SongName = songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1)); } else if (songInfo.StartsWith("LOOP START")) { newLoop = new DataTypes.Loop(); } else if (songInfo.StartsWith("LOOP NUMBER")) { newLoop.LoopNumber = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("LOOP REPETITIONS")) { newLoop.Repetitions = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("LOOP BPM")) { newLoop.BeatsPerMinute = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("NODE START")) { newNode = new DataTypes.Node(); } else if (songInfo.StartsWith("NODE NAME")) { newNode.NodeName = songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1)); } else if (songInfo.StartsWith("NODE TYPE")) { newNode.NodeType = (DataTypes.NodeType)System.Enum.Parse(typeof(DataTypes.NodeType), songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("NODE LOOP NUMBER")) { newNode.LoopNumber = System.Int32.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("NODE TIME POSITION")) { newNode.TimePosition.Add(float.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1)))); } else if (songInfo.StartsWith("NODE IS START")) { newNode.StartNode = bool.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("NODE IS ACCEPT")) { newNode.AcceptNode = bool.Parse(songInfo.Substring(songInfo.IndexOf('<') + 1, songInfo.IndexOf('>') - (songInfo.IndexOf('<') + 1))); } else if (songInfo.StartsWith("NODE END")) { newLoop.NodeList.Add(newNode); newNode = new DataTypes.Node(); } else if (songInfo.StartsWith("LOOP END")) { newSong.LoopList.Add(newLoop); newLoop = new DataTypes.Loop(); } } return(newSong); }