当前位置: 首页>>代码示例>>C#>>正文


C# Environment.AddCharacter方法代码示例

本文整理汇总了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();
        }
开发者ID:regenvanwalbeek,项目名称:BattleFury,代码行数:94,代码来源:BattleScreen.cs


注:本文中的Environment.AddCharacter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。