protected void DetermineHit(Collision2D collision, bool destroysSelfOnHit) { Entity hitEntity = collision.gameObject.GetComponent <Entity>(); if (hitEntity && hitEntity.affinity != affinity) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(DamageValue(), owner, gameObject); if (destroysSelfOnHit) { DestroyMe(); } } } else if (hitEntity && hitEntity.gameObject != owner) { IProjectilePassable iProjectilePassable = collision.gameObject.GetComponent(typeof(IProjectilePassable)) as IProjectilePassable; if (iProjectilePassable == null) { if (DestroysSelfOnFriendlyHit()) { DestroyMe(); } } } }
void OnTriggerEnter2D(Collider2D collider) { IHarmable harmedObject = collider.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { Explode(); } }
void OnCollisionEnter2D(Collision2D collision) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { Explode(); } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.GetComponent <Entity>()) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(1, gameObject, gameObject); } } }
void OnTriggerEnter2D(Collider2D collider) { if (hazardous) { IHarmable harmedObject = collider.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(50, gameObject, gameObject); } } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.GetComponent <Entity>().affinity != GetComponent <Entity>().affinity) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(1, gameObject, gameObject); } DestroyMe(); } }
private void OnCollisionEnter2D(Collision2D collision) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; float damage = 1; if (harmedObject != null) { if (vehicleControls.IsCharging()) { damage = 5; } harmedObject.ReceiveHit(damage, gameObject, gameObject); } }
void OnCollisionEnter2D(Collision2D collision) { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(10, gameObject, gameObject); float damage = collision.gameObject.GetComponent <Rigidbody2D>().velocity.magnitude * 15; currentHealth -= damage; print("dinged for " + damage); if (currentHealth <= 0) { DestroyMe(); } } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.GetComponent <Entity>()) { if (AffinitiesMatch(collision.gameObject)) { // Sheep sheep = collision.gameObject.GetComponent<Sheep>(); // if(sheep) Merge (sheep); } else { IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable; if (harmedObject != null) { harmedObject.ReceiveHit(1, gameObject, gameObject); } } } }
public void Strike(IHarmable enemy) { throw new System.NotImplementedException(); }