예제 #1
0
        /// <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();
        }