public void CollidedWith(IColloidableObject colloidableObject) { if (colloidableObject is Bullet) { Bullet bullet = colloidableObject as Bullet; energy -= bullet.Energy / 100.0f; } }
public void CheckCollisions(IColloidableObject spacecraft) { foreach (var gameObject in gameObjects.ToArray()) { if(gameObject is IColloidableObject) { var colloidableObject = gameObject as IColloidableObject; if(spacecraft.CollisionSphere.Intersects(colloidableObject.CollisionSphere)) { spacecraft.CollidedWith(colloidableObject); colloidableObject.CollidedWith(spacecraft); } } } }
public void CheckCollisions(IColloidableObject spacecraft) { foreach (var gameObject in gameObjects.ToArray()) { if (gameObject is IColloidableObject) { var colloidableObject = gameObject as IColloidableObject; if (spacecraft.CollisionSphere.Intersects(colloidableObject.CollisionSphere)) { spacecraft.CollidedWith(colloidableObject); colloidableObject.CollidedWith(spacecraft); } } } }
public void CollidedWith(IColloidableObject colloidableObject) { MyContentManager.Sound_Explosion.Play(Math.Max(0, 0.1f - MyMath.Distance(gameWorld.CameraPosition, gamePosition) / 4000.0f / 10)); gameWorld.Add(new BulletExplosion(gameWorld, gamePosition, Energy)); dead = true; }
public void CollidedWith(IColloidableObject colloidableObject) { if(colloidableObject is Bullet) { Bullet bullet = colloidableObject as Bullet; energy -= bullet.Energy/100.0f; } }