コード例 #1
0
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//                             _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;
    }
コード例 #2
0
    // 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();
    }
コード例 #3
0
    // NEW LOOP TRANSITION
    // This method transitions between edges. There is no expectation of input; code will later
    // be implemented if the player does then correctly input the first node of the loop.
    public IEnumerator newLoopTransition()
    {
        bool timeToTransition = false;

        while (!timeToTransition)
        {
            if (beatNo >= currentEdge.TransitionTime)
            {
                timeToTransition = true;
            }
            yield return(null);
        }
        if (timeToTransition)
        {
            currentNode = currentEdge.ToNode;
            currentEdge = currentLoop.EdgeList[0];
            playerEdge  = currentEdge;
            playerNode  = currentNode;
            if (currentNode == currentEdge.FromNode)
            {
                sounds.playNodeSound();
            }
        }
        transitioning = false;
        graphics.beginGraphicsProcess();
    }
コード例 #4
0
    // DELETE NODE
    // This method deletes the selected node, then links the two nodes on either side of it.
    public void deleteNode()
    {
        DataTypes.Node gonerNode = selectedNode;
        // We use the first TimePosition of the note to be deleted as a reference point (why?)
        // float deletePoint = gonerNode.TimePosition[0];
        // We then go through each nextNode in
        for (int i = 0; i < gonerNode.NextNode.Count; i++)
        {
            DataTypes.Node newNextNode = gonerNode.NextNode[i];
            DataTypes.Node newPrevNode = gonerNode.PrevNode[i];
            foreach (DataTypes.Node node in newPrevNode.NextNode)
            {
                if (node == gonerNode)
                {
                    gonerNode.NextNode[i] = newNextNode;
                }
            }
            foreach (DataTypes.Node node in newNextNode.PrevNode)
            {
                if (node == gonerNode)
                {
                    gonerNode.NextNode[i] = newPrevNode;
                }
            }
        }
        foreach (float time in gonerNode.TimePosition)
        {
            listofUsedBeats.Remove(time);
            listofAvailableBeats.Add(time);
        }
        currentLoop.NodeList.Remove(gonerNode);
        NodeMenu nodeMenu = FindObjectOfType <NodeMenu>();

        // TODO: Graphical representation.
        updateGraphics();

        // FROM A PREVIOUS VERSION OF THIS METHOD WHICH DELETED ALL FUTURE NODES OR TIME POSITIONS

        /*foreach (DataTypes.Node node in currentLoop.NodeList){
         *      if (node.TimePosition[0]>= deletePoint){
         *              currentLoop.NodeList.Remove(node);
         *      }
         *      else if (currentLoop.NodeList.Count > 1){
         *              foreach (DataTypes.Node prevNode in node.PrevNode){
         *                      if (prevNode.TimePosition[0] >= deletePoint)
         *                              node.PrevNode.Remove(prevNode);
         *              }
         *              foreach (float time in node.TimePosition){
         *                      if (time >= deletePoint){
         *                              int index = node.TimePosition.IndexOf(time);
         *                              node.TimePosition.RemoveAt[index];
         *                              foreach (DataTypes.Node nextNode in node.NextNode){
         *                                      if (nextNode.TimePosition)
         *                              }
         *                      }
         *              }
         *      }
         * }*/
    }
コード例 #5
0
    // BAILED NODE TRANSITION
    // This method transitions node and edge without awarding points or expecting further input.
    public IEnumerator bailedNodeTransition()
    {
        bool timeToTransition = false;

        while (!timeToTransition)
        {
            if (beatNo >= currentEdge.TransitionTime)
            {
                timeToTransition = true;
            }
            yield return(null);
        }
        if (timeToTransition)
        {
            currentNode = currentEdge.ToNode;
            int oldEdgeIndex = currentLoop.EdgeList.FindIndex(i => i == currentEdge);
            if (oldEdgeIndex + 1 != currentLoop.EdgeList.Count)
            {
                currentEdge = currentLoop.EdgeList[oldEdgeIndex + 1];
                playerEdge  = currentEdge;
                playerNode  = currentNode;
                if (currentNode == currentEdge.FromNode)
                {
                    sounds.playNodeSound();
                    score.awardPoints();
                }
            }
            else
            {
                playerNode = currentNode;
                if (currentNode == currentEdge.ToNode)
                {
                    sounds.playNodeSound();
                    score.awardPoints();
                }
            }
        }
        transitioning = false;
        float latestTime = 0f;

        foreach (DataTypes.Node node in currentLoop.NodeList)
        {
            foreach (float time in node.TimePosition)
            {
                if (time > latestTime)
                {
                    latestTime = time;
                }
            }
        }
        if (bailed && !transitioning &&
            currentEdge.TransitionTime == latestTime)
        {
            transitioning = true;
            resetTransition();
        }
    }
