//************************************************************************** // // Public // //************************************************************************** override public void PerformAction() { if (blocks.Count == 0) { return; } BaseBlock block = blocks[blocks.Count - 1]; blocks.Remove(block); int targetY = fieldData.TraceVertical(xPosition, yPosition + blocks.Count - 3, true); if (targetY >= 0) { fieldData.FillPoint(xPosition, targetY); currentCollisionData.geometry[0, blocks.Count] = 0; SendMessageUpwards(BlockController.CALLBACK_HANDLE_SHOT, block); block.xPosition = xPosition; block.yPosition = targetY; } if (blocks.Count == 0) { NotifyFigureLanded(); } else { blocks[blocks.Count - 1].SetupActiveAppearance(); } SoundPlaybackController sound = SoundPlayer.Instance.PlaySound(SoundConst.SHOT); sound.Volume = 0.6f; }
//-------------------------------------------------------------------------- private void StopSpeeding() { if (speedingSound) { speedingSound.AnimateFade(0.5f, true); speedingSound = null; } }
private void PlaySoundRotate() { string soundName = currentRotationIndex == 0 ? SoundConst.ROTATE1 : SoundConst.ROTATE2; SoundPlaybackController sound = SoundPlayer.Instance.PlaySound(soundName); sound.Volume = 0.80f; currentRotationIndex = (currentRotationIndex + 1) % 2; }
//-------------------------------------------------------------------------- private void PlayFastMusic() { if (backgroundMusicSlow) { backgroundMusicSlow.Pause(); } backgroundMusicFast = SoundPlayer.Instance.PlaySound(SoundConst.BACKGROUND_MUSIC_RUSH); backgroundMusicFast.Volume = 1.0f; backgroundMusicFast.Loop(); }
//-------------------------------------------------------------------------- public void Play() { if (Time.time - lastPlayTime > resetDuration) { currentIndex = startIndex; } currentIndex = Mathf.Max(Mathf.Min(endIndex, currentIndex), startIndex); string soundToPlay = System.String.Format("{1}{0:00}", currentIndex, soundName); SoundPlaybackController sound = SoundPlayer.Instance.PlaySound(soundToPlay); sound.Volume = volume; currentIndex++; lastPlayTime = Time.time; }
//-------------------------------------------------------------------------- private void PlaySlowMusic() { if (!backgroundMusicSlow) { backgroundMusicSlow = SoundPlayer.Instance.PlaySound(SoundConst.BACKGROUND_MUSIC_SLOW); backgroundMusicSlow.Volume = 1.0f; backgroundMusicSlow.Loop(); } else { if (backgroundMusicFast) { backgroundMusicFast.AnimateFade(0.3f, true); backgroundMusicFast = null; } backgroundMusicSlow.Play(); } }
//************************************************************************** // Playback public SoundPlaybackController PlaySound(AudioClip clip) { GameObject go = new GameObject("Sound [" + clip.name + "]"); go.transform.parent = transform; go.transform.position = Vector3.zero; AudioSource source = go.AddComponent <AudioSource>(); source.clip = clip; source.Play(); SoundPlaybackController controller = go.AddComponent <SoundPlaybackController>(); controller.DieAfterTime(Time.realtimeSinceStartup + clip.length); return(controller); }
//-------------------------------------------------------------------------- private void PlaySpeeding() { StopSpeeding(); speedingSound = SoundPlayer.Instance.PlaySound(SoundConst.SPEEDING); speedingSound.Volume = 0.70f; }
//-------------------------------------------------------------------------- private void PlaySoundMoveRight() { SoundPlaybackController sound = SoundPlayer.Instance.PlaySound(SoundConst.MOVE_RIGHT); sound.Volume = 0.55f; }