//fades from one scene to another with a dropinObject to mask it public void transitionToScene(Color transitionColor, gameState goToState, musicState musicTransition) { GameObject tempGameObject = Instantiate(dropInObject, GameObject.FindGameObjectWithTag("Canvas").transform); this.transitionColor = transitionColor; tempGameObject.GetComponent <DropIn>().Drop(goToState); this.musicTransition = musicTransition; }
//called when a player is killed. updates the amount of players alive and handles the end of the round public void updatePlayer(MasterBody deadPlayer) { playersAlive -= 1; temporaryRanking[playersAlive] = deadPlayer.playerID; Debug.Log("player" + temporaryRanking[playersAlive] + " Just finished in " + playersAlive + "th place"); //If there are two people left, speed up the music if (playersAlive == 2) { goalPitch = pitchTop; musicTransition = musicState.pitchUp; } else { goalPitch = pitchMiddle; } int winnerID = 0; // If there is only survivor left, loops through all the players and checks which is left alive. assigns that player as the winner. if (playersAlive == 1) { foreach (GameObject player in playersHolder) { if (player.GetComponent <MasterBody>().isAlive) { winnerID = player.GetComponent <MasterBody>().playerID; scoreCounter.updateScore(winnerID, "win"); temporaryRanking[0] = winnerID; //Sets the color of the level transition: transitionColor = playerColors[winnerID + 1]; //changes the color of the transitionscreen to match the color of the winning player. +1 because the first entry is break; } } if (transitionGoing == false) { transitionGoing = true; GameObject tempGameObject = Instantiate(dropInObject, GameObject.FindGameObjectWithTag("Canvas").transform); tempGameObject.GetComponent <DropIn>().Drop(gameState.inbetweenRounds, winnerID + 1); goalPitch = pitchMiddle; musicTransition = musicState.fadeOut; } } }
void FixedUpdate() { //Code for lerping the music. (Making it transition nicely) if (musicTransition != musicState.wait) { if (musicTransition == musicState.fadeIn) { lowPassFilter.cutoffFrequency = SongTransition(lowBottomCutoffFrequency, lowTopCutoffFrequency); highPassFilter.cutoffFrequency = SongTransition(highTopCutoffFrequency, highBottomCutoffFrequency); audioSource.pitch = SongTransition(pitchBottom, goalPitch); } else if (musicTransition == musicState.fadeOut) { lowPassFilter.cutoffFrequency = SongTransition(lowTopCutoffFrequency, lowBottomCutoffFrequency); highPassFilter.cutoffFrequency = SongTransition(highBottomCutoffFrequency, highTopCutoffFrequency); audioSource.pitch = SongTransition(goalPitch, pitchBottom); } else if (musicTransition == musicState.pitchUp) { audioSource.pitch = SongTransition(pitchBottom, goalPitch); } else if (musicTransition == musicState.pitchDown) { audioSource.pitch = SongTransition(goalPitch, pitchBottom); } lerpTimer += Time.deltaTime * lerpScalar; //sets the timer ready for next use. if (lerpTimer >= 1) { musicTransition = musicState.wait; lerpTimer = 0; } } }
public void SongTransition(musicState fadeOutState) { musicTransition = fadeOutState; }