コード例 #6
0
    // 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();
    }
コード例 #7
0
 // 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;
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 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);
 }
コード例 #10
0
    // ADD NODE
    // This method creates a node, names it and adds it to the current loop.
    public void addNode(string type)
    {
        DataTypes.NodeType newType;
        if (type == "HIT")
        {
            newType = DataTypes.NodeType.HIT;
        }
        else if (type == "ROLL")
        {
            newType = DataTypes.NodeType.ROLL;
        }
        else
        {
            newType = DataTypes.NodeType.SNARE;
        }
        DataTypes.Node newNode = new DataTypes.Node(newType);

        if (newNode.NodeType == DataTypes.NodeType.HIT)
        {
            hitNo++;
            newNode.nameNode(hitNo);
        }
        else if (newNode.NodeType == DataTypes.NodeType.ROLL)
        {
            rollNo++;
            newNode.nameNode(rollNo);
        }
        else
        {
            snareNo++;
            newNode.nameNode(snareNo);
        }
        newNode.TimePosition.Add(listofAvailableBeats[0]);
        ListofAvailableBeats.Remove(newNode.TimePosition[0]);
        listofUsedBeats.Add(newNode.TimePosition[0]);

        currentLoop.NodeList.Add(newNode);
        if (currentLoop.NodeList.Count > 1)
        {
            currentLoop.NodeList.Sort((x, y) => (x.TimePosition[0].CompareTo(y.TimePosition[0])));
        }
        // TODO: Graphical representation.
        updateGraphics();
    }
コード例 #11
0
 // Update is called once per frame
 void Update()
 {
     if (selectedNode != null && nodeToBeHighlighted)
     {
         ringNode(nodePositionsNodePos[selectedNode], 30f, 30);
         nodeToBeHighlighted = false;
     }
     if (isAcceptNodeSet && acceptToBeHighlighted)
     {
         DataTypes.Node acceptNode = currentLoop.NodeList.Find(o => o.AcceptNode == true);
         ringAccept(nodePositionsNodePos[acceptNode], 30f, 30);
         acceptToBeHighlighted = false;
     }
     currentBeat = getCurrentBeat();
     if (menu != null)
     {
         menu.transform.SetAsLastSibling();
     }
 }
