package Services.Sounds.WeaponSoundObjects { import flash.media.SoundChannel; import flash.media.Sound; import Gameplay.WeaponIndex; /** * ... * @author */ public class UserChannels { protected var Username : String; protected var weaponIndex : int; protected var weapon : WeaponSound; protected var effectChannel : SoundChannel = new SoundChannel(); public function UserChannels(name : String, weapon : int) { Username = name; weaponIndex = weapon; assignWeapon(weaponIndex); } public function playCommand(args : String) : void { var commands : Array = args.split("|"); /* if (!String(commands[0]).match(Username)) { return; } */ if (String(commands[1]) == "0") { weapon.playFire(); } else if (String(commands[1]) == "1") { effectChannel.stop(); effectChannel = weapon.getReload().play(); } else if (String(commands[1]) == "2") { weaponIndex = parseInt(String(commands[2])); assignWeapon(weaponIndex); effectChannel.stop(); effectChannel = weapon.getSwitch().play(); } else if (String(commands[1]) == "3") { weapon.playEmpty(); } } private function assignWeapon(index:int) : void { switch(weaponIndex) { case WeaponIndex.PISTOL: weapon = new glock(); break; case WeaponIndex.MAGNUM: weapon = new deagle(); break; case WeaponIndex.MP5: weapon = new mp5(); break; case WeaponIndex.MAC10: weapon = new mac10(); break; case WeaponIndex.SHOTGUN: weapon = new m3(); break; case WeaponIndex.AUTOSHOTGUN: weapon = new xm1014(); break; case WeaponIndex.M4A1: weapon = new m4a1(); break; case WeaponIndex.AK47: weapon = new ak47(); break; case WeaponIndex.SNIPERRIFLE: weapon = new scout(); break; case WeaponIndex.MAGNUMSNIPER: weapon = new awp(); break; case WeaponIndex.MACHINEGUN: weapon = new m249(); break; default : weapon = new glock(); } } } }