Beispiel #1
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         life vidaEnemy = coll.gameObject.GetComponent <life>();
         coll.gameObject.GetComponent <Player>().charm = true;
         vidaEnemy.ApplyDamage(damage);
         DestroyObject(gameObject);
     }
 }
Beispiel #2
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         foreach (ContactPoint2D contact in coll.contacts)
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = contact.point;
         }
         life vidaEnemy = coll.gameObject.GetComponent <life>();
         vidaEnemy.ApplyDamage(damage);
     }
 }
Beispiel #3
0
 void OnTriggerStay2D(Collider2D coll)
 {
     if (coll.tag == "Enemy" && Enemy != null)
     {
         if (Input.GetButtonDown("Attack") && !anime.GetCurrentAnimatorStateInfo(0).IsName("Blend Tree"))
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = swordHit.position;
             life vidaEnemy = coll.gameObject.GetComponent <life> ();
             vidaEnemy.ApplyDamage(basicDamage);
         }
     }
 }
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         foreach (ContactPoint2D contact in coll.contacts)
         {
             GameObject temp = Instantiate(hitPrefab) as GameObject;
             temp.transform.position = contact.point;
         }
         if (!coll.gameObject.GetComponent <Player>().defense)
         {
             vidaEnemy = coll.gameObject.GetComponent <life>();
             vidaEnemy.ApplyDamage(damage);
         }
         DestroyObject(gameObject);
     }
 }