void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") { return; } if (other.tag == transform.tag) { return; } HitBy = other.GetComponent <OnContact> (); //What am i and what will i do! switch (Type) { case TypeOfContact.PlayerProjectile: TakeDamage(HitBy.DealDamage()); break; case TypeOfContact.Player: if ((HitBy.ContactType() == TypeOfContact.EnemyProjectile) || (HitBy.ContactType() == TypeOfContact.Enemy)) { TakeDamage(HitBy.DealDamage()); } break; case TypeOfContact.Enemy: case TypeOfContact.EnemyProjectile: if ((HitBy.ContactType() == TypeOfContact.PlayerProjectile) || (HitBy.ContactType() == TypeOfContact.Player)) { TakeDamage(HitBy.DealDamage()); } break; case TypeOfContact.PowerUp: if (HitBy.ContactType() == TypeOfContact.Player) { switch (DestroyBonus) { case OnDestroyed.ExtraLife: gameController.AddLife(1); Death(); break; } } else if (HitBy.ContactType() == TypeOfContact.PlayerProjectile) { TakeDamage(HitBy.DealDamage()); } break; } }
private bool OnSensorCollision(Fixture fixtureA, Fixture fixtureB, Contact contact) { // we assume that fixtureA is always our self System.Diagnostics.Debug.Assert(fixtureA.Body.UserData == this.Entity); var entity2 = (Entity)fixtureB.Body.UserData; if (currentlyVisibleEntities.ContainsKey(entity2)) { currentlyVisibleEntities[entity2]++; } else { currentlyVisibleEntities.Add(entity2, 1); OnContact?.Invoke(Name, entity2, contact); } return(true); }