本文整理汇总了C#中BaseObject.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# BaseObject.AddComponent方法的具体用法?C# BaseObject.AddComponent怎么用?C# BaseObject.AddComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject.AddComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateObject
private void CreateObject(Enemy enemy)
{
var baseObject = new BaseObject { Username = enemy.UniqueId.ToString()};
baseObject.AddComponent(new Sprite(_texture, 32, 32, new Vector2(enemy.Position.ScreenXPosition, enemy.Position.ScreenYPosition), Color.Black, enemy.Position.Visible));
baseObject.AddComponent(new Animation(16, 16, 2));
//Later we add specific component for enemies here.
_enemies.Add(baseObject);
}
示例2: GetDeathAnimationObject
public static BaseObject GetDeathAnimationObject(DeathAnimation deathAnimation, Vector2 position)
{
var baseObject = new BaseObject {Id = "deathAnimation"};
switch (deathAnimation)
{
case DeathAnimation.Explosion:
baseObject.AddComponent(new Sprite(ManagerContent.LoadTexture("death_effect"), 16, 16, position));
baseObject.AddComponent(new Animation(16, 16, 3,100));
baseObject.AddComponent(new DeathAnimationExplosion());
baseObject.AddComponent(new Camera(_camera));
break;
}
return baseObject;
}
示例3: CreateObject
private void CreateObject(Player player)
{
var baseObject = new BaseObject {Username = player.Username};
baseObject.AddComponent(new Sprite(_texture, 32,32, new Vector2(player.Position.ScreenXPosition,player.Position.ScreenYPosition), Color.White, player.Position.Visible));
baseObject.AddComponent(new Animation(16,16,2));
if (player.Username == _managerNetwork.Username)
{
baseObject.AddComponent(new MainPlayer(_managerNetwork));
}
else
{
baseObject.AddComponent(new Name(_font));
}
_players.Add(baseObject);
}
示例4: LoadContent
public override void LoadContent(ContentManager content)
{
_managerMap.LoadContent();
var player = new BaseObject {Id = "player"};
player.AddComponent(new Sprite(content.Load<Texture2D>("link_full"), 16, 16, new Vector2(50, 50)));
player.AddComponent(new PlayerInput(ManagerScreen,_managerPlayer));
player.AddComponent(new Animation(16, 16,2));
player.AddComponent(new Collision(_managerMap,_entities));
player.AddComponent(new Camera(_managerCamera));
player.AddComponent(new Equipment(content,_managerMap,_managerCamera,_entities));
player.GetComponent<Equipment>(ComponentType.Equipment).AddItem(new Boomerang());
player.GetComponent<Equipment>(ComponentType.Equipment).AddItem(new Sword(_entities));
player.GetComponent<Equipment>(ComponentType.Equipment).EquipItemInSlot(1,ItemSlot.A);
player.GetComponent<Equipment>(ComponentType.Equipment).EquipItemInSlot(2, ItemSlot.B);
player.AddComponent(new Damage(_entities,true));
player.AddComponent(FactoryStats.GetStats("Link"));
player.AddComponent(new GUI());
player.GetComponent<GUI>(ComponentType.GUI).LoadContent(content);
//var testNPC = new BaseObject();
//testNPC.AddComponent(new Sprite(content.Load<Texture2D>("Marin"), 16, 16, new Vector2(50, 50)));
//testNPC.AddComponent(new AIMovementRandom(200));
//testNPC.AddComponent(new Animation(16, 16));
//testNPC.AddComponent(new Collision(_managerMap));
//testNPC.AddComponent(new Camera(_managerCamera));
_entities.AddEntity(player);
//for (int n = 0; n < 3; n++)
//{
// var testEnemy = new BaseObject {Id = string.Format("enemy_{0}", n)};
// testEnemy.AddComponent(new Sprite(content.Load<Texture2D>("Octorok"), 16, 16, new Vector2(50 + ManagerFunction.Random(10,20), 50 + ManagerFunction.Random(10,20))));
// testEnemy.AddComponent(new AIMovementRandom(1000, 0.5f));
// testEnemy.AddComponent(new Animation(16, 16, 2));
// testEnemy.AddComponent(new Collision(_managerMap));
// testEnemy.AddComponent(new Octorok(player, content.Load<Texture2D>("Octorok_bullet"), _managerMap));
// testEnemy.AddComponent(new Camera(_managerCamera));
// testEnemy.AddComponent(new Damage(_entities));
// testEnemy.AddComponent(FactoryStats.GetStats("Octorok"));
// _entities.AddEntity(testEnemy);
//}
//_entities.AddEntity(testNPC);
//Script test!
//var testEnemy = new BaseObject { Id = string.Format("enemy_{0}", "script") };
//testEnemy.AddComponent(new Sprite(content.Load<Texture2D>("Octorok"), 16, 16, new Vector2(50 + ManagerFunction.Random(10, 20), 50 + ManagerFunction.Random(10, 20))));
//testEnemy.AddComponent(new AIMovementRandom(1000, 0.5f));
//testEnemy.AddComponent(new Animation(16, 16, 2));
//testEnemy.AddComponent(new Collision(_managerMap,_entities));
//testEnemy.AddComponent(new Octorok(player, content.Load<Texture2D>("Octorok_bullet"), _managerMap,_entities));
//testEnemy.AddComponent(new Camera(_managerCamera));
//testEnemy.AddComponent(new Damage(_entities));
//testEnemy.AddComponent(FactoryStats.GetStats("Octorok"));
//testEnemy.AddComponent(new Script("script_time_test"));
//_entities.AddEntity(testEnemy);
//Just for test
//var window = new WindowMessage("Hello, this is a message! This is a long message",content);
//ManagerWindow.NewWindow("test_message",window);
}