TaylorUmongusHas

Taylor Umongus Has Unity Player Controller

Jan 14th, 2021
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.21 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class player_movement : MonoBehaviour {
  8.  
  9. public float speed;
  10. public float health;
  11. public bool isOnFirstLevel;
  12. public GameObject pistolBullet;
  13. public GameObject shotgunBullet;
  14. public GameObject shotgunBullet2;
  15. public GameObject bullet;
  16. public GameObject bullet2;
  17. public GameObject bullet3;
  18. public GameObject ionBullet;
  19. public GameObject ionBullet2;
  20. public GameObject ionSounder;
  21. public GameObject grenade;
  22. public GameObject rocket;
  23. public GameObject healthdraw;
  24. public GameObject uziBullet;
  25. public GameObject rifleBullet;
  26. public GameObject explosion;
  27. public GameObject Mexplosion;
  28. public GameObject Trexplosion;
  29. public GameObject explosionSounder;
  30. public GameObject gunModel1;
  31. public GameObject gunModel2;
  32. public GameObject gunModel3;
  33. public GameObject gunRotate3;
  34. public GameObject gunRotate33;
  35. public GameObject gunModel4;
  36. public GameObject gunModel5;
  37. public GameObject gunRotate5;
  38. public GameObject gunModel6;
  39. public GameObject gunModel7;
  40. public GameObject gunModel8;
  41. public GameObject gunModel9;
  42. public float fireDelay;
  43. public bool death;
  44. public float gun1;
  45. public float gun2;
  46. public float gun3;
  47. public float gun4;
  48. public float gun5;
  49. public float gun6;
  50. public float gun7;
  51. public float gun8;
  52. public float gun9;
  53. public float equip;
  54. public int ammo1;
  55. public int ammo2;
  56. public int ammo3;
  57. public int ammo4;
  58. public int ammo5;
  59. public int ammo6;
  60. public int ammo7;
  61. public int ammo8;
  62. public int ammo9;
  63. public Transform shootPlace;
  64. public Transform shootPlace1;
  65. public Transform shootPlace2;
  66. public Transform shootPlace3;
  67. public Transform shootPlace4;
  68. public Transform shootPlace5;
  69. public Transform shootPlace6;
  70. public Transform shootPlace7;
  71. public Transform shootPlace8;
  72. public Transform shootPlace9;
  73. public Transform gunHand;
  74.  
  75. public Rigidbody myBody;
  76.  
  77. public Text healthText;
  78. public Text equipText;
  79. public Text weaponText1;
  80. public Text weaponText2;
  81. public Text weaponText3;
  82. public Text weaponText4;
  83. public Text weaponText5;
  84. public Text weaponText6;
  85. public Text weaponText7;
  86. public Text weaponText8;
  87. public Text weaponText9;
  88. public Text ammoText;
  89.  
  90. private float nextFire;
  91.  
  92. void Start(){
  93. health = 100;
  94. UpdateHealth ();
  95. equipText.text = "Handgun (1)";
  96. Instantiate (gunModel1, gunHand.position, gunHand.rotation);
  97. myBody = GetComponent<Rigidbody>();
  98. if (isOnFirstLevel.Equals(false)){
  99. gun1=PlayerPrefs.GetFloat("gun01", 1.0f);
  100. gun2=PlayerPrefs.GetFloat("gun02", 0.0f);
  101. gun3=PlayerPrefs.GetFloat("gun03", 0.0f);
  102. gun4=PlayerPrefs.GetFloat("gun04", 0.0f);
  103. gun5=PlayerPrefs.GetFloat("gun05", 0.0f);
  104. gun6=PlayerPrefs.GetFloat("gun06", 0.0f);
  105. gun7=PlayerPrefs.GetFloat("gun07", 0.0f);
  106. gun8=PlayerPrefs.GetFloat("gun08", 0.0f);
  107. gun9=PlayerPrefs.GetFloat("gun09", 0.0f);
  108. ammo1=PlayerPrefs.GetInt("ammo01", 34);
  109. ammo2=PlayerPrefs.GetInt("ammo02", 0);
  110. ammo3=PlayerPrefs.GetInt("ammo03", 0);
  111. ammo4=PlayerPrefs.GetInt("ammo04", 0);
  112. ammo5=PlayerPrefs.GetInt("ammo05", 0);
  113. ammo6=PlayerPrefs.GetInt("ammo06", 0);
  114. ammo7=PlayerPrefs.GetInt("ammo07", 0);
  115. ammo8=PlayerPrefs.GetInt("ammo08", 0);
  116. ammo9=PlayerPrefs.GetInt("ammo09", 0);
  117. }
  118. }
  119.  
  120. void FixedUpdate()
  121. {
  122. //myBody.MovePosition(transform.position + (transform.forward * Time.deltaTime * speed));
  123. }
  124.  
  125. void Update()
  126. {
  127.  
  128. float axisX = Input.GetAxis ("Horizontal");
  129. float axisY = Input.GetAxis ("Vertical");
  130.  
  131. if (gun1 == 1){
  132. weaponText1.text = "1";
  133. }
  134. if (gun2 == 1){
  135. weaponText2.text = "2";
  136. }
  137. if (gun3 == 1){
  138. weaponText3.text = "3";
  139. }
  140. if (gun4 == 1){
  141. weaponText4.text = "4";
  142. }
  143. if (gun5 == 1){
  144. weaponText5.text = "5";
  145. }
  146. if (gun6 == 1){
  147. weaponText6.text = "6";
  148. }
  149. if (gun7 == 1){
  150. weaponText7.text = "7";
  151. }
  152. if (gun8 == 1){
  153. weaponText8.text = "8";
  154. }
  155. if (gun9 == 1){
  156. weaponText9.text = "9";
  157. }
  158.  
  159. if (death == false){
  160.  
  161. //transform.Translate (new Vector3 (axisX, axisY) * Time.deltaTime * speed);
  162. myBody.velocity = new Vector3(axisX * speed, axisY * speed);
  163.  
  164. }
  165.  
  166. UpdateHealth ();
  167.  
  168. if (death == false)
  169. {
  170. if (Input.GetKey (KeyCode.Q))
  171. transform.Rotate (Vector3.forward * 150 * Time.deltaTime);
  172.  
  173. if (Input.GetKey (KeyCode.E))
  174. transform.Rotate (-Vector3.forward * 150 * Time.deltaTime);
  175.  
  176. if (Input.GetKey ("1")) {
  177. if (gun1 == 1) {
  178. fireDelay = 0.12f;
  179. equip = 1;
  180. equipText.text = "Handgun (1)";
  181. ammoText.text = "Ammo: Infinity";
  182. Destroy (GameObject.FindWithTag("EquippedGun"));
  183. Instantiate (gunModel1, gunHand.position, gunHand.rotation);
  184. }
  185. }
  186.  
  187. if (Input.GetKey ("2")) {
  188. if (gun2 == 1) {
  189. fireDelay = 0.66f;
  190. equip = 2;
  191. equipText.text = "Shotgun (2)";
  192. ammoText.text = "Ammo: " + ammo2;
  193. Destroy (GameObject.FindWithTag("EquippedGun"));
  194. Instantiate (gunModel2, gunHand.position, gunHand.rotation);
  195. }
  196. }
  197.  
  198. if (Input.GetKey ("3")) {
  199. if (gun3 == 1) {
  200. fireDelay = 0.3f;
  201. equip = 3;
  202. equipText.text = "Grenade Launcher (3)";
  203. ammoText.text = "Ammo: " + ammo3;
  204. Destroy (GameObject.FindWithTag("EquippedGun"));
  205. Instantiate (gunModel3, gunHand.position, gunHand.rotation);
  206. }
  207. }
  208.  
  209. if (Input.GetKey ("4")) {
  210. if (gun4 == 1) {
  211. fireDelay = 0.08f;
  212. equip = 4;
  213. equipText.text = "Minigun (4)";
  214. ammoText.text = "Ammo: " + ammo4;
  215. Destroy (GameObject.FindWithTag("EquippedGun"));
  216. Instantiate (gunModel4, gunHand.position, gunHand.rotation);
  217. }
  218. }
  219.  
  220. if (Input.GetKey ("5")) {
  221. if (gun5 == 1) {
  222. fireDelay = 0.6f;
  223. equip = 5;
  224. equipText.text = "Rocket Launcher (5)";
  225. ammoText.text = "Ammo: " + ammo5;
  226. Destroy (GameObject.FindWithTag("EquippedGun"));
  227. Instantiate (gunModel5, gunHand.position, gunHand.rotation);
  228. }
  229. }
  230. if (Input.GetKey ("6")) {
  231. if (gun6 == 1) {
  232. fireDelay = 0.6f;
  233. equip = 6;
  234. equipText.text = "Ion Cannon (6)";
  235. ammoText.text = "Ammo: " + ammo6;
  236. Destroy (GameObject.FindWithTag("EquippedGun"));
  237. Instantiate (gunModel6, gunHand.position, gunHand.rotation);
  238. }
  239. }
  240. if (Input.GetKey ("7")) {
  241. if (gun7 == 1) {
  242. fireDelay = 0.8f;
  243. equip = 7;
  244. equipText.text = "Plasma Cannon (7)";
  245. ammoText.text = "Ammo: " + ammo7;
  246. Destroy (GameObject.FindWithTag("EquippedGun"));
  247. Instantiate (gunModel7, gunHand.position, gunHand.rotation);
  248. }
  249. }
  250. if (Input.GetKey ("8")) {
  251. if (gun8 == 1) {
  252. fireDelay = 0.05f;
  253. equip = 8;
  254. equipText.text = "Minigun (8)";
  255. }
  256. }
  257. if (Input.GetKey ("9")) {
  258. if (gun9 == 1) {
  259. fireDelay = 0.15f;
  260. equip = 9;
  261. equipText.text = "Death Cannon (9)";
  262. }
  263. }
  264.  
  265.  
  266. if (health <= 0) {
  267. speed = 0;
  268. Invoke("Respawning", 8.0f);
  269. death = true;
  270. }
  271.  
  272. if (Input.GetMouseButtonDown(0) && Time.time > nextFire) {
  273. {
  274.  
  275. if (equip == 1) {
  276. FireHandgun ();
  277. Instantiate (pistolBullet, shootPlace.position, shootPlace.rotation);
  278. nextFire = Time.time + fireDelay;
  279. }
  280. if ((equip == 2) && (ammo2 > 0)) {
  281. FireShotgun ();
  282. ammo2 -= 1;
  283. Instantiate (shotgunBullet, shootPlace.position, shootPlace.rotation);
  284. nextFire = Time.time + fireDelay;
  285. ammoText.text = "Ammo: " + ammo2;
  286. }
  287. if ((equip == 3) && (ammo3 > 0)) {
  288. Instantiate (grenade, shootPlace.position, shootPlace.rotation);
  289. ammo3 -= 1;
  290. Invoke("GrenadeFirstRotation", 0.1f);
  291. Invoke("GrenadeNextRotation", 0.2f);
  292. Invoke("GrenadeLastRotation", 0.3f);
  293. nextFire = Time.time + fireDelay;
  294. Instantiate (uziBullet, shootPlace.position, shootPlace.rotation);
  295. ammoText.text = "Ammo: " + ammo3;
  296. }
  297.  
  298.  
  299. if ((equip == 6) && (ammo6 > 0)) {
  300. FireIon ();
  301. ammo6 -= 1;
  302. Instantiate (ionSounder, shootPlace3.position, shootPlace3.rotation);
  303. nextFire = Time.time + fireDelay;
  304. ammoText.text = "Ammo: " + ammo6;
  305. }
  306.  
  307. if ((equip == 5) && (ammo5 > 0)) {
  308. FireRocket ();
  309. ammo5 -= 1;
  310. nextFire = Time.time + fireDelay;
  311. Instantiate (uziBullet, shootPlace2.position, shootPlace2.rotation);
  312. Destroy (GameObject.FindWithTag("EquippedGun"));
  313. Instantiate (gunRotate5, gunHand.position, gunHand.rotation);
  314. Invoke("RocketRotation", 0.65f);
  315. ammoText.text = "Ammo: " + ammo5;
  316. }
  317.  
  318. if ((equip == 7) && (ammo7 > 0)) {
  319. FirePlasma ();
  320. ammo7 -= 1;
  321. Instantiate (ionSounder, shootPlace3.position, shootPlace3.rotation);
  322. nextFire = Time.time + fireDelay;
  323. ammoText.text = "Ammo: " + ammo7;
  324. }
  325. if (equip == 8) {
  326. Instantiate(bullet3, shootPlace.position, shootPlace.rotation);
  327. Instantiate (rifleBullet, shootPlace.position, shootPlace.rotation);
  328. nextFire = Time.time + fireDelay;
  329. }
  330. if (equip == 9) {
  331. Instantiate (ionBullet, shootPlace.position, shootPlace.rotation);
  332. Instantiate (ionSounder, shootPlace.position, shootPlace.rotation);
  333. nextFire = Time.time + fireDelay;
  334. }
  335. }
  336.  
  337. }
  338.  
  339. if (Input.GetMouseButton(0) && Time.time > nextFire) {
  340. {
  341. nextFire = Time.time + fireDelay;
  342.  
  343. if ((equip == 4) && (ammo4 > 0)) {
  344. MachineGun ();
  345.  
  346. ammo4 -= 1;
  347. Instantiate (rifleBullet, shootPlace3.position, shootPlace3.rotation);
  348. ammoText.text = "Ammo: " + ammo4;
  349. }
  350.  
  351. }
  352.  
  353. }
  354. }
  355.  
  356. }
  357.  
  358. void FireHandgun ()
  359. {
  360. for(var i = 0; i<1; i++){
  361. var pistolbulletRot = shootPlace.transform.rotation;
  362. pistolbulletRot.x += Random.Range(-0.04f, 0.04f);
  363. pistolbulletRot.y += Random.Range(-0.04f, 0.04f);
  364. pistolbulletRot.z += Random.Range(-0.04f, 0.04f);
  365. Instantiate(bullet, shootPlace.transform.position, pistolbulletRot);
  366. }
  367. }
  368.  
  369. void FireShotgun ()
  370. {
  371. for(var i = 0; i<10; i++){
  372. var pelletRot = shootPlace2.transform.rotation;
  373. pelletRot.x += Random.Range(-0.14f, 0.14f);
  374. pelletRot.y += Random.Range(-0.14f, 0.14f);
  375. pelletRot.z += Random.Range(-0.14f, 0.14f);
  376. Instantiate(bullet2, shootPlace2.transform.position, pelletRot);
  377. }
  378. }
  379.  
  380. void MachineGun ()
  381. {
  382. for(var i = 0; i<1; i++){
  383. var machinebulletRot = shootPlace3.transform.rotation;
  384. machinebulletRot.x += Random.Range(-0.06f, 0.06f);
  385. machinebulletRot.y += Random.Range(-0.06f, 0.06f);
  386. machinebulletRot.z += Random.Range(-0.06f, 0.06f);
  387. Instantiate(bullet3, shootPlace3.transform.position, machinebulletRot);
  388. }
  389. }
  390.  
  391. void FireRocket ()
  392. {
  393. for(var i = 0; i<1; i++){
  394. var rocketRot = shootPlace.transform.rotation;
  395. rocketRot.x += Random.Range(-0.02f, 0.02f);
  396. rocketRot.y += Random.Range(-0.02f, 0.02f);
  397. rocketRot.z += Random.Range(-0.02f, 0.02f);
  398. Instantiate(rocket, shootPlace.transform.position, rocketRot);
  399. }
  400. }
  401.  
  402. void FireIon ()
  403. {
  404. for(var i = 0; i<1; i++){
  405. var dicebulletRot = shootPlace.transform.rotation;
  406. dicebulletRot.x += Random.Range(-0.02f, 0.02f);
  407. dicebulletRot.y += Random.Range(-0.02f, 0.02f);
  408. dicebulletRot.z += Random.Range(-0.02f, 0.02f);
  409. Instantiate(ionBullet, shootPlace.transform.position, dicebulletRot);
  410. }
  411. }
  412.  
  413. void FirePlasma ()
  414. {
  415. for(var i = 0; i<1; i++){
  416. var dicebulletRot = shootPlace.transform.rotation;
  417. dicebulletRot.x += Random.Range(-0.02f, 0.02f);
  418. dicebulletRot.y += Random.Range(-0.02f, 0.02f);
  419. dicebulletRot.z += Random.Range(-0.02f, 0.02f);
  420. Instantiate(ionBullet2, shootPlace.transform.position, dicebulletRot);
  421. }
  422. }
  423.  
  424. void GrenadeFirstRotation ()
  425. {
  426. Destroy (GameObject.FindWithTag("EquippedGun"));
  427. Instantiate (gunRotate3, gunHand.position, gunHand.rotation);
  428. }
  429.  
  430. void GrenadeNextRotation ()
  431. {
  432. Destroy (GameObject.FindWithTag("EquippedGun"));
  433. Instantiate (gunRotate33, gunHand.position, gunHand.rotation);
  434. }
  435.  
  436. void GrenadeLastRotation ()
  437. {
  438. Destroy (GameObject.FindWithTag("EquippedGun"));
  439. Instantiate (gunModel3, gunHand.position, gunHand.rotation);
  440. }
  441.  
  442. void RocketRotation ()
  443. {
  444. Destroy (GameObject.FindWithTag("EquippedGun"));
  445. Instantiate (gunModel5, gunHand.position, gunHand.rotation);
  446. }
  447.  
  448. void UpdateHealth ()
  449. {
  450. if (death == false){
  451. healthText.text = "Health: " + health;
  452. }
  453. else
  454. {
  455. healthText.text = "GAME OVER!!!!!!";
  456. }
  457. }
  458.  
  459. void Respawning () {
  460. SceneManager.LoadScene(SceneManager.GetActiveScene().name);
  461. }
  462.  
  463. void OnTriggerEnter(Collider other)
  464. {
  465. if (other.tag == "Gun 2") {
  466. Destroy (other.gameObject);
  467. ammo2 += 6;
  468. gun2 = 1;
  469. if (equip == 2){
  470. ammoText.text = "Ammo: " + ammo2;
  471. }
  472. if (equip < 2) {
  473. fireDelay = 0.66f;
  474. equip = 2;
  475. equipText.text = "Shotgun (2)";
  476. ammoText.text = "Ammo: " + ammo2;
  477. Destroy (GameObject.FindWithTag("EquippedGun"));
  478. Instantiate (gunModel2, gunHand.position, gunHand.rotation);
  479. }
  480. }
  481. if (other.tag == "Gun 3") {
  482. Destroy (other.gameObject);
  483. ammo3 += 6;
  484. gun3 = 1;
  485. if (equip == 3){
  486. ammoText.text = "Ammo: " + ammo3;
  487. }
  488. if (equip < 3) {
  489. fireDelay = 0.3f;
  490. equip = 3;
  491. equipText.text = "Grenade Launcher (3)";
  492. ammoText.text = "Ammo: " + ammo3;
  493. Destroy (GameObject.FindWithTag("EquippedGun"));
  494. Instantiate (gunModel3, gunHand.position, gunHand.rotation);
  495. }
  496. }
  497. if (other.tag == "Gun 4")
  498. {
  499. Destroy(other.gameObject);
  500. ammo4 += 100;
  501. gun4 = 1;
  502. if (equip == 4){
  503. ammoText.text = "Ammo: " + ammo4;
  504. }
  505. if (equip < 4) {
  506. fireDelay = 0.08f;
  507. equip = 4;
  508. equipText.text = "Machine Gun (4)";
  509. ammoText.text = "Ammo: " + ammo4;
  510. Destroy (GameObject.FindWithTag("EquippedGun"));
  511. Instantiate (gunModel4, gunHand.position, gunHand.rotation);
  512. }
  513. }
  514. if (other.tag == "Gun 5")
  515. {
  516. Destroy(other.gameObject);
  517. ammo5 += 1;
  518. gun5 = 1;
  519. if (equip == 5){
  520. ammoText.text = "Ammo: " + ammo5;
  521. }
  522. if (equip < 5) {
  523. fireDelay = 0.6f;
  524. equip = 5;
  525. equipText.text = "Rocket Launcher (5)";
  526. ammoText.text = "Ammo: " + ammo5;
  527. Destroy (GameObject.FindWithTag("EquippedGun"));
  528. Instantiate (gunModel5, gunHand.position, gunHand.rotation);
  529. }
  530. }
  531. if (other.tag == "Gun 6")
  532. {
  533. Destroy(other.gameObject);
  534. gun6 = 1;
  535. if (equip == 6){
  536. ammoText.text = "Ammo: " + ammo6;
  537. }
  538. if (equip < 6) {
  539. fireDelay = 0.6f;
  540. equip = 6;
  541. equipText.text = "Ion Cannon (6)";
  542. ammoText.text = "Ammo: " + ammo6;
  543. Destroy (GameObject.FindWithTag("EquippedGun"));
  544. Instantiate (gunModel6, gunHand.position, gunHand.rotation);
  545. }
  546. }
  547. if (other.tag == "Gun 7")
  548. {
  549. Destroy(other.gameObject);
  550. gun7 = 1;
  551. if (equip == 7){
  552. ammoText.text = "Ammo: " + ammo7;
  553. }
  554. if (equip < 7) {
  555. fireDelay = 0.8f;
  556. equip = 7;
  557. equipText.text = "Plasma Cannon (7)";
  558. ammoText.text = "Ammo: " + ammo7;
  559. Destroy (GameObject.FindWithTag("EquippedGun"));
  560. Instantiate (gunModel7, gunHand.position, gunHand.rotation);
  561. }
  562. }
  563. if (other.tag == "Gun 8")
  564. {
  565. Destroy(other.gameObject);
  566. gun8 = 1;
  567. }
  568. if (other.tag == "Shell") {
  569. Destroy (other.gameObject);
  570. ammo2 += 1;
  571. if (equip == 2){
  572. ammoText.text = "Ammo: " + ammo2;
  573. }
  574. }
  575. if (other.tag == "Shells") {
  576. Destroy (other.gameObject);
  577. ammo2 += 4;
  578. if (equip == 2){
  579. ammoText.text = "Ammo: " + ammo2;
  580. }
  581. }
  582. if (other.tag == "Grenade") {
  583. Destroy (other.gameObject);
  584. ammo3 += 1;
  585. if (equip == 3){
  586. ammoText.text = "Ammo: " + ammo3;
  587. }
  588. }
  589. if (other.tag == "Grenades") {
  590. Destroy (other.gameObject);
  591. ammo3 += 4;
  592. if (equip == 3){
  593. ammoText.text = "Ammo: " + ammo3;
  594. }
  595. }
  596. if (other.tag == "Ammo Box") {
  597. Destroy (other.gameObject);
  598. ammo4 += 100;
  599. if (equip == 4){
  600. ammoText.text = "Ammo: " + ammo4;
  601. }
  602. }
  603. if (other.tag == "Rockets") {
  604. Destroy (other.gameObject);
  605. ammo5 += 1;
  606. if (equip == 5){
  607. ammoText.text = "Ammo: " + ammo5;
  608. }
  609. }
  610. if (other.tag == "Batteries") {
  611. Destroy (other.gameObject);
  612. ammo6 += 4;
  613. if (equip == 6){
  614. ammoText.text = "Ammo: " + ammo6;
  615. }
  616. }
  617. if (other.tag == "Plasma Shells") {
  618. Destroy (other.gameObject);
  619. ammo7 += 3;
  620. if (equip == 7){
  621. ammoText.text = "Ammo: " + ammo7;
  622. }
  623. }
  624. if (other.tag == "Spider Attack") {
  625. health -= 2;
  626. Instantiate (Trexplosion, other.transform.position, other.transform.rotation);
  627. }
  628. if (other.tag == "Cockroach Attack") {
  629. health -= 4;
  630. Instantiate (Trexplosion, other.transform.position, other.transform.rotation);
  631. }
  632. if (other.tag == "Beetle Attack") {
  633. health -= 5;
  634. Instantiate (Trexplosion, other.transform.position, other.transform.rotation);
  635. }
  636. if (other.tag == "EnemyPulse") {
  637. health -= 4;
  638. Instantiate (Trexplosion, other.transform.position, other.transform.rotation);
  639. Destroy(other.gameObject);
  640. }
  641. if (other.tag == "Tarantula Attack") {
  642. Instantiate (explosion, other.transform.position, other.transform.rotation);
  643. Instantiate (explosionSounder, other.transform.position, other.transform.rotation);
  644. health -= 20;
  645. }
  646. if (other.tag == "Mealworm Attack") {
  647. Instantiate (Mexplosion, other.transform.position, other.transform.rotation);
  648. Instantiate (shotgunBullet, other.transform.position, other.transform.rotation);
  649. health -= 14;
  650. }
  651. if (other.tag == "EnemyRocket") {
  652. Destroy (other.gameObject);
  653. }
  654. if (other.tag == "EnemyExplosion") {
  655. health -= 7;
  656. }
  657. if (other.tag == "Tarantula Explosion") {
  658. health -= 20;
  659. }
  660. if (other.tag == "Mealworm Explosion") {
  661. health -= 14;
  662. }
  663. if (other.tag == "Barrier") {
  664. Destroy (other.gameObject);
  665. }
  666. if (GameObject.FindGameObjectsWithTag("Boss").Length < 1)
  667. {
  668. if (other.tag == "StartGame") {
  669. health = 100;
  670. SceneManager.LoadScene ("Mission 1");
  671. }
  672. if (other.tag == "NextLevel") {
  673. CompleteLevel();
  674. health = 100;
  675. SceneManager.LoadScene ("Mission 2");
  676. }
  677. if (other.tag == "NextLevel2") {
  678. CompleteLevel();
  679. health = 100;
  680. SceneManager.LoadScene ("Mission 3");
  681. }
  682. if (other.tag == "NextLevel3") {
  683. CompleteLevel();
  684. SceneManager.LoadScene("Mission 4");
  685. health = 100;
  686. }
  687. if (other.tag == "NextLevel4") {
  688. CompleteLevel();
  689. SceneManager.LoadScene("Mission 5");
  690. health = 100;
  691. }
  692. if (other.tag == "NextLevel5") {
  693. CompleteLevel();
  694. SceneManager.LoadScene("Mission 6");
  695. health = 100;
  696. }
  697. if (other.tag == "NextLevel6") {
  698. CompleteLevel();
  699. SceneManager.LoadScene("Mission 7");
  700. health = 100;
  701. }
  702. if (other.tag == "NextLevel7") {
  703. CompleteLevel();
  704. SceneManager.LoadScene("Mission 8");
  705. health = 100;
  706. }
  707. if (other.tag == "NextLevel8") {
  708. CompleteLevel();
  709. SceneManager.LoadScene("Mission 9");
  710. health = 100;
  711. }
  712. if (other.tag == "NextLevel9") {
  713. CompleteLevel();
  714. SceneManager.LoadScene("Mission 10");
  715. health = 100;
  716. }
  717. }
  718.  
  719. }
  720.  
  721. void CompleteLevel(){
  722. PlayerPrefs.SetFloat("gun01",gun1);
  723. PlayerPrefs.SetFloat("gun02",gun2);
  724. PlayerPrefs.SetFloat("gun03",gun3);
  725. PlayerPrefs.SetFloat("gun04",gun4);
  726. PlayerPrefs.SetFloat("gun05",gun5);
  727. PlayerPrefs.SetFloat("gun06",gun6);
  728. PlayerPrefs.SetFloat("gun07",gun7);
  729. PlayerPrefs.SetFloat("gun08",gun8);
  730. PlayerPrefs.SetFloat("gun09",gun9);
  731. PlayerPrefs.SetInt("ammo01",ammo1);
  732. PlayerPrefs.SetInt("ammo02",ammo2);
  733. PlayerPrefs.SetInt("ammo03",ammo3);
  734. PlayerPrefs.SetInt("ammo04",ammo4);
  735. PlayerPrefs.SetInt("ammo05",ammo5);
  736. PlayerPrefs.SetInt("ammo06",ammo6);
  737. PlayerPrefs.SetInt("ammo07",ammo7);
  738. PlayerPrefs.SetInt("ammo08",ammo8);
  739. PlayerPrefs.SetInt("ammo09",ammo9);
  740. PlayerPrefs.Save();
  741. }
  742.  
  743. }
Advertisement
Add Comment
Please, Sign In to add comment