public static bool OnMeleeHit(Fixture a, Fixture b, Contact c) { if (b.Body.IsBullet) { return(true); } Projectile p = (Projectile)a.UserData; // If we hit a weapon. if (b.UserData is Weapon) { Weapon w = (Weapon)b.UserData; w.TakeDamage(p.GetPower()); } // If we hit a bot if (b.UserData is Bot) { Bot bot = (Bot)b.UserData; bot.TakeDamage(p.GetPower()); } // If we hit a projectile (e.g. an axe) if (b.UserData is Projectile) { Projectile o = (Projectile)b.UserData; o.TakeDamage(p.GetPower()); } return(true); }
public static bool OnBulletHit(Fixture a, Fixture b, Contact c) { // Fixture a is always the bullet, and Fixture b is what it hit. if (b.UserData is String && ((string)(b.UserData.ToString())).Equals("Wall")) { if (!m_toRemove.Contains(a.Body)) { m_toRemove.Add(a.Body); } return(true); } if (b.Body.IsBullet) { return(true); } // If we've gotten this far, b.UserData is an Object Projectile p = (Projectile)a.UserData; // If we hit a weapon. if (b.UserData is Weapon) { Weapon w = (Weapon)b.UserData; w.TakeDamage(p.GetPower()); } // If we hit a bot if (b.UserData is Bot) { Bot bot = (Bot)b.UserData; bot.TakeDamage(p.GetPower()); } // If we hit a projectile (e.g. an axe) if (b.UserData is Projectile) { Projectile o = (Projectile)b.UserData; o.TakeDamage(p.GetPower()); } if (!m_toRemove.Contains(a.Body)) { m_toRemove.Add(a.Body); } return(true); }