コード例 #12
0
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//								_NODE-RELATED METHODS_


    // GET PREFAB
    // This method assesses a node's type and returns the corresponding prefab.
    GameObject getPrefab(DataTypes.Node node)
    {
        if (node.NodeType.Equals(DataTypes.NodeType.HIT))
        {
            return(AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/Hit graph node.prefab", typeof(GameObject)) as GameObject);
        }
        else if (node.NodeType.Equals(DataTypes.NodeType.ROLL))
        {
            return(AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/Roll graph node.prefab", typeof(GameObject)) as GameObject);
        }
        else if (node.NodeType.Equals(DataTypes.NodeType.SNARE))
        {
            return(AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/Snare graph node.prefab", typeof(GameObject)) as GameObject);
        }
        else
        {
            return(null);
        }
    }
コード例 #13
0
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//							_LINERENDERER-RELATED METHODS_


    // VISUAL PULSE
    // This method goes to the position of the player's node and, every frame, draws a
    // ring around it using the ringNode method (see below). This ring pulses in time
    // with the music.
    // It MIGHT need to be turned into an IEnumerator/CoRoutine.
    void visualPulse(float radiusVariation)
    {
        DataTypes.Node node         = stateMachine.PlayerNode;
        float          sizeOfRadius = (stateMachine.Timer.getCurrentTime() % TimingManager.QuarterLength);
        float          radiusPulse;

        if (sizeOfRadius < TimingManager.EighthLength)
        {
            radiusPulse = radiusVariation / (TimingManager.EighthLength / sizeOfRadius);
        }
        else
        {
            radiusPulse = (2 * radiusVariation) - (radiusVariation / (TimingManager.EighthLength / sizeOfRadius));
        }
        float radius = 20 + radiusPulse;

        /*Debug.Log(nodePositionsNodePos[node]);*/
        Vector3 position = nodePositionsNodePos[node];

        ringNode(position, radius, 40);
    }
コード例 #14
0
    // FAILED TRANSITION
    // This method handles a failed transition.
    public IEnumerator failedTransition()
    {
        bool timeToTransition = false;

        while (!timeToTransition)
        {
            if (beatNo >= currentEdge.TransitionTime)
            {
                timeToTransition = true;
            }
            yield return(null);
        }
        if (timeToTransition)
        {
            currentNode = currentEdge.ToNode;
            int oldEdgeIndex = currentLoop.EdgeList.FindIndex(i => i == currentEdge);
            currentEdge = currentLoop.EdgeList[oldEdgeIndex + 1];
            score.multiplierReset();
        }
        transitioning = false;
        float latestTime = 0f;

        foreach (DataTypes.Node node in currentLoop.NodeList)
        {
            foreach (float time in node.TimePosition)
            {
                if (time > latestTime)
                {
                    latestTime = time;
                }
            }
        }
        if (bailed && !transitioning &&
            currentEdge.TransitionTime == latestTime)
        {
            transitioning = true;
            resetTransition();
        }
    }
コード例 #15
0
    //RESET TRANSITION
    // This method handles a transition between the end of one iteration of a loop
    // and the beginning of another.
    public IEnumerator resetTransition()
    {
        resetting = true;
        bool timeToTransition = false;

        while (!timeToTransition)
        {
            bool endofbar = false;
            while (!endofbar)
            {
                if (timer.currentElapsed() % 1.0f == 0.0f)
                {
                    endofbar = true;
                }
                yield return(null);
            }
            timer.resetTimer();
            if (beatNo == currentLoop.NodeList[0].TimePosition[0])
            {
                timeToTransition = true;
            }
            yield return(null);
        }
        if (timeToTransition)
        {
            timer.resetTimer();
            currentEdge = currentLoop.EdgeList[0];
            currentNode = currentEdge.FromNode;
            //ScoreController.resetMultiplier();
            if (currentNode == currentLoop.NodeList[0])
            {
                sounds.playNodeSound();
            }
        }
        transitioning = false;
        resetting     = false;
    }
コード例 #16
0
 // Update is called once per frame
 void Update()
 {
     /*if (graphicsStarted){
      *      if (!pulsing){
      *              pulsing = true;
      *              StartCoroutine(visualPulse(10f));
      *      }
      * }*/
     visualPulse(20f);
     if (acceptToBeHighlighted)
     {
         DataTypes.Node acceptNode = currentLoop.NodeList.Find(o => o.AcceptNode == true);
         ringAccept(nodePositionsNodePos[acceptNode], 30f, 30);
         acceptToBeHighlighted = false;
     }
     if (lastDrawnEdge != stateMachine.CurrentEdge)
     {
         arrowToBeDrawn = true;
     }
     if (arrowToBeDrawn)
     {
         drawEdge();
     }
 }
コード例 #17
0
 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 //                                        _TRANSITIONS_
 // NODE TRANSITION
 // This method transitions node and edge.
 public IEnumerator nodeTransition()
 {
     bool timeToTransition = false;
     while(!timeToTransition){
         if(beatNo >= currentEdge.TransitionTime){
         timeToTransition = true;
         }
         yield return null;
     }
     if (timeToTransition){
         currentNode = currentEdge.ToNode;
         int oldEdgeIndex = currentLoop.EdgeList.FindIndex(i => i == currentEdge);
         currentEdge = currentLoop.EdgeList[oldEdgeIndex+1];
         playerEdge = currentEdge;
         playerNode = currentNode;
         if (currentNode == currentEdge.FromNode){
             sounds.playNodeSound();
             score.awardPoints();
         }
     }
     transitioning = false;
     float latestTime = 0f;
     foreach (DataTypes.Node node in currentLoop.NodeList){
         foreach (float time in node.TimePosition){
             if(time > latestTime){
                 latestTime = time;
             }
         }
     }
     if ( bailed && !transitioning
         && currentEdge.TransitionTime == latestTime){
         transitioning = true;
         resetTransition();
     }
 }
コード例 #18
0
 // NEW LOOP TRANSITION
 // This method transitions between edges. There is no expectation of input; code will later
 // be implemented if the player does then correctly input the first node of the loop.
 public IEnumerator newLoopTransition()
 {
     bool timeToTransition = false;
     while(!timeToTransition){
         if(beatNo >= currentEdge.TransitionTime){
             timeToTransition = true;
         }
         yield return null;
     }
     if(timeToTransition){
         currentNode = currentEdge.ToNode;
         currentEdge = currentLoop.EdgeList[0];
         playerEdge = currentEdge;
         playerNode = currentNode;
         if (currentNode == currentEdge.FromNode){
             sounds.playNodeSound();
         }
     }
     transitioning = false;
     graphics.beginGraphicsProcess();
 }
コード例 #19
0
 // FAILED TRANSITION
 // This method handles a failed transition.
 public IEnumerator failedTransition()
 {
     bool timeToTransition = false;
     while(!timeToTransition){
         if(beatNo >= currentEdge.TransitionTime){
             timeToTransition = true;
         }
         yield return null;
     }
     if (timeToTransition){
         currentNode = currentEdge.ToNode;
         int oldEdgeIndex = currentLoop.EdgeList.FindIndex(i => i == currentEdge);
         currentEdge = currentLoop.EdgeList[oldEdgeIndex+1];
         score.multiplierReset();
     }
     transitioning = false;
     float latestTime = 0f;
     foreach (DataTypes.Node node in currentLoop.NodeList){
         foreach (float time in node.TimePosition){
             if(time > latestTime){
                 latestTime = time;
             }
         }
     }
     if ( bailed && !transitioning
         && currentEdge.TransitionTime == latestTime){
         transitioning = true;
         resetTransition();
     }
 }
コード例 #20
0
    // 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();
    }
コード例 #21
0
    // 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();
    }
コード例 #22
0
    // ADD NODE
    // This method creates a node, names it and adds it to the current loop.
    public void addNode(string type)
    {
        DataTypes.NodeType newType;
        if (type == "HIT"){
            newType = DataTypes.NodeType.HIT;
        } else if (type == "ROLL"){
            newType = DataTypes.NodeType.ROLL;
        } else {
            newType = DataTypes.NodeType.SNARE;
        }
        DataTypes.Node newNode = new DataTypes.Node(newType);

        if (newNode.NodeType == DataTypes.NodeType.HIT){
            hitNo++;
            newNode.nameNode(hitNo);
        } else if (newNode.NodeType == DataTypes.NodeType.ROLL){
            rollNo++;
            newNode.nameNode(rollNo);
        } else {
            snareNo++;
            newNode.nameNode(snareNo);
        }
        newNode.TimePosition.Add(listofAvailableBeats[0]);
        ListofAvailableBeats.Remove(newNode.TimePosition[0]);
        listofUsedBeats.Add (newNode.TimePosition[0]);

        currentLoop.NodeList.Add(newNode);
        if (currentLoop.NodeList.Count > 1){
            currentLoop.NodeList.Sort((x, y) => (x.TimePosition[0].CompareTo(y.TimePosition[0])));
        }
        // TODO: Graphical representation.
        updateGraphics();
    }
コード例 #23
0
 //RESET TRANSITION
 // This method handles a transition between the end of one iteration of a loop
 // and the beginning of another.
 public IEnumerator resetTransition()
 {
     resetting = true;
     bool timeToTransition = false;
     while(!timeToTransition){
         bool endofbar = false;
         while (!endofbar){
             if (timer.currentElapsed() % 1.0f == 0.0f){
                 endofbar = true;
             }
             yield return null;
         }
         timer.resetTimer();
         if(beatNo == currentLoop.NodeList[0].TimePosition[0]){
             timeToTransition = true;
         }
         yield return null;
     }
     if (timeToTransition){
         timer.resetTimer();
         currentEdge = currentLoop.EdgeList[0];
         currentNode = currentEdge.FromNode;
         //ScoreController.resetMultiplier();
         if (currentNode == currentLoop.NodeList[0]){
             sounds.playNodeSound();
         }
     }
     transitioning = false;
     resetting = false;
 }
コード例 #24
0
 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 //                             _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;
 }
コード例 #25
0
 // 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);
 }