本文整理汇总了C#中Entity.SetParent方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.SetParent方法的具体用法?C# Entity.SetParent怎么用?C# Entity.SetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.SetParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Wall
public Wall(Scene scene, IList<Vector2> vertices)
: base(scene, vertices)
{
SetBodyType(BodyType.Static);
Entity entity = new Entity(scene);
entity.AddModel(ModelFactory.CreatePolygon(vertices, new Vector3(0, 0, 1)));
entity.SetParent(this);
SetCollisionCategory(Category.All);
}
示例2: Bullet
public Bullet(Scene scene, Vector2 position, Vector2 velocity)
: base(scene, PolygonFactory.CreateNGon(3, 0.1f, new Vector2()), new Transform2(position))
{
Entity = new Entity(Scene);
SetVelocity(Transform2.CreateVelocity(velocity));
Entity.SetParent(this);
Model model = ModelFactory.CreatePolygon(Vertices, new Vector3(0, 0, 1));
//Model model = ModelFactory.CreateArrow(new Vector3(0f, 0f, 1f), velocity.Normalized() * 0.1f, 0.1f, 0.3f, 0.15f);
model.SetColor(new Vector3(1, 1, 0));
Entity.AddModel(model);
OnCollision += Bullet_OnCollision;
SetCollisionCategory(Category.Cat1);
SetCollidesWith(~Category.Cat1);
}
示例3: StepTest7
public void StepTest7()
{
Scene scene = new Scene();
Actor actor = new Actor(scene, PolygonFactory.CreateRectangle(2, 2));
actor.SetTransform(new Transform2(new Vector2(1, 1)));
actor.SetVelocity(Transform2.CreateVelocity(new Vector2(0, 3)));
Entity entity = new Entity(scene);
entity.SetParent(actor);
FloatPortal enter = new FloatPortal(scene);
enter.SetTransform(new Transform2(new Vector2(1, 2), 1, (float)Math.PI / 2));
//enter.SetVelocity(Transform2.CreateVelocity(new Vector2(1, 0)));
FloatPortal exit = new FloatPortal(scene);
exit.SetTransform(new Transform2(new Vector2(10, 10)));
exit.SetVelocity(Transform2.CreateVelocity(new Vector2(10, 0)));
enter.Linked = exit;
exit.Linked = enter;
PortalCommon.UpdateWorldTransform(scene);
SimulationStep.Step(scene.GetAll().OfType<IPortalCommon>(), scene.GetAll().OfType<IPortal>(), 1, null);
Assert.IsTrue(entity.GetTransform() == new Transform2());
Assert.IsTrue(entity.GetVelocity() == Transform2.CreateVelocity());
Assert.IsTrue(actor.GetTransform() == actor.WorldTransform);
Assert.IsTrue(actor.GetVelocity() == actor.WorldVelocity);
}
示例4: Export
/// <summary>
/// Creates a Scene from an EditorScene. Scene is intended for gameplay use.
/// </summary>
public static Scene Export(EditorScene level, Controller controller)
{
Scene scene = new Scene();
/*if (level.GetAll().OfType<EditorPlayer>().Count() > 0)
{
Camera2 camera = new Camera2(scene);
camera.SetTransform(new Transform2(new Vector2(), 10, 0));
scene.SetActiveCamera(camera);
if (level.ActiveCamera != null)
{
camera.Aspect = level.ActiveCamera.Aspect;
}
}
else*/
{
if (level.ActiveCamera != null)
{
ControllerCamera camera = level.ActiveCamera.ShallowClone();
camera.Scene = scene;
scene.SetActiveCamera(camera);
}
}
#region create background
Model background = Game.ModelFactory.CreatePlane();
background.Texture = level.Renderer.GetTexture("grid.png");
background.SetColor(new Vector3(1, 1, 0.5f));
background.Transform.Position = new Vector3(0, 0, -5f);
float size = 50;
background.Transform.Scale = new Vector3(size, size, size);
background.TransformUv.Size = size;
Entity back = new Entity(scene, new Vector2(0f, 0f));
back.Name = "Background";
back.AddModel(background);
back.IsPortalable = false;
#endregion
Dictionary<EditorObject, SceneNode> dictionary = new Dictionary<EditorObject, SceneNode>();
AnimationDriver animation = new AnimationDriver();
scene.SceneObjectList.Add(animation);
List<EditorObject> editorObjects = level.GetAll().OfType<EditorObject>().ToList();
foreach (EditorObject e in editorObjects)
{
if (e is EditorPortal)
{
EditorPortal cast = (EditorPortal)e;
Entity entity = new Entity(scene);
entity.IsPortalable = false;
entity.AddModel(ModelFactory.CreatePortal());
entity.ModelList[0].Transform.Position += new Vector3(0, 0, -2);
if (cast.OnEdge)
{
FixturePortal portal = new FixturePortal(scene);
portal.Name = cast.Name;
dictionary.Add(cast, portal);
entity.SetParent(portal);
}
else
{
FloatPortal portal = new FloatPortal(scene);
portal.Name = cast.Name;
portal.SetTransform(cast.GetTransform());
dictionary.Add(cast, portal);
entity.SetParent(portal);
if (cast.AnimatedTransform != null)
{
animation.Add(portal, cast.AnimatedTransform);
portal.SetTransform(cast.AnimatedTransform.GetTransform(0));
}
else
{
portal.SetTransform(cast.GetTransform());
}
}
}
else if (e is EditorEntity)
{
EditorEntity cast = (EditorEntity)e;
Entity clone = new Entity(scene);
clone.Name = cast.Name;
clone.AddModelRange(cast.Models);
dictionary.Add(cast, clone);
if (cast.AnimatedTransform != null)
{
animation.Add(clone, cast.AnimatedTransform);
clone.SetTransform(cast.AnimatedTransform.GetTransform(0));
}
else
{
//.........这里部分代码省略.........