예제 #1
0
 // INPUT CORRECT
 // This method checks that the player's input corresponds to the expected input -
 // That they are in the right place and that they are pressing the right thing.
 public bool inputCorrect(DataTypes.InputType input)
 {
     if (stateMachine.CurrentNode == stateMachine.PlayerNode &&
         (input.ToString() == stateMachine.PlayerEdge.NextNodeType.ToString() ||
          ((input.ToString() == "HIT" || input.ToString() == "SNARE")) ||
          stateMachine.CurrentEdge.NextNodeType.ToString() == "ROLL"))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
    // CHECK FOR TRANSITION
    // This method takes the input and decides what to do with it.
    public void checkTransition(DataTypes.InputType input)
    {
        float latestTime = 0f;

        foreach (DataTypes.Node node in currentLoop.NodeList)
        {
            foreach (float time in node.TimePosition)
            {
                if (time > latestTime)
                {
                    latestTime = time;
                }
            }
        }
        if (currentEdge.TransitionTime == latestTime)
        {
            transitioning = false;
        }
        if (bailed && !transitioning &&
            currentEdge.TransitionTime != latestTime)
        {
            transitioning = true;
            StartCoroutine(bailedNodeTransition());
        }
        else if (bailed && !transitioning &&
                 currentEdge.TransitionTime == latestTime)
        {
            transitioning = true;
            StartCoroutine(bailedNodeTransition());
        }
        if ((input == DataTypes.InputType.HIT ||
             input == DataTypes.InputType.SNARE ||
             input == DataTypes.InputType.BAIL) &&
            !bailed &&
            !transitioning)
        {
            transitioning = true;
            // Checksfor a bail
            if (input == DataTypes.InputType.BAIL &&
                currentNode == playerNode)
            {
                bailOnLoop();
            }
            // Checks for a roll
            else if (currentEdge.NextNodeType == DataTypes.NodeType.ROLL &&
                     inputManager.inputWithinTolerance(beatNo))
            {
                StartCoroutine("handleDrumrolls");
            }

            // Checks current edge
            else if (inputManager.inputCorrect(input) &&
                     inputManager.inputWithinTolerance(beatNo))
            {
                StartCoroutine("nodeTransition");
            }
            else
            {
                StartCoroutine("failedTransition");
            }
        }
    }
예제 #3
0
    // GAMEPLAY LOOP
    // This method contains the elements of the gameplay that are checked on a frame-by-frame basis.
    public void gameplayLoop()
    {
        // Get the current beat
        beatNo = timer.currentBeat();
        //Debug.Log("Current Beat - " + beatNo.ToString());
        //Debug.Log("Current Node - " + currentNode.NodeName);
        //Debug.Log ("Current Beat in StateMachine at start of process - " + timer.currentBeat().ToString());
        // Check to see if the first node has played (This happens automatically, does not count as
        // a transition and can contribute towards points).
        checkFirstHit();
        // Check whether the current node is the final node in the loop and if the current edge's transition time matches the
        float latestTime = 0f;

        foreach (DataTypes.Node node in currentLoop.NodeList)
        {
            foreach (float time in node.TimePosition)
            {
                if (time > latestTime)
                {
                    latestTime = time;
                }
            }
        }
        if (checkFinalNode() &&
            (currentEdge.TransitionTime == latestTime))
        {
            if (loopRepetition.Equals(currentLoop.Repetitions))
            {
                if (playerNode != currentNode)
                {
                    score.loopScoreReset();
                    StartCoroutine(resetTransition());
                }
                else if (currentLoop.LoopNumber == currentSong.LoopList.Count)
                {
                    loadVictory();
                }
                else
                {
                    StartCoroutine(loadNextLoop());
                    currentEdge.FromNode = currentNode;
                    StartCoroutine(newLoopTransition());
                }
            }
            else if (loopRepetition != currentLoop.Repetitions)
            {
                StartCoroutine(resetTransition());
            }
        }
        // Get and process the input to see if it triggers a transition. If it does, this process
        // handles that transition as well.
        DataTypes.InputType input = inputManager.getInput();
        if ((input != DataTypes.InputType.NONE) || bailed)
        {
            checkTransition(input);
        }
        else
        {
            inputManager.checkForMiss();
        }
        //Debug.Log ("Current Beat in StateMachine at end of process - " + timer.currentBeat().ToString());
    }