Beispiel #1
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         Enemy_Slime enemy = col.gameObject.GetComponent <Enemy_Slime>();
         if (isAttacking)
         {
             int mult = (attackType == AttackType.Strong) ? 2 : 1;
             enemy.Damage(strengh * mult);
             int dir = (isFacingRight) ? 1 : -1;
             col.attachedRigidbody.AddForce(new Vector2(dir * pushStrengh, 0));
             isAttacking = false;
         }
     }
 }
Beispiel #2
0
 void OnCollisionStay2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         Enemy_Slime enemy = col.gameObject.GetComponent <Enemy_Slime>();
         if (enemy.isAttacking)
         {
             camscript.Shake();
             health -= enemy.strengh;
             int dir = (isFacingRight) ? 1 : -1;
             rigidbod.AddForce(new Vector2(dir * enemy.strengh * 100, 0));
             if (health == 0)
             {
                 Dying();
             }
         }
     }
 }
Beispiel #3
0
 public void SetEnemySlime(Enemy_Slime es)
 {
     this.es = es;
 }
Beispiel #4
0
 private void Awake()
 {
     es = GameObject.FindObjectOfType <Enemy_Slime>();
 }