Advertisement
Guest User

Unity

a guest
Apr 8th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class FireBall : MonoBehaviour {
  7.  
  8.     //private bool isReloaded = true;
  9.     public Image healthBar;
  10.     public Image healthBar2;
  11.     public GameObject Mummy;
  12.     public Animator anim;
  13.     public Animator anim2;
  14.     public Image cell;
  15.     public Sprite key;
  16.     public GameObject gate;
  17.     public GameObject[] door = new GameObject[4];
  18.  
  19.     void Start(){
  20.         healthBar = GameObject.Find("ZbBar").GetComponent<Image>();
  21.         healthBar2 = GameObject.Find("ZbBar2").GetComponent<Image>();
  22.         Mummy = GameObject.Find("Mummy");
  23.         anim = Mummy.GetComponent<Animator>();
  24.         anim2 = GameObject.Find("Boss").GetComponent<Animator>();
  25.         cell = GameObject.Find("Item5").GetComponent<Image>();
  26.         gate = GameObject.Find("Gate 4");
  27.     }
  28.  
  29.     void FixedUpdate () {
  30.         // if(isReloaded == true){
  31.             GetComponent<Rigidbody>().velocity = GameObject.Find("Player").transform.rotation * Vector3.forward * 5f;
  32.             //isReloaded = false;
  33.             //StartCoroutine("Reload");
  34.         // }
  35.     }
  36.  
  37.     void OnTriggerEnter(Collider other){
  38.         if(other.gameObject.name == "Mummy"){
  39.             Destroy(gameObject);
  40.             healthBar.fillAmount -= 0.07f;
  41.             if(healthBar.fillAmount <= 0){
  42.                 //Destroy(Mummy);
  43.                 //Debug.Log("DEATH");
  44.                 anim.SetBool("Die", true);
  45.                 PlayerPrefs.SetString("IsDeath", "true");
  46.  
  47.             }
  48.         }
  49.         if(other.gameObject.name == "Boss" && other.gameObject.name != "ww_shield"){
  50.             Destroy(gameObject);
  51.             healthBar2.fillAmount -= 0.03f;
  52.             if(healthBar2.fillAmount <= 0){
  53.                 //Destroy(Mummy);
  54.                 //Debug.Log("DEATH");
  55.                 cell.sprite = key;
  56.                 Color c = cell.color;
  57.                 c.a = 255f;
  58.                 cell.color = c;
  59.  
  60.                 gate.SetActive(false);
  61.  
  62.                 anim2.SetBool("Die", true);
  63.                 PlayerPrefs.SetString("IsDeath2", "true");
  64.             }
  65.         }
  66.         else{
  67.             Destroy(gameObject);
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement