// Update is called once per frame void Update() { TextMesh filledIn = transform.FindChild("Filled In Text").GetComponent <TextMesh>(); TextMesh toFillIn = transform.FindChild("To Fill-In Text").GetComponent <TextMesh>(); toFillIn.text = rapper.GetCurrentLine(); LevelManager lvlMgr = (LevelManager)FindObjectOfType(typeof(LevelManager)); if (lvlMgr.currentTurn == LevelManager.TurnState.PlayerTurn) { filledIn.text = input.GetRapString(); } else { string curLine = rapper.GetCurrentLine(); filledIn.text = curLine.Substring(0, Mathf.Min(curLine.Length, lvlMgr.enemyTypeStep)); } }
// Update is called once per frame void FixedUpdate() { if (currentState == State.Typing) { timeElapsed += Time.fixedDeltaTime; beatTime = timeElapsed % (60.0f / bpm); if (currentTurn == TurnState.EnemyTurn) { // typing for the enemy if (nextType > ((60.0f / bpm) / 10) && enemyTypeStep <= rapper.GetCurrentLine().Length) { nextType = 0; if (Random.Range(0, 100) < rapper.messUpProbability) { scoreEnemy -= 5; ScoreUpdate(); enemyTypeStep = 0; } else { enemyTypeStep++; } } } nextType += Time.fixedDeltaTime; // beats and stuff if (lastTime > beatTime || lastTime == -1) { // "bump" the circle GetComponent <Animator>().speed = 1 / ((60.0f / bpm) * 4); GetComponent <Animator>().SetTrigger("bump"); if (discreetBeat % 4 == 0) { // move the circle in a line GetComponent <Animator>().speed = 1 / ((60.0f / bpm) * 4); GetComponent <Animator>().SetTrigger("line"); if (rapper.GetCurrentLine() != "") { if (currentTurn == TurnState.PlayerTurn) { if (Compare()) { scorePlayer += 10; ScoreUpdate(); } } else { scoreEnemy += 10; ScoreUpdate(); } } BeatUpdate(); rapper.GoToNextLine(); // after 4 verses, switch turns. if (verse % 4 == 0 && verse != 0) { if (currentTurn == TurnState.PlayerTurn) { currentTurn = TurnState.EnemyTurn; } else { currentTurn = TurnState.PlayerTurn; } } verse++; } discreetBeat++; } lastTime = beatTime; } }