本文整理汇总了C#中Environment.AddCharacter方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.AddCharacter方法的具体用法?C# Environment.AddCharacter怎么用?C# Environment.AddCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment.AddCharacter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadContent
/// <summary>
/// Load assets used by the game
/// </summary>
public override void LoadContent()
{
// Create the Content Manager.
if (content == null)
{
content = new ContentManager(ScreenManager.Game.Services, "Content");
}
// Load content necessary for the battle screen
ContentLoader.LoadContent(content);
// Create the Entity Manager.
entityManager = new EntityManager(content);
// Create the physics simulator
PhysicsSimulator physicsEntity = new PhysicsSimulator();
// Create the Arena Entity.
Arena arenaEntity = null;
if (GameSettings.Arena == GameSettings.ARENA_SETTING.PLAIN_ARENA)
{
arenaEntity = new PlainArena(entityManager, physicsEntity);
}
else if (GameSettings.Arena == GameSettings.ARENA_SETTING.WALLED_ARENA)
{
arenaEntity = new WalledArena(entityManager, physicsEntity);
}
else if (GameSettings.Arena == GameSettings.ARENA_SETTING.SPLIT_BASE)
{
arenaEntity = new SplitBaseArena(entityManager, physicsEntity);
}
else if (GameSettings.Arena == GameSettings.ARENA_SETTING.PIT_OF_DEATH)
{
arenaEntity = new DeathPitArena(entityManager, physicsEntity);
}
// Create the environment
Environment environment = new Environment(arenaEntity);
// Create the Item Spawner
ItemManager itemManager = new ItemManager(entityManager, physicsEntity, environment, GameSettings.ItemsOn);
environment.SetItemManager(itemManager);
// Create the Camera Entity.
Camera gameCamera = new Camera(new Vector3(0, 10, 60), Vector3.Zero + new Vector3(0, 20, -100), Vector3.Up );
Camera debugCamera = new Camera(new Vector3(0, 20, 40), Vector3.Zero, Vector3.Up);
debugCameraComponent = new DebugCameraComponent(debugCamera);
debugCamera.AttachComponent(debugCameraComponent);
cameraEntities.Add(gameCamera); // Game Camera
cameraEntities.Add(debugCamera); // Debug Camera
// Create the Characters.
List<PlayerSettings> players = GameSettings.GetPlayers();
characters = new List<Character>(numPlayers);
foreach (PlayerSettings player in players)
{
if (player.Character == GameSettings.CHARACTER_SETTING.ROBOT)
{
Character character = new FightingRobot(numLives, arenaEntity.GetCharacterSpawnPosition(), player.PlayerIndex, player.Team, environment, player.Color);
physicsEntity.AddPhysicsEntity(character.GetBox());
characters.Add(character);
environment.AddCharacter(character);
}
}
// Create the Hud
HUD hud = new HUD(characters);
// Add the entities to the Entity Manager and init the manager
entityManager.AddEntity(arenaEntity);
entityManager.AddEntity(gameCamera);
entityManager.AddEntity(debugCamera);
entityManager.AddEntity(physicsEntity);
entityManager.AddEntity(itemManager);
for (int i = 0; i < characters.Count; i++)
{
entityManager.AddEntity(characters[i]);
}
entityManager.AddEntity(hud);
entityManager.Initialize();
// Track the characters that are alive
livingCharacters = new List<Character>();
for (int i = 0; i < characters.Count; i++)
{
livingCharacters.Add(characters[i]);
}
AudioManager.StartBattleMusic();
}