Guest User

Untitled

a guest
Sep 20th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.49 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Metal : MonoBehaviour
  6. {
  7. public GameObject sound;
  8. public GameObject black;
  9. public GameObject antiSound;
  10.  
  11. public GameObject na;
  12. public GameObject parts;
  13. public GameObject bags;
  14. public GameObject seat;
  15. public GameObject Wheel;
  16. public GameObject shoes;
  17.  
  18. public bool canDiveBike;
  19. public float bikeStartTime = 10f;
  20. public float bikeTimer = 0;
  21. public int item;
  22.  
  23. void Update()
  24. {
  25. if (canDiveBike == false)
  26. {
  27. bikeTimer -= Time.deltaTime;
  28. Debug.Log(bikeTimer);
  29. if (bikeTimer <= 0)
  30. {
  31. canDiveBike = true;
  32. return;
  33. }
  34. sound.SetActive(false);
  35. }
  36. }
  37. void Start()
  38. {
  39. bikeTimer = bikeStartTime;
  40. canDiveBike = true;
  41. }
  42.  
  43. void OnTriggerEnter(Collider other)
  44. {
  45. if (other.gameObject.tag == "stuffBike")
  46. {
  47. if (canDiveBike == true)
  48. {
  49. sound.SetActive(true);
  50. antiSound.SetActive(false);
  51. }
  52. else
  53. {
  54. sound.SetActive(false);
  55. antiSound.SetActive(true);
  56. }
  57. }
  58. }
  59.  
  60. void OnTriggerStay(Collider other)
  61. {
  62. if (other.gameObject.tag == "stuffBike") {
  63.  
  64. if (canDiveBike == true)
  65. {
  66. sound.SetActive(true);
  67. antiSound.SetActive(false);
  68. }
  69.  
  70. if (Input.GetKeyDown(KeyCode.E))
  71. {
  72. digBike();
  73. }
  74. }
  75. }
  76.  
  77. void OnTriggerExit(Collider other)
  78. {
  79. if (other.gameObject.tag == "stuffBike")
  80. {
  81. StopAllCoroutines();
  82. antiSound.SetActive(false);
  83. sound.SetActive(false);
  84. black.SetActive(false);
  85. na.SetActive(false);
  86. parts.SetActive(false);
  87. bags.SetActive(false);
  88. seat.SetActive(false);
  89. Wheel.SetActive(false);
  90. shoes.SetActive(false);
  91. }
  92. }
  93.  
  94. void digBike()
  95. {
  96. StartCoroutine(DigItBike());
  97. }
  98.  
  99. IEnumerator DigItBike()
  100. {
  101. if (canDiveBike == true) {
  102. float time = 0;
  103. float randy = Random.Range(2.5f, 17.5f);
  104. while (time < randy)
  105. {
  106. black.SetActive(true);
  107. time += Time.deltaTime;
  108. yield return null;
  109. }
  110.  
  111. if (randy < 5) {
  112. Debug.Log("Nothing");
  113. item = 0;
  114. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 0);
  115. }
  116.  
  117. else if (randy < 7.5)
  118. {
  119. Debug.Log("Just some parts");
  120. PlayerPrefs.SetInt("parts", PlayerPrefs.GetInt("parts") + 1);
  121. item = 1;
  122. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 2);
  123. }
  124. else if (randy < 10)
  125. {
  126. Debug.Log("saddle bags");
  127. PlayerPrefs.SetInt("bags", PlayerPrefs.GetInt("bags") + 1);
  128. item = 2;
  129. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
  130. }
  131. else if (randy < 12.5)
  132. {
  133. Debug.Log("Bike seat");
  134. PlayerPrefs.SetInt("seat", PlayerPrefs.GetInt("seat") + 1);
  135. item = 3;
  136. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
  137. }
  138. else if (randy < 15)
  139. {
  140. Debug.Log("A Wheel");
  141. PlayerPrefs.SetInt("Wheel", PlayerPrefs.GetInt("Wheel") + 1);
  142. item = 4;
  143. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
  144. }
  145. else if (randy < 17.5)
  146. {
  147. Debug.Log("Biking Shoes!");
  148. PlayerPrefs.SetInt("Shoes", PlayerPrefs.GetInt("Shoes") + 1);
  149. item = 5;
  150. PlayerPrefs.SetInt("points", PlayerPrefs.GetInt("points") + 5);
  151. }
  152.  
  153. bikeTimer = bikeStartTime;
  154. canDiveBike = false;
  155. black.SetActive(false);
  156. StopAllCoroutines();
  157. StartCoroutine(bikeShowDig());
  158. }else{
  159. StopAllCoroutines();
  160. }
  161. }
  162.  
  163. IEnumerator bikeShowDig()
  164. {
  165. float time1 = 0;
  166. float randy1 = 2.0f;
  167. while (time1 < randy1)
  168. {
  169. if (item == 0)
  170. {
  171. na.SetActive(true);
  172. parts.SetActive(false);
  173. bags.SetActive(false);
  174. seat.SetActive(false);
  175. Wheel.SetActive(false);
  176. shoes.SetActive(false);
  177. }
  178. else if (item == 1)
  179. {
  180. na.SetActive(false);
  181. parts.SetActive(true);
  182. bags.SetActive(false);
  183. seat.SetActive(false);
  184. Wheel.SetActive(false);
  185. shoes.SetActive(false);
  186.  
  187. } else if (item == 2)
  188. {
  189. na.SetActive(false);
  190. parts.SetActive(false);
  191. bags.SetActive(true);
  192. seat.SetActive(false);
  193. Wheel.SetActive(false);
  194. shoes.SetActive(false);
  195. }
  196. else if (item == 3)
  197. {
  198. na.SetActive(false);
  199. parts.SetActive(false);
  200. bags.SetActive(false);
  201. seat.SetActive(true);
  202. Wheel.SetActive(false);
  203. shoes.SetActive(false);
  204. }
  205. else if (item == 4)
  206. {
  207. na.SetActive(false);
  208. parts.SetActive(false);
  209. bags.SetActive(false);
  210. seat.SetActive(false);
  211. Wheel.SetActive(true);
  212. shoes.SetActive(false);
  213. }
  214. else if (item == 5)
  215. {
  216. na.SetActive(false);
  217. parts.SetActive(false);
  218. bags.SetActive(false);
  219. seat.SetActive(false);
  220. Wheel.SetActive(false);
  221. shoes.SetActive(true);
  222. }
  223. time1 += Time.deltaTime;
  224. yield return null;
  225. }
  226. na.SetActive(false);
  227. parts.SetActive(false);
  228. bags.SetActive(false);
  229. seat.SetActive(false);
  230. Wheel.SetActive(false);
  231. shoes.SetActive(false);
  232. antiSound.SetActive(true);
  233. }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment