Advertisement
Guest User

Untitled

a guest
Jun 19th, 2012
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //--------Weapon Manager---------//
  2. //--------Kevin Soares--------//
  3. //--------Outbreak-----------//
  4.  
  5. var weapons : GameObject[];
  6. var selectedWeapon : int;
  7.  
  8. function Update ()
  9. {
  10.     SwitchUpdates();
  11. }
  12.  
  13. function SelectWeapon (index : int) {
  14. for (var i : int=0 ;i<weapons.length; i++)  {
  15.     if (i != index){
  16.         weapons[i].gameObject.SetActiveRecursively(false);
  17.  
  18.     }else{
  19.         weapons[i].gameObject.SetActiveRecursively(true);
  20.  
  21.     }
  22.  
  23. }
  24. }
  25.  
  26. function SwitchUpdates()
  27. {
  28.     //Gun
  29.     if (Input.GetKeyDown("1") && weapons.length >= 1)
  30.     {
  31.             SelectWeapon(0);
  32.             selectedWeapon = 0;
  33.     }
  34.     //Pistol
  35.     else if (Input.GetKeyDown("2") && weapons.length >= 2)
  36.     {
  37.         SelectWeapon(1);
  38.         selectedWeapon = 1;
  39.         isPistol = true;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement