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>();
	}
Example #2
0
 private void Start()
 {
     body               = GetComponent <Rigidbody2D>();
     pHealth            = (Health1)FindObjectOfType(typeof(Health1));
     hBar               = (HealthBar1)FindObjectOfType(typeof(HealthBar1));
     transform.position = spawnPoint.transform.position;
     l11 = GameObject.FindGameObjectWithTag("L11");
     l21 = GameObject.FindGameObjectWithTag("L21");
     l31 = GameObject.FindGameObjectWithTag("L31");
 }
 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;
         }
     }
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     player  = GameObject.FindGameObjectWithTag("Player2");
     pHealth = (Health1)FindObjectOfType(typeof(Health1));
     hBar    = (HealthBar1)FindObjectOfType(typeof(HealthBar1));
 }