TeHArGiS10

Untitled

Aug 9th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #pragma strict
  2.  
  3. var Ammo : int = 7;
  4. var AssaultRifle = false;
  5. var Revolver = false;
  6. var GunScriptAssaultRifle : GameObject;
  7. var GunScriptRevolver : GameObject;
  8. var AmmoText : GameObject;
  9. var GunText : GameObject;
  10.  
  11. function Start () {
  12. Revolver = true;
  13. if(AssaultRifle) {
  14. Ammo = 50;
  15. }
  16. if(Revolver) {
  17. Ammo = 7;
  18. }
  19. }
  20.  
  21. function Update () {
  22. AmmoText.guiText.text = Ammo.ToString();
  23.  
  24. if(Ammo <= 0)
  25. Ammo = 0;
  26.  
  27. if(AssaultRifle) {
  28. GunText.guiText.text = "Assault Rifle";
  29. }
  30. if(Revolver) {
  31. GunText.guiText.text = "Revolver";
  32. }
  33. }
  34.  
  35. function BulletSystem () {
  36. if(AssaultRifle) {
  37. Ammo -= 1;
  38. }
  39. if(Revolver) {
  40. Ammo -= 1;
  41. }
  42. if (Ammo == 0 && (AssaultRifle)) {
  43. audio.Play();
  44. GunScriptAssaultRifle.gameObject.SetActive(false);
  45. yield WaitForSeconds(2);
  46. GunScriptAssaultRifle.gameObject.SetActive(true);
  47. Ammo = 50;
  48. }
  49.  
  50. if (Ammo == 0 && (Revolver)) {
  51. audio.Play();
  52. GunScriptRevolver.gameObject.SetActive(false);
  53. yield WaitForSeconds(2);
  54. GunScriptRevolver.gameObject.SetActive(true);
  55. Ammo = 7;
  56. }
  57.  
  58. if (Ammo <= 50 && AssaultRifle && Input.GetKeyDown(KeyCode.R)) {
  59. audio.Play();
  60. GunScriptAssaultRifle.gameObject.SetActive(false);
  61. yield WaitForSeconds(2);
  62. GunScriptAssaultRifle.gameObject.SetActive(true);
  63. Ammo = 50;
  64. }
  65. if (Ammo <= 7 && Revolver && Input.GetKeyDown(KeyCode.R))) {
  66. audio.Play();
  67. GunScriptAssaultRifle.gameObject.SetActive(false);
  68. yield WaitForSeconds(2);
  69. GunScriptAssaultRifle.gameObject.SetActive(true);
  70. Ammo = 7;
  71. }
  72. }
  73.  
  74. function AssaultRifleYes () {
  75. AssaultRifle = true;
  76. Revolver = false;
  77. Ammo = 50;
  78. }
  79.  
  80. function RevolverYes () {
  81. Ammo = 7;
  82. Revolver = true;
  83. AssaultRifle = false;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment