Skip to content

Instantly share code, notes, and snippets.

@DomDomHaas
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DomDomHaas/c61d08bba0d75d84a4da to your computer and use it in GitHub Desktop.
Save DomDomHaas/c61d08bba0d75d84a4da to your computer and use it in GitHub Desktop.
MasterAudio get PlayListSource change pitch
private AudioSource playlistSource;
playlistCont = PlayListController.Instance;
playlistSource = playlistCont.CurrentPlaylistSource;
if (usePitchAddtion) {
checkAddPitch ();
} else {
checkPitchChange ();
}
private void checkAddPitch ()
{
float newPitch = this.pitchNormal;
if (!this.whiteSwarm.iAmDead && !this.blackSwarm.iAmDead) {
if (this.whiteSwarm.isInStream) {
if (this.whiteSwarm.hitOwnStream) {
newPitch += this.addOwnStream;
} else {
newPitch += this.addDmgStream;
}
}
if (this.blackSwarm.isInStream) {
if (this.blackSwarm.hitOwnStream) {
newPitch += this.addOwnStream;
} else {
newPitch += this.addDmgStream;
}
}
//Debug.Log (" newPitch: " + newPitch);
playlistSource.pitch = newPitch;
}
}
private void checkPitchChange ()
{
if (!this.whiteSwarm.iAmDead && !this.blackSwarm.iAmDead) {
bool whiteInWrongStream = (this.whiteSwarm.isInStream && !this.whiteSwarm.hitOwnStream);
bool blackInWrongStream = (this.blackSwarm.isInStream && !this.blackSwarm.hitOwnStream);
if (this.whiteSwarm.isInStream || this.blackSwarm.isInStream) {
if (whiteInWrongStream || blackInWrongStream) {
playlistSource.pitch = this.pitchDmgStream;
} else {
playlistSource.pitch = this.pitchOwnStream;
}
} else {
playlistSource.pitch = this.pitchNormal;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment