本文整理汇总了C#中World.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# World.Destroy方法的具体用法?C# World.Destroy怎么用?C# World.Destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.Destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Distance_Box_to_Box
public void Test_Distance_Box_to_Box()
{
var node1 = new Node ("Node1");
var col1 = new CollisionObject ();
col1.Shape = new BoxShape (1, 1, 1);
col1.SetOffset (0, 0, 0);
node1.Attach (col1);
var node2 = new Node ("Node2");
var col2 = new CollisionObject ();
col2.Shape = new BoxShape (1,1,1);
col2.SetOffset (0, 10, 0);
node2.Attach (col2);
node1.Translate (0, 0, 0);
node2.Translate (10, 0, 0);
// 10*√2
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
wld.CollisionUpdate ();
Assert.AreEqual(10*1.4142f - 2*1.4142f, wld.Distance (node1, node2), 0.05f);
wld.Destroy ();
}
示例2: Test_BoxShape
public void Test_BoxShape()
{
var node1 = new Node ("Sweeper");
var col1 = new CollisionObject ();
col1.Shape = new BoxShape (1, 1, 1);
col1.SetOffset (0, 1, 0);
node1.Attach (col1);
var node2 = new Node ("Target1");
var col2 = new CollisionObject ();
col2.Shape = new SphereShape (1);
col2.SetOffset (0, 1, 0);
node2.Attach (col2);
var node3 = new Node ("Target2");
var col3 = new CollisionObject ();
col3.Shape = new SphereShape (1);
col3.SetOffset (0, 1, 0);
node1.Translate (0, 0, 0);
node2.Translate (10, 0, 0);
node3.Translate (20, 0, 0);
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
wld.AddChild (node3);
wld.CollisionUpdate ();
var result = wld.Sweep (node1, new Vector3 (100, 0, 0));
Assert.AreEqual (true, result.Hit);
Assert.AreEqual (new Vector3 (9, 1, 0), result.Point);
Assert.AreEqual (new Vector3 (-1, 0, 0), result.Normal);
Assert.AreEqual (8, result.Distance, 0.01f);
Assert.AreEqual (0.08f, result.Fraction, 0.01f);
result = wld.Sweep (node1, new Vector3 (0, 100, 0));
Assert.AreEqual (false, result.Hit);
result = wld.Sweep (node1, new Vector3 (-100, 100, 0));
Assert.AreEqual (false, result.Hit);
wld.Destroy ();
}
示例3: Main
public static void Main(string[] args)
{
var g2d = DD.Graphics2D.GetInstance ();
g2d.CreateWindow (800, 600, "こんにちは、世界");
// ----------------------------------------
var wld = new World ();
var node1 = MyCharacter.Create (new Vector3 (200, 200, 0), 16); // GroupID = 1<<4
var node2 = MyBlock.Create (new Vector3 (100, 300, 0), -1); // CollideWith = All
var node3 = MyBlock.Create (new Vector3 (300, 300, 0), 16); // CollideWith = 1<<4
var node4 = MyBlock.Create (new Vector3 (500, 300, 0), 0); // CollideWith = None
var node5 = MyHUD.Create (new Vector3 (10, 10, 0));
wld.AddChild (node1);
wld.AddChild (node2);
wld.AddChild (node3);
wld.AddChild (node4);
wld.AddChild (node5);
// ----------------------------------------
var active = true;
g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
active = false;
};
Console.WriteLine ("Start of Main Loop");
g2d.SetFrameRateLimit (60);
var watch = new Stopwatch ();
watch.Start ();
while (active) {
var msec = watch.ElapsedMilliseconds;
g2d.Dispatch (wld);
wld.Animate (msec, 33);
wld.Deliver ();
wld.CollisionUpdate ();
wld.Update (msec);
g2d.Draw (wld);
}
wld.Destroy ();
Console.WriteLine ("End of Game");
}
示例4: Test_Distance_Invalid_Objects
public void Test_Distance_Invalid_Objects()
{
var node1 = new Node ("Node1");
var node2 = new Node ("Node2");
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
wld.CollisionUpdate ();
var d = wld.Distance (node1, node2);
Assert.AreEqual (Single.NaN, d);
wld.Destroy ();
}
示例5: Main
public static void Main(string[] args)
{
var g2d = DD.Graphics2D.GetInstance ();
g2d.CreateWindow (800, 600, "こんにちは、世界");
Resource.SetTextureDirectory ("DatabaseSample/Textures/");
// ----------------------------------------
var node1 = MyCharacterHolder.Create ();
var node2 = MyCharacterViewer.Create (new Vector3 (0, 0, 0));
var node3 = MyCharacterSelector.Create (new Vector3 (0,0,0));
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
wld.AddChild (node3);
// ----------------------------------------
var active = true;
g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
active = false;
};
Console.WriteLine ("Start of Main Loop");
g2d.SetFrameRateLimit (60);
var watch = new Stopwatch ();
watch.Start ();
while (active) {
var msec = watch.ElapsedMilliseconds;
g2d.Dispatch (wld);
wld.Animate (msec, 33);
wld.Deliver ();
wld.CollisionUpdate ();
wld.Update (msec);
wld.Purge ();
g2d.Draw (wld);
}
Console.WriteLine ("End of Game");
wld.Destroy ();
}
示例6: Test_ApplyForce
public void Test_ApplyForce()
{
var ball1 = new Node ("Ball1");
var rb1 = new RigidBody ();
rb1.Mass = 1;
rb1.AddShape ( new SphereShape (1));
rb1.Material = new PhysicsMaterial ();
rb1.Material.Restitution = 1;
ball1.Attach (rb1);
var ball2 = new Node ("Ball2");
var rb2 = new RigidBody ();
rb2.Mass = 1;
rb2.AddShape ( new SphereShape (1));
rb2.Material = new PhysicsMaterial ();
rb2.Material.Restitution = 1;
ball2.Attach (rb2);
var wld = new World ("");
wld.AddChild (ball1);
wld.AddChild (ball2);
wld.PhysicsSimulator.SetGravity (0, 0, 0);
ball2.Translate (10, 0, 0);
// ①→②
// ①②→ (運動量保存の法則)
ball1.RigidBody.ApplyForce (1000, 0, 0);
for (var i = 0; i < 100; i++) {
wld.PhysicsUpdate (33);
Debug.WriteLine ("Ball1 = {0}, Ball2 = {1}", ball1.Position, ball2.Position);
}
Assert.AreEqual (new Vector3 (8.0333f, 0, 0), ball1.Position);
Assert.AreEqual (new Vector3 (56.6890f, 0, 0), ball2.Position);
wld.Destroy ();
}
示例7: Test_AllNodes
public void Test_AllNodes()
{
var wld = new World ();
for (var i = 0; i < 10; i++) {
var node = new Node ("" + i);
var col = new CollisionObject ();
col.Shape = new SphereShape (1);
node.Attach (col);
node.Translate (i, 0, 0);
wld.AddChild (node);
}
wld.CollisionUpdate ();
var results = wld.RayCast (new Vector3 (-10, 10, 0), new Vector3 (10, 10, 0));
Assert.AreEqual (0, results.Count ());
results = wld.RayCast (new Vector3 (-10, 0, 0), new Vector3 (10, 0, 0));
Assert.AreEqual (10, results.Count ());
Assert.AreEqual ("0", results.ElementAt (0).Node.Name);
Assert.AreEqual ("1", results.ElementAt (1).Node.Name);
Assert.AreEqual ("2", results.ElementAt (2).Node.Name);
Assert.AreEqual ("3", results.ElementAt (3).Node.Name);
Assert.AreEqual ("4", results.ElementAt (4).Node.Name);
Assert.AreEqual ("5", results.ElementAt (5).Node.Name);
Assert.AreEqual ("6", results.ElementAt (6).Node.Name);
Assert.AreEqual ("7", results.ElementAt (7).Node.Name);
Assert.AreEqual ("8", results.ElementAt (8).Node.Name);
Assert.AreEqual ("9", results.ElementAt (9).Node.Name);
wld.Destroy ();
}
示例8: Test_Distance
public void Test_Distance()
{
var node1 = new Node ("Node1");
node1.Attach (new CollisionObject ());
node1.CollisionObject.Shape = new BoxShape (1, 1, 1);
node1.CollisionObject.Offset = new Vector3 (2, 0, 0);
var node2 = new Node ("Node2");
node2.Attach (new CollisionObject ());
node2.CollisionObject.Shape = new BoxShape (1, 1, 1);
node2.Translate (-2, 0, 0);
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
// Distance()はスタティック関数なので
// コリジョンワールドは使用しない
//wld.CollisionUpdate ();
Assert.AreEqual(2, CollisionAnalyzer.Distance(node1.CollisionObject, node2.CollisionObject), 0.0001f);
wld.Destroy ();
}
示例9: Test_RegisterCollisionObject
public void Test_RegisterCollisionObject()
{
var node1 = new Node ("Node1");
var col1 = new CollisionObject ();
col1.Shape = new BoxShape (1, 1, 1);
node1.Attach (col1);
var node2 = new Node ("Node2");
var col2 = new CollisionObject ();
col2.Shape = new BoxShape (1, 1, 1);
node2.Attach (col2);
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
// ここで登録される
wld.CollisionUpdate ();
Assert.AreEqual (2, wld.CollisionAnalyzer.CollisionObjectCount);
Assert.AreEqual (2, wld.CollisionAnalyzer.CollisionObjects.Count ());
wld.Destroy ();
}
示例10: Test_Overlapped
public void Test_Overlapped()
{
var node1 = new Node ("Node1");
node1.Attach (new CollisionObject ());
node1.CollisionObject.Shape = new BoxShape (1, 1, 1);
var node2 = new Node ("Node2");
node2.Attach (new CollisionObject ());
node2.CollisionObject.Shape = new BoxShape (1, 1, 1);
var wld = new World ();
wld.AddChild (node1);
wld.AddChild (node2);
// Overlapped()はスタティック関数なので
// コリジョンワールドは使用しない
//wld.CollisionUpdate ();
node2.SetTranslation (0, 0, 0);
Assert.AreEqual (true, CollisionAnalyzer.Overlapped (node1.CollisionObject, node2.CollisionObject));
node2.SetTranslation (1, 0, 0);
Assert.AreEqual (true, CollisionAnalyzer.Overlapped (node1.CollisionObject, node2.CollisionObject));
node2.SetTranslation (2, 0, 0);
Assert.AreEqual (false, CollisionAnalyzer.Overlapped (node1.CollisionObject, node2.CollisionObject));
node1.CollisionObject.SetOffset (1, 0, 0);
Assert.AreEqual (true, CollisionAnalyzer.Overlapped (node1.CollisionObject, node2.CollisionObject));
wld.Destroy ();
}
示例11: Test_BoxShape
public void Test_BoxShape()
{
var node = new Node ();
var col = new CollisionObject ();
col.Shape = new BoxShape (1, 1, 1);
col.SetOffset (1, 0, 0);
node.Attach (col);
node.Translate (1, 0, 0);
node.Rotate (45, 0, 0, 1);
var wld = new World ();
wld.AddChild (node);
wld.CollisionUpdate ();
// (1+1) - 1*√2
var result = wld.RayCast (new Vector3 (-10, 0, 0), new Vector3 (10, 0, 0)).First ();
Assert.AreEqual (true, result.Hit);
Assert.AreEqual (new Vector3 (0.5858f, 0, 0), result.Point);
Assert.AreEqual (new Vector3 (-1, 0, 0), result.Normal);
Assert.AreEqual (10.58579f, result.Distance, 0.01f);
Assert.AreEqual (0.5245f, result.Fraction, 0.01f);
// (1+1) + 1*√2
result = wld.RayCast (new Vector3 (10, 0, 0), new Vector3 (-10, 0, 0)).First ();
Assert.AreEqual (true, result.Hit);
Assert.AreEqual (new Vector3 (3.4142f, 0, 0), result.Point);
Assert.AreEqual (new Vector3 (1, 0, 0), result.Normal);
Assert.AreEqual (6.585786f, result.Distance, 0.01f);
Assert.AreEqual (0.3225f, result.Fraction, 0.01f);
wld.Destroy ();
}
示例12: Test_SphereShape
public void Test_SphereShape()
{
var node = new Node ();
var col = new CollisionObject ();
col.Shape = new SphereShape (1);
col.SetOffset (1, 0, 0);
node.Attach (col);
node.Translate (1, 0, 0);
node.Rotate (45, 0, 0, 1);
var wld = new World ();
wld.AddChild (node);
wld.CollisionUpdate ();
// (1+1) - 1
var result = wld.RayCast (new Vector3 (-10, 0, 0), new Vector3 (10, 0, 0)).First ();
Assert.AreEqual (true, result.Hit);
Assert.AreEqual (new Vector3 (1, 0, 0), result.Point);
Assert.AreEqual (new Vector3 (-1, 0, 0), result.Normal);
Assert.AreEqual (11, result.Distance, 0.01f);
Assert.AreEqual (0.55f, result.Fraction, 0.01f);
// (1+1) + 1
result = wld.RayCast (new Vector3 (10, 0, 0), new Vector3 (-10, 0, 0)).First ();
Assert.AreEqual (true, result.Hit);
Assert.AreEqual (new Vector3 (3, 0, 0), result.Point);
Assert.AreEqual (new Vector3 (1, 0, 0), result.Normal);
Assert.AreEqual (7, result.Distance, 0.01f);
Assert.AreEqual (0.35f, result.Fraction, 0.01f);
wld.Destroy ();
}
示例13: Test_Damping
public void Test_Damping()
{
var box = new Node ("Box1");
box.Attach (new RigidBody ());
box.RigidBody.Material = new PhysicsMaterial ();
box.RigidBody.Mass = 1;
box.RigidBody.Material.LinearDamping= 0.9f; // 減衰 90%
box.RigidBody.AddShape (new BoxShape (1, 1, 1));
var wld = new World ("");
wld.AddChild (box);
wld.PhysicsSimulator.SetGravity (0, 0, 0);
box.RigidBody.ApplyForce (1000, 0, 0);
for (var i = 0; i < 100; i++) {
wld.PhysicsUpdate (33);
Debug.WriteLine ("Box = {0}", box.Position);
}
Assert.AreEqual (new Vector3 (7.3742f, 0, 0), box.Position);
wld.Destroy ();
}
示例14: Test_Restitution
public void Test_Restitution()
{
var sph1 = new Node ("Sphere1");
sph1.Attach (new RigidBody ());
sph1.RigidBody.Material = new PhysicsMaterial ();
sph1.RigidBody.Mass = 1;
sph1.RigidBody.Material.Restitution = 0; // 反射 0%
sph1.RigidBody.AddShape ( new SphereShape (1));
var sph2 = new Node ("Sphere2");
sph2.Attach (new RigidBody ());
sph2.RigidBody.Material = new PhysicsMaterial ();
sph2.RigidBody.Mass = 1;
sph2.RigidBody.Material.Restitution = 1; // 反射 100%
sph2.RigidBody.AddShape( new SphereShape (1));
var plane = new Node ("Plane");
plane.Attach (new RigidBody ());
plane.RigidBody.Material = new PhysicsMaterial ();
plane.RigidBody.Mass = 0;
plane.RigidBody.Material.Restitution = 1;
plane.RigidBody.AddShape(new BoxShape (100, 1, 100));
var wld = new World ("");
wld.AddChild (sph1);
wld.AddChild (sph2);
wld.AddChild (plane);
wld.PhysicsSimulator.SetGravity (0, -9.8f, 0);
sph1.Translate (0, 10, 0);
sph2.Translate (10, 10, 0);
for (var i = 0; i < 100; i++) {
wld.PhysicsUpdate (33);
Debug.WriteLine ("Sphere1 = {0}, Sphere2 = {1}", sph1.Position, sph2.Position);
}
//Assert.AreEqual (new Vector3 (0, 2.0000f, 0), sph1.Position);
//Assert.AreEqual (new Vector3(10.00011f, 7.681699f,0.00011f), sph2.Position);
wld.Destroy ();
}
示例15: Test_Gravity
public void Test_Gravity()
{
var ball1 = new Node ("FreeFall");
ball1.Attach(new RigidBody ());
ball1.RigidBody.AddShape (new SphereShape (1));
var ball2 = new Node ("NoFall");
ball2.Attach (new RigidBody ());
ball2.RigidBody.AddShape (new SphereShape (1));
ball2.RigidBody.Mass = 0; // = static, no gravity
ball2.Translate (10, 0, 0);
var wld = new World ();
wld.AddChild (ball1);
wld.AddChild (ball2);
wld.PhysicsSimulator.SetGravity (0, -9.8f, 0);
for (var i = 0; i < 250; i++) {
wld.PhysicsUpdate (4);
Debug.WriteLine ("Ball1 = {0}, Ball2 = {1}", ball1.Position, ball2.Position);
}
// Ball1 のみ重力による自由落下 (d = 4.9t^2)
Assert.AreEqual (new Vector3(0, -4.9817f, 0), ball1.Position);
Assert.AreEqual (new Vector3 (10, 0, 0), ball2.Position);
wld.Destroy ();
}