Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class RayCastingScript : MonoBehaviour
- {
- public GameObject bulletHole;
- public int zombiesLeft = 15;
- public GameObject zombieValue;
- void Update()
- {
- RaycastHit objectHit;
- if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out objectHit))
- {
- if (Input.GetButtonDown("Fire1"))
- {
- if (objectHit.collider.gameObject.tag == "FloppingZombie")
- {
- iTween.RotateTo(objectHit.collider.gameObject.transform.parent.gameObject, iTween.Hash(
- "x", 90f,
- "time", 0.5f,
- "islocal", true
- ));
- iTween.ColorTo(objectHit.collider.gameObject, new Color(1, 0, 0), 0.1f);
- objectHit.collider.gameObject.tag = "IsDead";
- zombiesLeft = zombiesLeft - 1;
- zombieValue.GetComponent<Text>().text = zombiesLeft.ToString();
- }
- if (objectHit.collider.gameObject.tag == "SpinningZombie")
- {
- iTween.RotateBy(objectHit.collider.gameObject.transform.parent.gameObject, iTween.Hash(
- "y", 3f,
- "time", 1f,
- "islocal", true
- ));
- iTween.ColorTo(objectHit.collider.gameObject, new Color(1, 0, 0), 0.1f);
- objectHit.collider.gameObject.tag = "IsDead";
- zombiesLeft = zombiesLeft - 1;
- zombieValue.GetComponent<Text>().text = zombiesLeft.ToString();
- }
- if (objectHit.collider.gameObject.tag == "InnocentChild")
- {
- objectHit.collider.gameObject.tag = "IsDead";
- AudioSource.
- SceneManager.LoadScene("GameOver");
- }
- GameObject bulletHoleClone;
- bulletHoleClone = Instantiate(bulletHole, objectHit.point, Quaternion.LookRotation(objectHit.normal));
- bulletHoleClone.transform.parent = objectHit.transform;
- //StartCoroutine(GunEffects());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement