本文整理汇总了C#中Thing.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Thing.Dispose方法的具体用法?C# Thing.Dispose怎么用?C# Thing.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thing
的用法示例。
在下文中一共展示了Thing.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Thing_CollisionHappend
void Thing_CollisionHappend(Thing obj1, Thing obj2)
{
hitSound.Play();
obj2.Tint = Color.Red;
if (obj1 is Mobile && obj2 is Mobile)
{
obj1.Velocity = obj2.Velocity - obj1.Velocity;
obj2.Velocity = obj1.Velocity - obj2.Velocity;
this.Tick();
((Mobile)obj1).Health-=2;
((Mobile)obj2).Health-=2;
}
else
{
if (obj2 is Mobile)
{
((Mobile)obj2).Health-=2;
}
else
{
Vector2 position = obj2.Position;
obj1.Velocity += obj2.Velocity * 0.02f;
this.Components.Remove(obj2);
Animation exp = new Animation(this, spriteBatch, ExplosionMap, 0.5f);
this.Components.Add(exp);
}
if (obj1 is Mobile)
((Mobile)obj1).Health-=2;
else
{
Vector2 position = obj1.Position;
obj2.Velocity += obj1.Velocity * 0.02f;
this.Components.Remove(obj1);
Animation exp = new Animation(this, spriteBatch, ExplosionMap, 0.5f);
exp.Position = position;
this.Components.Add(exp);
}
}
if (!(obj1 is Mobile) && !(obj2 is Mobile))
{
obj1.Dispose();
obj2.Dispose();
}
}