示例#1
0
 void Start()
 {
     //Initializing the plague and hp scripts for reference
     anim         = Character.GetComponent <Animator>();
     plagueScript = Character.GetComponent <PlagueBolt>();
     hpScript     = Character.GetComponent <HpScript>();
 }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     playerHp = GameObject.FindGameObjectWithTag("Player").GetComponent <HpScript>();
 }
示例#3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Wall"))
        {
            Destroy(gameObject);
        }
        if (collision.gameObject.CompareTag("Enemy"))
        {
            //randomizar o valor para instanciar o damageFx - remove o parent e muda sua escala para destruir
            int        randomIndex   = Random.Range(0, damageFx.Count - 1);
            GameObject damageFxClone = Instantiate(damageFx[randomIndex], this.transform);
            damageFxClone.transform.SetParent(null);
            damageFxClone.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            Destroy(damageFxClone, 0.3f);

            //checa se o inimigo tem o script HPScript para diminuir hp e depois destruir
            HpScript hpScript = collision.gameObject.GetComponent <HpScript>();
            if (hpScript)
            {
                hpScript.RemoveHp(damage);
            }
            Destroy(gameObject);
        }
    }
示例#4
0
 // Start is called before the first frame update
 void Start()
 {
     hpScript          = GetComponent <HpScript>();
     hpSlider.minValue = 0;
     hpSlider.maxValue = hpScript.Hp;
 }
示例#5
0
 void Start()
 {
     playerHp = GameObject.FindGameObjectWithTag("Player").GetComponent <HpScript>();
 }