Beispiel #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;
    }
Beispiel #2
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();
    }
    public void drawEdge()
    {
        foreach (GameObject obj in drawnArrow)
        {
            Object.Destroy(obj.gameObject);
        }
        // First, we ses the places the starting edge tells us to go to
        Vector3 lineStartingPlace = nodePositionsNodePos[stateMachine.CurrentEdge.FromNode];
        Vector3 lineEndingPlace   = nodePositionsNodePos[stateMachine.CurrentEdge.ToNode];

        // Then we instantiate a lineRenderer.
        GameObject lineObj  = AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/LineRendererPrefab.prefab", typeof(GameObject)) as GameObject;
        GameObject lineInst = (GameObject)Instantiate(lineObj);

        lineInst.transform.SetParent(canvas.transform);
        lineInst.transform.SetAsLastSibling();
        LineRenderer lineRenderer = lineInst.GetComponent <LineRenderer>();

        lineRenderer.SetVertexCount(2);
        lineRenderer.useWorldSpace = true;

        lineRenderer.SetPosition(0, lineStartingPlace);
        lineRenderer.SetPosition(1, lineEndingPlace);
        GameObject lineRChild = new GameObject();

        lineRChild.transform.SetParent(lineRenderer.transform);
        Text text = lineRChild.AddComponent <Text>();

        text.transform.position = Vector3.Lerp(lineStartingPlace, lineEndingPlace, 0.5f) + new Vector3(5f, 30f, 0f);
        text.text      = stateMachine.CurrentEdge.TransitionTime.ToString();
        text.fontSize  = 40;
        text.font      = Resources.Load <Font>("Fonts/Golden Age");
        text.alignment = TextAnchor.UpperRight;


        // Then, we draw the arrowhead
        Vector3 lineStartingPlace2 = Vector3.Lerp(lineStartingPlace, lineEndingPlace, 0.75f);
        Vector3 lineEndingPlace2   = lineEndingPlace;

        GameObject lineObj2  = AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/LineRendererPrefab.prefab", typeof(GameObject)) as GameObject;
        GameObject lineInst2 = (GameObject)Instantiate(lineObj2);

        lineInst2.transform.SetParent(canvas.transform);
        lineInst2.transform.SetAsLastSibling();
        LineRenderer lineRenderer2 = lineInst2.GetComponent <LineRenderer>();

        lineRenderer2.SetVertexCount(2);
        lineRenderer2.SetWidth(30f, 1f);
        lineRenderer2.useWorldSpace = true;

        lineRenderer2.SetPosition(0, lineStartingPlace2);
        lineRenderer2.SetPosition(1, lineEndingPlace2);

        drawnArrow.Add(lineInst);
        drawnArrow.Add(lineInst2);
        arrowToBeDrawn = false;
        lastDrawnEdge  = stateMachine.CurrentEdge;
    }
Beispiel #4
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();
        }
    }
Beispiel #5
0
    /*// 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);
        }
    }
Beispiel #6
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();
        }
    }
Beispiel #7
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;
    }
 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 //                             _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;
 }
 //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;
 }
 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 //                                        _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();
     }
 }
 // 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();
 }
    /*// 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;
        }
    }
 // 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();
     }
 }
    public void drawEdge()
    {
        foreach(GameObject obj in drawnArrow){
            Object.Destroy(obj.gameObject);
        }
        // First, we ses the places the starting edge tells us to go to
        Vector3 lineStartingPlace = nodePositionsNodePos[stateMachine.CurrentEdge.FromNode];
        Vector3 lineEndingPlace = nodePositionsNodePos[stateMachine.CurrentEdge.ToNode];

        // Then we instantiate a lineRenderer.
        GameObject lineObj = AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/LineRendererPrefab.prefab", typeof(GameObject)) as GameObject;
        GameObject lineInst = (GameObject)Instantiate(lineObj);
        lineInst.transform.SetParent(canvas.transform);
        lineInst.transform.SetAsLastSibling();
        LineRenderer lineRenderer = lineInst.GetComponent<LineRenderer>();
        lineRenderer.SetVertexCount(2);
        lineRenderer.useWorldSpace = true;

        lineRenderer.SetPosition(0,lineStartingPlace);
        lineRenderer.SetPosition(1,lineEndingPlace);
        GameObject lineRChild = new GameObject();
        lineRChild.transform.SetParent(lineRenderer.transform);
        Text text = lineRChild.AddComponent<Text>();
        text.transform.position = Vector3.Lerp(lineStartingPlace,lineEndingPlace,0.5f) + new Vector3(5f,30f,0f);
        text.text = stateMachine.CurrentEdge.TransitionTime.ToString();
        text.fontSize = 40;
        text.font = Resources.Load<Font>("Fonts/Golden Age");
        text.alignment = TextAnchor.UpperRight;

        // Then, we draw the arrowhead
        Vector3 lineStartingPlace2 = Vector3.Lerp(lineStartingPlace,lineEndingPlace,0.75f);
        Vector3 lineEndingPlace2 = lineEndingPlace;

        GameObject lineObj2 = AssetDatabase.LoadAssetAtPath("Assets/Resources/Prefabs/LineRendererPrefab.prefab", typeof(GameObject)) as GameObject;
        GameObject lineInst2 = (GameObject)Instantiate(lineObj2);
        lineInst2.transform.SetParent(canvas.transform);
        lineInst2.transform.SetAsLastSibling();
        LineRenderer lineRenderer2 = lineInst2.GetComponent<LineRenderer>();
        lineRenderer2.SetVertexCount(2);
        lineRenderer2.SetWidth(30f,1f);
        lineRenderer2.useWorldSpace = true;

        lineRenderer2.SetPosition(0,lineStartingPlace2);
        lineRenderer2.SetPosition(1,lineEndingPlace2);

        drawnArrow.Add(lineInst);
        drawnArrow.Add(lineInst2);
        arrowToBeDrawn = false;
        lastDrawnEdge = stateMachine.CurrentEdge;
    }