Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6.  
  7. public class RayCastingScript : MonoBehaviour
  8. {
  9. public GameObject bulletHole;
  10. public int zombiesLeft = 15;
  11. public GameObject zombieValue;
  12.  
  13. void Update()
  14. {
  15. RaycastHit objectHit;
  16.  
  17. if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out objectHit))
  18. {
  19. if (Input.GetButtonDown("Fire1"))
  20. {
  21.  
  22. if (objectHit.collider.gameObject.tag == "FloppingZombie")
  23. {
  24. iTween.RotateTo(objectHit.collider.gameObject.transform.parent.gameObject, iTween.Hash(
  25. "x", 90f,
  26. "time", 0.5f,
  27. "islocal", true
  28. ));
  29. iTween.ColorTo(objectHit.collider.gameObject, new Color(1, 0, 0), 0.1f);
  30. objectHit.collider.gameObject.tag = "IsDead";
  31. zombiesLeft = zombiesLeft - 1;
  32. zombieValue.GetComponent<Text>().text = zombiesLeft.ToString();
  33. }
  34.  
  35. if (objectHit.collider.gameObject.tag == "SpinningZombie")
  36. {
  37. iTween.RotateBy(objectHit.collider.gameObject.transform.parent.gameObject, iTween.Hash(
  38. "y", 3f,
  39. "time", 1f,
  40. "islocal", true
  41. ));
  42. iTween.ColorTo(objectHit.collider.gameObject, new Color(1, 0, 0), 0.1f);
  43. objectHit.collider.gameObject.tag = "IsDead";
  44. zombiesLeft = zombiesLeft - 1;
  45. zombieValue.GetComponent<Text>().text = zombiesLeft.ToString();
  46. }
  47.  
  48. if (objectHit.collider.gameObject.tag == "InnocentChild")
  49. {
  50. objectHit.collider.gameObject.tag = "IsDead";
  51. AudioSource.
  52. SceneManager.LoadScene("GameOver");
  53. }
  54.  
  55. GameObject bulletHoleClone;
  56. bulletHoleClone = Instantiate(bulletHole, objectHit.point, Quaternion.LookRotation(objectHit.normal));
  57. bulletHoleClone.transform.parent = objectHit.transform;
  58.  
  59. //StartCoroutine(GunEffects());
  60. }
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement