/// <summary>
        /// Constructs the arena. Also constructs several platforms and physics elements
        /// which need to get added to the EntityManager and PhysicsSimulator.
        /// </summary>
        /// <param name="entityManager"></param>
        /// <param name="physicsSimulator"></param>
        public SplitBaseArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
        {
            // Create the platforms.
            float focus = 15.0f;
            Platform leftGround = new Platform(new Vector3(-focus, 0, 0), 22.0f, 2.0f, 5.0f);
            Platform rightGround = new Platform(new Vector3(focus, 0, 0), 22.0f, 2.0f, 5.0f);

            Platforms.Add(leftGround);
            entityManager.AddEntity(leftGround);
            physicsSimulator.AddPhysicsEntity(leftGround.GetBox());

            Platforms.Add(rightGround);
            entityManager.AddEntity(rightGround);
            physicsSimulator.AddPhysicsEntity(rightGround.GetBox());

            // Create the Spawn Positions
            spawnPositions = new List<Vector3>();
            spawnPositions.Add(new Vector3(-15, 10, 0));
            spawnPositions.Add(new Vector3(-5, 15, 0));
            spawnPositions.Add(new Vector3(5, 15, 0));
            spawnPositions.Add(new Vector3(15, 10, 0));

            // Create the Bounding box.
            boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
        }
        /// <summary>
        /// Constructs the arena. Also constructs several platforms and physics elements
        /// which need to get added to the EntityManager and PhysicsSimulator.
        /// </summary>
        /// <param name="entityManager"></param>
        /// <param name="physicsSimulator"></param>
        public DeathPitArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
        {
            // Create the platforms.
            Platform left = new Platform(new Vector3(-30, 5.5f, 0), 15.0f, 20.0f, 5.0f);
            Platform right = new Platform(new Vector3(30, 5.5f, 0), 15.0f, 20.0f, 5.0f);
            Platform mid = new Platform(new Vector3(0, -3, 0), 60.0f, 3.0f, 5.0f);
            Platform centerPlat = new Platform(new Vector3(0, 10, 0), 10.0f, 1.0f, 5.0f);
            left.GetBox().Material.KineticFriction = 0;
            left.GetBox().Material.StaticFriction = 0;
            right.GetBox().Material.KineticFriction = 0;
            right.GetBox().Material.StaticFriction = 0;

            Platforms.Add(left);
            entityManager.AddEntity(left);
            physicsSimulator.AddPhysicsEntity(left.GetBox());
            Platforms.Add(right);
            entityManager.AddEntity(right);
            physicsSimulator.AddPhysicsEntity(right.GetBox());
            Platforms.Add(mid);
            entityManager.AddEntity(mid);
            physicsSimulator.AddPhysicsEntity(mid.GetBox());
            Platforms.Add(centerPlat);
            entityManager.AddEntity(centerPlat);
            physicsSimulator.AddPhysicsEntity(centerPlat.GetBox());

            // Create the Spawn Positions
            spawnPositions = new List<Vector3>();
            spawnPositions.Add(new Vector3(-15, 10, 0));
            spawnPositions.Add(new Vector3(-5, 15, 0));
            spawnPositions.Add(new Vector3(5, 15, 0));
            spawnPositions.Add(new Vector3(15, 10, 0));

            // Create the Bounding box.
            boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
        }
 public ItemManagerComponent(Entity parent, EntityManager entityManager, PhysicsSimulator physics, Arena arena)
     : base(parent, "ItemManagerComponent")
 {
     this.entityManager = entityManager;
     this.physics = physics;
     this.arena = arena;
     this.Items = new List<Item>();
 }
        public ItemManager(EntityManager entityManager, PhysicsSimulator physics, Environment environment, bool itemDropsAllowed)
        {
            if (itemDropsAllowed)
            {
                ItemSpawnComponent itemSpawner = new ItemSpawnComponent(this, environment);
                this.AttachComponent(itemSpawner);
            }

            this.itemManager = new ItemManagerComponent(this, entityManager, physics, environment.Arena);
            this.AttachComponent(itemManager);
        }
        /// <summary>
        /// Constructs the arena. Also constructs several platforms and physics elements
        /// which need to get added to the EntityManager and PhysicsSimulator.
        /// </summary>
        /// <param name="entityManager"></param>
        /// <param name="physicsSimulator"></param>
        public WalledArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
        {
            // Create the platforms.
            Platform ground = new Platform(new Vector3(0, -0.5f, 0), 50.0f, 3.0f, 5.0f);

            float xOffset = 25.0f;
            int heightStart = 8;
            int heightStop = 40;

            // Create the left wall
            for (int height = heightStart; height < heightStop; height++)
            {
                Platform leftWall = new Platform(new Vector3(-xOffset, height, 0.0f), 1.0f, 1.0f, 5.0f);
                leftWall.GetBox().Material.KineticFriction = 0;
                leftWall.GetBox().Material.StaticFriction = 0;
                Platforms.Add(leftWall);
                entityManager.AddEntity(leftWall);
                physicsSimulator.AddPhysicsEntity(leftWall.GetBox());
            }

            // Create the right wall
            for (int height = heightStart; height < heightStop; height++)
            {
                Platform rightWall = new Platform(new Vector3(xOffset, height, 0.0f), 1.0f, 1.0f, 5.0f);
                rightWall.GetBox().Material.KineticFriction = 0;
                rightWall.GetBox().Material.StaticFriction = 0;

                Platforms.Add(rightWall);
                entityManager.AddEntity(rightWall);
                physicsSimulator.AddPhysicsEntity(rightWall.GetBox());
            }

            Platforms.Add(ground);
            entityManager.AddEntity(ground);
            physicsSimulator.AddPhysicsEntity(ground.GetBox());

            // Create the Spawn Positions
            spawnPositions = new List<Vector3>();
            spawnPositions.Add(new Vector3(-15, 10, 0));
            spawnPositions.Add(new Vector3(-5, 15, 0));
            spawnPositions.Add(new Vector3(5, 15, 0));
            spawnPositions.Add(new Vector3(15, 10, 0));

            // Create the Bounding box.
            boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
        }
Example #6
0
        /// <summary>
        /// Constructs the arena. Also constructs several platforms and physics elements
        /// which need to get added to the EntityManager and PhysicsSimulator.
        /// </summary>
        /// <param name="entityManager"></param>
        /// <param name="physicsSimulator"></param>
        public PlainArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
        {
            // Create the platforms.
            Platform ground = new Platform(new Vector3(0, 0, 0), 50.0f, 3.0f, 5.0f);
            Platforms.Add(ground);
            entityManager.AddEntity(ground);
            physicsSimulator.AddPhysicsEntity(ground.GetBox());

            // Create the Spawn Positions
            spawnPositions = new List<Vector3>();
            spawnPositions.Add(new Vector3(-15, 10, 0));
            spawnPositions.Add(new Vector3(-5, 15, 0));
            spawnPositions.Add(new Vector3(5, 15, 0));
            spawnPositions.Add(new Vector3(15, 10, 0));

            // Create the Bounding box.
            boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
        }
        /// <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();
        }