// Check for collisions with enemies void OnTriggerEnter2D(Collider2D col) { EnemyHP s = col.gameObject.GetComponent <EnemyHP>(); if (s != null && col.gameObject.GetComponent <Turret>() == null) { s.die(); EHP.gotHit(Vector3.zero, 1); } }
// Check for collisions with enemies, and stay out of asteroids void OnTriggerEnter2D(Collider2D col) { if (invuln || Time.time < 1f) { return; } EnemyHP s = col.gameObject.GetComponent <EnemyHP>(); if (s != null && !turtle_script.currently_active) { if (!dashing) { gotHit(); } if (s.gameObject.GetComponent <Rock> () == null) { if (dashing) { if (dash_powered) { s.gotHit(col.transform.position - transform.position, 1, false); } if (!PlayerMove.dash_kill) { dash_powered = false; } } else { s.gotHit(col.transform.position - transform.position, 4, true); } } } // Bullet and HP drop collisions managed by BulletScript.cs and HPDrop.cs }
// Anything that does damage should call this to damage whatever it hit. // Returns true if it actually deals damage (so that the bullet should die, etc.) public static bool dealDamage(GameObject obj, int damage, Vector3 pos, ObjT.obj type, Vector3 bullet) { if (obj == null) { return(false); } EnemyHP s = obj.GetComponent <EnemyHP>(); if (s != null) { s.gotHit(bullet, damage); return(true); } if (obj.layer == 9) { return(true); } PlayerHP PHP = obj.GetComponent <PlayerHP> (); if (PHP != null && (type != ObjT.obj.player_bullet) && (type != ObjT.obj.player_explosion)) { if (!PlayerHP.dashing) { PHP.gotHit(damage); } return(true); } upgrade_button ub; if ((ub = obj.GetComponentInParent <upgrade_button>())) { ub.put_description(); return(true); // I beleive this will destroy the bullet } return(false); }