本文整理汇总了C#中Project290.Physics.Dynamics.World类的典型用法代码示例。如果您正苦于以下问题:C# World类的具体用法?C# World怎么用?C# World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
World类属于Project290.Physics.Dynamics命名空间,在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachBodiesWithRevoluteJoint
/// <summary>
/// Attaches the bodies with revolute joints.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="bodies">The bodies.</param>
/// <param name="localAnchorA">The local anchor A.</param>
/// <param name="localAnchorB">The local anchor B.</param>
/// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
/// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
public static List<RevoluteJoint> AttachBodiesWithRevoluteJoint(World world, List<Body> bodies,
Vector2 localAnchorA,
Vector2 localAnchorB, bool connectFirstAndLast,
bool collideConnected)
{
List<RevoluteJoint> joints = new List<RevoluteJoint>(bodies.Count + 1);
for (int i = 1; i < bodies.Count; i++)
{
RevoluteJoint joint = new RevoluteJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB);
joint.CollideConnected = collideConnected;
world.AddJoint(joint);
joints.Add(joint);
}
if (connectFirstAndLast)
{
RevoluteJoint lastjoint = new RevoluteJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA,
localAnchorB);
lastjoint.CollideConnected = collideConnected;
world.AddJoint(lastjoint);
joints.Add(lastjoint);
}
return joints;
}
示例2: CreateFixedAngleJoint
/// <summary>
/// Creates a fixed angle joint.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="body">The body.</param>
/// <returns></returns>
public static FixedAngleJoint CreateFixedAngleJoint(World world, Body body)
{
FixedAngleJoint angleJoint = new FixedAngleJoint(body);
world.AddJoint(angleJoint);
return angleJoint;
}
示例3: CreateFixedDistanceJoint
public static FixedDistanceJoint CreateFixedDistanceJoint(World world, Body body, Vector2 localAnchor,
Vector2 worldAnchor)
{
FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
world.AddJoint(distanceJoint);
return distanceJoint;
}
示例4: CreateAngleJoint
/// <summary>
/// Creates an angle joint.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="bodyA">The first body.</param>
/// <param name="bodyB">The second body.</param>
/// <returns></returns>
public static AngleJoint CreateAngleJoint(World world, Body bodyA, Body bodyB)
{
AngleJoint angleJoint = new AngleJoint(bodyA, bodyB);
world.AddJoint(angleJoint);
return angleJoint;
}
示例5: CreateDistanceJoint
public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA,
Vector2 anchorB)
{
DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
world.AddJoint(distanceJoint);
return distanceJoint;
}
示例6: MasslessItem
public MasslessItem(Texture2D t, PhysicsShape shape, Vector2 position, World w)
: base(position, w, t.Width, t.Height)
{
texture = t;
body.BodyType = BodyType.Static;
body.Position = position;
switch (shape)
{
case PhysicsShape.Rectangle:
fixture = FixtureFactory.CreateRectangle(
texture.Width,
texture.Height,
0.0f,
Vector2.Zero,
body);
break;
}
//fixture.CollisionFilter.IgnoreCollisionWith();
fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
w.AddBody(body);
//drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
//drawRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
}
示例7: Battle
public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel)
{
this.sprWorld = sprWorld;
this.botHalfWidth = botHalfWidth;
this.world = world;
xmlDoc = new XmlDocument();
if (nextAllies == "")
{
xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml");
}
else
{
xmlDoc.LoadXml(nextAllies);
}
//xmlDoc.
XmlNodeList nodes = xmlDoc.GetElementsByTagName("Bot");
Vector2[] edges = { new Vector2(-botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, botHalfWidth) * Settings.MetersPerPixel, new Vector2(-botHalfWidth, botHalfWidth) * Settings.MetersPerPixel };
CreateBots(nodes, edges);
xmlDoc.Load("Games/SuperPowerRobots/Storage/Battles.xml");
nodes = xmlDoc.GetElementsByTagName("Level");
nodes = nodes[currentLevel].ChildNodes;
CreateBots(nodes, edges);
}
示例8: CreateBreakableBody
/// <summary>
/// Creates a breakable body. You would want to remove collinear points before using this.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="vertices">The vertices.</param>
/// <param name="density">The density.</param>
/// <param name="position">The position.</param>
/// <returns></returns>
public static BreakableBody CreateBreakableBody(World world, Vertices vertices, float density, Vector2 position,
Object userData)
{
List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);
BreakableBody breakableBody = new BreakableBody(triangles, world, density, userData);
breakableBody.MainBody.Position = position;
world.AddBreakableBody(breakableBody);
return breakableBody;
}
示例9: Bomb
public Bomb(Vector2 position, World world, Vector2 velocity)
: base(position, world, TextureStatic.Get("bomb").Width, TextureStatic.Get("bomb").Height)
{
body.BodyType = BodyType.Dynamic;
texture = TextureStatic.Get("bomb");
fixture = FixtureFactory.CreateCircle(TextureStatic.Get("bomb").Width / 2, 1, body);
laidTime = GameClock.Now;
world.AddBody(body);
body.LinearVelocity = velocity;
}
示例10: Explosion
public Explosion(Vector2 position, World world, float radius, int power)
: base(position, world, TextureStatic.Get("solitudeExplosion").Width, TextureStatic.Get("solitudeExplosion").Height)
{
body.BodyType = BodyType.Kinematic;
body.Position = position;
this.radius = 1f;
maxRadius = radius;
this.power = power;
fixture = FixtureFactory.CreateCircle(this.maxRadius, 0f, body);
fixture.CollisionFilter.CollidesWith = Category.None;
texture = TextureStatic.Get("solitudeExplosion");
}
示例11: SolitudeObject
public SolitudeObject(Vector2 position, World world, Shape shape, float width, float height)
{
body = BodyFactory.CreateBody(world, position);
//currently in wall class:
fixture = new Fixture(body, shape);
fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
//###################
drawOrigin = new Vector2(width, height);
drawRectangle = new Rectangle(0, 0, (int)width, (int)height);
}
示例12: Mauler
public Mauler(Vector2 position, World w)
: base(position, w, TextureStatic.Get("solitudeMauler").Width, TextureStatic.Get("solitudeMauler").Height)
{
health = Settings.maulerHealth;
world = w;
body.BodyType = BodyType.Dynamic;
body.Position = position;
texture = TextureStatic.Get("solitudeMauler");
fixture = FixtureFactory.CreateCircle(texture.Width/2, 0.25f, body, Vector2.Zero);
fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
world.AddBody(body);
targetPoint = body.Position;
}
示例13: BreakableBody
public BreakableBody(IEnumerable<Vertices> vertices, World world, float density, Object userData)
{
_world = world;
_world.ContactManager.PostSolve += PostSolve;
MainBody = new Body(_world);
MainBody.BodyType = BodyType.Dynamic;
foreach (Vertices part in vertices)
{
PolygonShape polygonShape = new PolygonShape(part, density);
Fixture fixture = MainBody.CreateFixture(polygonShape, userData);
Parts.Add(fixture);
}
}
示例14: Fighter
public Fighter(Vector2 position, World w)
: base(position, w, TextureStatic.Get("fighter").Width, TextureStatic.Get("fighter").Height)
{
this.health = Settings.fighterHealth;
world = w;
lastShot = GameClock.Now;
world = w;
body.BodyType = BodyType.Dynamic;
body.Position = position;
texture = TextureStatic.Get("fighter");
fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
world.AddBody(body);
targetPoint = body.Position;
}
示例15: TyTaylor
public TyTaylor(World w, Vector2 position)
: base(position, w, TextureStatic.Get("ty").Width, TextureStatic.Get("ty").Height)
{
health = Settings.TyHealth;
world = w;
lastShot = GameClock.Now;
body.BodyType = BodyType.Dynamic;
body.Position = position;
texture = TextureStatic.Get("ty");
fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
world.AddBody(body);
targetPoint = body.Position;
fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
}