Advertisement
KorolevDmitry123

Untitled

Jul 27th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BulletSound : MonoBehaviour {
  5. public AudioSource source;
  6. private GameObject bullet;
  7. public AudioClip ShootE;
  8. public AudioClip ShootP;
  9. public AudioClip ShootM;
  10. public AudioClip ShootG;
  11. public AudioClip ShootV;
  12. public AudioClip ShootR;
  13. public bool e;
  14. public bool p;
  15. public bool m;
  16. public bool g;
  17. public bool v;
  18. public bool r;
  19. public GameObject _bullet;
  20. void Start()
  21. {
  22. bullet = (GameObject)this.gameObject;
  23. source = GetComponent<AudioSource>();
  24. source.loop = false;
  25. }
  26. void Update()
  27. {
  28. switch ( )
  29. {
  30. case "Enemy":
  31. e = true;
  32. _bullet.gameObject.SetActive(false);
  33. Debug.Log("E");
  34. break;
  35. case "Ring":
  36. r = true;
  37. _bullet.gameObject.SetActive(false);
  38. Debug.Log("R");
  39. break;
  40. case "Metal":
  41. m = true;
  42. _bullet.gameObject.SetActive(false);
  43. Debug.Log("M");
  44. break;
  45. case "Plastic":
  46. p = true;
  47. _bullet.gameObject.SetActive(false);
  48. Debug.Log("P");
  49. break;
  50. case "Glass":
  51. g = true;
  52. _bullet.gameObject.SetActive(false);
  53. Debug.Log("G");
  54. break;
  55. case "Vidic":
  56. v = true;
  57. _bullet.gameObject.SetActive(false);
  58. Debug.Log("V");
  59. break;
  60. }
  61. if (r == true)
  62. {
  63. bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
  64. r = false;
  65. }
  66. if (m == true)
  67. {
  68. bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
  69. m = false;
  70. }
  71. if (p == true)
  72. {
  73. bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
  74. p = false;
  75. }
  76. if (g == true)
  77. {
  78. bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
  79. g = false;
  80. }
  81. if (v == true)
  82. {
  83. bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
  84. v = false;
  85. }
  86. if (e == true)
  87. {
  88. bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
  89. e = false;
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement