Advertisement
jasonjohn

WeaponManager

Jul 13th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class WeaponManager : MonoBehaviour {
  2. public List<Gun> Weapons = new List<Gun>();
  3. public int CurWeapon;
  4. public static WeaponManager Instance;
  5. // Use this for initialization
  6. void Start () {
  7. Instance = this;
  8.  
  9. }
  10.  
  11. // Update is called once per frame
  12. void Update () {
  13. CurWeapon = GUIManager.Instance.CurWeapon;
  14.  
  15. }
  16.  
  17. public void Spawn()
  18. {
  19. CurWeapon = GUIManager.Instance.CurWeapon;
  20. transform.root.GetComponent<Character> ().Server_GetGun (Weapons [CurWeapon].Name);
  21. ApplyWeapon();
  22.  
  23.  
  24. }
  25.  
  26. public void ApplyWeapon()
  27. {
  28. foreach (Gun gu in Weapons)
  29. {
  30. if(gu == Weapons[CurWeapon])
  31. {
  32. gu.gameObject.SetActive(true);
  33. }
  34. else
  35. {
  36. gu.gameObject.SetActive(false);
  37. }
  38. }
  39. }
  40.  
  41. public static Gun FindWeapon(string Name)
  42. {
  43. foreach (Gun Gu in Instance.Weapons)
  44. {
  45. if(Name == Gu.Name)
  46. return Gu;
  47. }
  48. return null;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement