Example #1
0
	// Use this for initialization
	void Awake () {
		hb = this;
		rect = GetComponent<RectTransform>();
		width = rect.sizeDelta.x+1;
		Debug.Log("width "+ width.ToString());
		if(image == null) image = GetComponent<Image>();
	}
 private void OnTriggerStay2D(Collider2D other)
 {
     if (isAttacking)
     {
         if (other.tag == "Vampire")
         {
             other.GetComponent <Animator>().SetInteger("Anim", 3);
             Score += 200;
             other.GetComponent <Collider2D>().enabled = false;
         }
         else if (other.tag == "Trpas")
         {
             other.GetComponent <Animator>().SetInteger("Anim", 3);
             Score += 50;
             other.GetComponent <Collider2D>().enabled = false;
         }
         else if (other.tag == "Boss")
         {
             i++;
             if (i == 1)
             {
                 HealthBar1.SetActive(false);
             }
             if (i == 2)
             {
                 HealthBar2.SetActive(false);
             }
             if (i == 3)
             {
                 HealthBar3.SetActive(false);
                 other.GetComponent <Animator>().SetInteger("Anim", 3);
                 Score += 500;
                 other.GetComponent <Collider2D>().enabled = false;
             }
         }
         else
         {
             other.GetComponent <Animator>().SetInteger("Anim", 3);
             Score += 100;
             other.GetComponent <Collider2D>().enabled = false;
         }
     }
 }