using System; using System.Diagnostics; namespace SpaceInvaders { public class PlayAlienSounds : Command { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- private int sound; //------------------------------------------------------------------- // CONSTRUCTION //------------------------------------------------------------------- public PlayAlienSounds() { this.sound = 0; } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public override void Execute(float deltaTime) { GameObject pGrid = ObjectNodeMan.FindObject(GameObject.ObjectName.AlienGrid); switch (sound) { case 0: SoundManager.Play("fastinvader1.wav"); break; case 1: SoundManager.Play("fastinvader2.wav"); break; case 2: SoundManager.Play("fastinvader3.wav"); break; case 3: SoundManager.Play("fastinvader4.wav"); break; default: Debug.Assert(false); //scream at me break; } if(this.sound == 3) { this.sound = 0; } else { this.sound++; } if (ForwardIterator.GetChild(pGrid) != null) { float delta = ((State_Play)GameContext.GetCurrState()).GetCurrDelta(); TimerEventMan.AddEvent(TimerEvent.EventName.PlayGridSound, this, delta); } } } // end class } // end namespace