private PlaySound SpawnBlackKey(int setID, int soundKeyID, PlaySound.SoundKey targetSoundKey) { float zOffset = offset * setID + soundKeyID * 0.5f; Vector3 position = new Vector3(0, 0.3f, zOffset); GameObject blackKey = Instantiate(BlackKeyPrefab, position, Quaternion.identity, transform); PlaySound playSound = blackKey.GetComponentInChildren <PlaySound>(); playSound.pitchOffset = setID; playSound.soundKey = targetSoundKey; playSound.LoadAudioClip(); return(playSound); }
private void SpawnSets(int pitch) { foreach (int value in Enum.GetValues(typeof(PlaySound.SoundKey))) { PlaySound.SoundKey targetSoundKey = (PlaySound.SoundKey)value; switch (targetSoundKey) { case PlaySound.SoundKey.C: SpawnWhiteKey(pitch, 0, targetSoundKey); break; case PlaySound.SoundKey.D: SpawnWhiteKey(pitch, 1, targetSoundKey); break; case PlaySound.SoundKey.E: SpawnWhiteKey(pitch, 2, targetSoundKey); break; case PlaySound.SoundKey.F: SpawnWhiteKey(pitch, 3, targetSoundKey); break; case PlaySound.SoundKey.G: SpawnWhiteKey(pitch, 4, targetSoundKey); break; case PlaySound.SoundKey.A: SpawnWhiteKey(pitch, 5, targetSoundKey); break; case PlaySound.SoundKey.B: SpawnWhiteKey(pitch, 6, targetSoundKey); break; case PlaySound.SoundKey.Db: SpawnBlackKey(pitch, 1, targetSoundKey); break; case PlaySound.SoundKey.Eb: SpawnBlackKey(pitch, 3, targetSoundKey); break; case PlaySound.SoundKey.Gb: SpawnBlackKey(pitch, 7, targetSoundKey); break; case PlaySound.SoundKey.Ab: SpawnBlackKey(pitch, 9, targetSoundKey); break; case PlaySound.SoundKey.Bb: SpawnBlackKey(pitch, 11, targetSoundKey); break; default: break; } UpdateActiveKeys(); } }