本文整理汇总了C#中Scene.AddEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.AddEntity方法的具体用法?C# Scene.AddEntity怎么用?C# Scene.AddEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.AddEntity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnonymousEntitiesDoNotHaveEqualNames
public void AnonymousEntitiesDoNotHaveEqualNames()
{
Scene scene = new Scene("Test Scene");
scene.AddEntity(new Entity());
scene.AddEntity(new Entity());
Assert.AreEqual(2, scene.Entities.Count);
}
示例2: AddEntity
public void AddEntity()
{
bool collectionChanged = false;
Scene scene = new Scene("Test Scene");
scene.Entities.CollectionChanged += (o, e) => collectionChanged = true;
Entity entity = new Entity();
scene.AddEntity(entity);
Assert.IsTrue(collectionChanged);
Assert.AreEqual(1, scene.Entities.Count());
}
示例3: RemoveEntity
public void RemoveEntity()
{
int eventsFired = 0;
Scene scene = new Scene("Test Scene");
scene.Entities.CollectionChanged += (o, e) => eventsFired++;
Entity entity = new Entity();
scene.AddEntity(entity);
scene.RemoveEntity(entity);
Assert.AreEqual(2, eventsFired);
Assert.AreEqual(0, scene.Entities.Count());
}
示例4: PlayOneShot
public static void PlayOneShot(string spriteName, string animName, int x, int y, Scene scene, int layer)
{
Entity entity = new Entity();
entity.posX = x;
entity.posY = y;
entity.scene = scene;
scene.AddEntity(entity);
entity.layer = layer;
entity.SetSprite(spriteName);
entity.sprite.PlayAnimation(animName);
entity.sprite.SetAnimCompleteCallback(delegate {
scene.RemoveEntity(entity);
});
}
示例5: SceneViewModel
public SceneViewModel(Scene scene)
{
this.scene = scene;
Entities = new ComputedObservableCollection<Entity, EntityViewModel>(scene.Entities, (entity) => new EntityViewModel(entity));
scene.PropertyChanged += Scene_PropertyChanged;
AddAttributeCommand = new DelegateCommand(null,
(parameter) =>
{
scene.CreateAttribute();
}
);
RemoveAttributeCommand = new DelegateCommand(null,
(parameter) =>
{
Attribute attribute = parameter as Attribute;
scene.RemoveAttribute(attribute);
}
);
AddEntityCommand = new DelegateCommand(null,
(parameter) =>
{
Entity entity = new Entity();
scene.AddEntity(entity);
}
);
RemoveEntityCommand = new DelegateCommand(null,
(parameter) =>
{
Entity entity = parameter as Entity;
scene.RemoveEntity(entity);
}
);
}
示例6: CreateTestGame
// Multiple inheritance tests
private static Game CreateTestGame()
{
var game = new Game("Test Game");
var prototypeA0 = new Entity() { Name = "prototypeA0" };
game.AddPrototype(prototypeA0);
var prototypeB0 = new Entity() { Name = "prototypeB0" };
game.AddPrototype(prototypeB0);
var prototypeC0 = new Entity() { Name = "prototypeC0" };
game.AddPrototype(prototypeC0);
var prototypeA1 = new Entity() { Name = "prototypeA1" };
prototypeA1.AddPrototype(prototypeA0);
game.AddPrototype(prototypeA1);
var prototypeB1 = new Entity() { Name = "prototypeB1" };
prototypeB1.AddPrototype(prototypeB0);
prototypeB1.AddPrototype(prototypeC0);
game.AddPrototype(prototypeB1);
var scene = new Scene("Test Scene");
game.FirstScene = scene;
var testEntity = new Entity() { Name = "testEntity" };
scene.AddEntity(testEntity);
testEntity.AddPrototype(prototypeA1);
testEntity.AddPrototype(prototypeB1);
return game;
}
示例7: CreateScene
private Scene CreateScene(ParseTreeNode node)
{
Scene scene = new Scene(grammar.GetName(node));
foreach (Tuple<string, object> attribute in GetProperties(node))
{
ParseTreeNode attributeNode = (ParseTreeNode)attribute.Item2;
scene.AddAttribute(new Attribute(attribute.Item1) { Value = new Value(getStrVal(attributeNode)) });
}
foreach (ParseTreeNode managerNode in grammar.GetOfType(node, grammar.Manager))
{
Manager manager = CreateManager(managerNode);
scene.AddManager(manager);
}
foreach (ParseTreeNode entityNode in grammar.GetOfType(node, grammar.Entity))
{
Entity entity = CreateEntity(entityNode, scene, false);
scene.AddEntity(entity);
}
return scene;
}
示例8: Scene_RemoveEntity
public void Scene_RemoveEntity()
{
var scene = new Scene("Test Scene");
var entity = new Entity();
scene.AddEntity(entity);
CommandHelper.TestUndoableCommand(
() => Assert.AreEqual(1, scene.Entities.Count),
() => scene.RemoveEntityCommand.Execute(entity),
() => Assert.AreEqual(0, scene.Entities.Count)
);
}
示例9: Scene_Delete
public void Scene_Delete()
{
var scene = new Scene("Test Scene");
var entity = new Entity();
scene.AddEntity(entity);
CommandHelper.TestUndoableCommand(
() => Assert.AreEqual(1, scene.EntityPresenters.Count),
() => scene.DeleteCommand.Execute(Enumerable.Repeat(scene.EntityPresenters.First(), 1)),
() => Assert.AreEqual(0, scene.EntityPresenters.Count)
);
}
示例10: Initialize
protected override void Initialize()
{
base.Initialize();
main_ui = new MainUI(this);
main_ui.Initialize();
scene = new Scene(this, 0, "test");
Scm.AddScene(scene);
Scm.SetActiveScene(scene);
/*
Vector3 camera_position = new Vector3(0, 10, 51);
Vector3 camera_target = camera_position + Vector3.Forward;
Camera cam = new Camera();
cam.Initialize();
cam.Fov = MathHelper.PiOver4;
scene.ActiveCamera = cam;
*/
camera = new Camera(this);
scene.ActiveCamera = camera;
//camera_ctrl = new FpsCameraController(this);
//cam.AttachController(camera_ctrl);
//camera_ctrl.Enabled = true;
//////////////////////////////////////////////////////////////////////////
Axis axis = new Axis(this);
axis.Initialize();
scene.AddEntity(axis);
axis.Pose.SetScale(10, 10, 10);
////////////////////////////////��������ķָ���//////////////////////////////////////////
Terrain terrain = new Terrain(this, "Textures\\flat_map", null);
terrain.Initialize();
scene.AddEntity(terrain);
camera.Target = new Vector3(terrain.WidthInPixel / 2.0f, 0, -terrain.HeightInPixel / 2.0f);
//camera.Target = new Vector3(0, 0, 0);
//////////////////////////////////////////////////////////////////////////
//Quad s1 = new Quad(this);
//s1.Initialize();
//scene.AddEntity(s1);
//s1.Pose.SetPosition(0, 0, 0);
//s1.Pose.SetScale(4, 4, 1);
//////////////////////////////////////////////////////////////////////////
//Avatar a1 = new Avatar(this, "Models\\p1_wedge");
//a1.Initialize();
//scene.AddEntity(a1);
//a1.pose.SetPosition(10, 20, -10);
//a1.pose.SetScale(0.01f, 0.01f, 0.01f);
//////////////////////////////////////////////////////////////////////////
Light l1 = new Light(this, new Vector3(0.0f, 1.0f, 0.0f), new Vector3(1.0f, -1.0f, -1.0f));
scene.AddLight(l1);
//////////////////////////////////////////////////////////////////////////
Box b1 = new Box(this);
b1.Initialize();
b1.SetScale(10.0f, 10.0f, 10.0f);
b1.SetPosition(100, 10, -100);
scene.AddEntity(b1);
Box b2 = new Box(this);
b2.Initialize();
b2.SetScale(10, 10, 10);
b2.SetPosition(150, 10, -150);
scene.AddEntity(b2);
//////////////////////////////////////////////////////////////////////////
float bx = 200;
float by = 20;
float bz = -200;
// Sphere s1 = new Sphere(this);
// s1.Initialize();
// s1.SetScale(10, 10, 10);
// s1.SetPosition(bx + 0.0442591f, by + 0.017970f, bz + 0.045182f);
// s1.ModelFile = "Models\\SphereLowPoly";
// scene.AddEntity(s1);
Axis a1 = new Axis(this);
a1.Initialize();
a1.SetScale(10, 10, 10);
Matrix rot = new Matrix();
rot.M11 = 9.9994452992e-001f; rot.M12 = 2.8077475493e-003f; rot.M13 = 1.0151533926e-002f;
rot.M21 = -2.8522679263e-003f; rot.M22 = 9.9998636727e-001f; rot.M23 = 4.3737664750e-003f;
rot.M31 = -1.0139115101e-002f; rot.M32 = -4.4024787564e-003f; rot.M33 = 9.9993890640e-001f;
a1.SetRotation(rot);
a1.SetPosition(bx + 0.0442591f, by + 0.017970f, bz + 0.045182f);
scene.AddEntity(a1);
//Sphere s2 = new Sphere(this);
//s2.Initialize();
//s2.SetScale(10, 10, 10);
//.........这里部分代码省略.........
示例11: CannotRenameToDuplicateNameInSameScope
public void CannotRenameToDuplicateNameInSameScope()
{
Game game = new Game("Test Game");
game.AddPrototype(new Entity() { Name = "TestEntity" });
Scene scene = new Scene("Test Scene");
Entity entity = new Entity() { Name = "TestEntity2" };
scene.AddEntity(entity);
game.AddScene(scene);
entity.Name = "TestEntity";
Assert.AreEqual(1, scene.Entities.Count);
Assert.AreEqual("TestEntity2", entity.Name);
}
示例12: CanAddDuplicateNameInDifferentScope
public void CanAddDuplicateNameInDifferentScope()
{
Game game = new Game("Test Game");
Scene scene1 = new Scene("Test Scene");
Entity entity1 = new Entity() { Name = "TestEntity" };
scene1.AddEntity(entity1);
game.AddScene(scene1);
Scene scene2 = new Scene("Test Scene 2");
Entity entity2 = new Entity() { Name = "TestEntity" };
scene2.AddEntity(entity2);
game.AddScene(scene2);
Assert.AreEqual(1, scene1.Entities.Count);
Assert.AreEqual(1, scene2.Entities.Count);
}