public BattleTargetSelector(string cursorTextureFileName)
 {
     cursorTexture = GameClass.LoadTextureData("General/playerTurnMenuCursor");
     controls = new GamePadController(PlayerIndex.One);
     debugControls = new KeyboardController();
     controls.ControlsActive = false;
     currentState = BattleTargetSelectorState.Inactive;
     debugControls.ControlsActive = false;
     selectedTargets = new List<BattleCharacter>();
 }
 public PlayerCharacterStatusBox(Vector2 position, PlayerCharacterStatusBoxMode mode)
     : base("General/StatusBoxBG", position, Vector2.Zero)
 {
     this.mode = mode;
        alpha = 0.0f;
        fadeState = FadeState.IdleFaded;
        levelUpOccurred = false;
        newTechniqueLearned = false;
        controls = new GamePadController(PlayerIndex.One);
        debugControls = new KeyboardController();
        addEXPTimer = 0.0f;
 }
Example #3
0
 public Menu(string name, Vector2 position, int menuOptionSpacing, string BGTextureFile, string cursorTextureFile, Vector2 cursorRelativePosition, Vector2 menuItemsDrawOffset, bool displayItemNames)
     : base(BGTextureFile, position, Vector2.Zero)
 {
     cursorTexture = GameClass.LoadTextureData(cursorTextureFile);
       this.menuOptionSpacing = menuOptionSpacing;
       this.cursorRelativePosition = cursorRelativePosition;
       menuOptions = new List<MenuOption>();
       alpha = 0.0f;
       menuState = MenuState.IdleFaded;
       controls = new GamePadController(PlayerIndex.One);
       debugControls = new KeyboardController();
       controls.ControlsActive = false;
       debugControls.ControlsActive = false;
       this.menuItemsDrawOffset = menuItemsDrawOffset;
       this.displayItemNames = displayItemNames;
 }
        public void LoadContent(Vector2 position, CharacterIdentity playerID)
        {
            this.characterID = playerID;
            this.position = position;
            this.CollisionBoxes = new Dictionary<MapCharacterAction, CollisionBox>();

            controls = new GamePadController(PlayerIndex.One);
            debugControls = new KeyboardController();

            MapCharacterData characterData = GameClass.ContentManager.Load<MapCharacterData>(@"MapCharacters/" + playerID.ToString() + "/" + playerID.ToString() + "Map");

            Sprites.Add(MapCharacterAction.Idle, AnimatedSprite.CreateFromData(characterData.idleSpriteData));
            Sprites.Add(MapCharacterAction.Run, AnimatedSprite.CreateFromData(characterData.runSpriteData));
            Sprites.Add(MapCharacterAction.Jump, AnimatedSprite.CreateFromData(characterData.jumpSpriteData));
            Sprites.Add(MapCharacterAction.Fall, AnimatedSprite.CreateFromData(characterData.fallSpriteData));
            Sprites.Add(MapCharacterAction.Land, AnimatedSprite.CreateFromData(characterData.landSpriteData));

            CollisionBoxes = new Dictionary<MapCharacterAction, CollisionBox>();
            CollisionBoxes.Add(MapCharacterAction.Idle, CollisionBox.CreateFromData(characterData.idleSpriteData.collisionBoxData));
            CollisionBoxes.Add(MapCharacterAction.Run, CollisionBox.CreateFromData(characterData.runSpriteData.collisionBoxData));
            CollisionBoxes.Add(MapCharacterAction.Jump, CollisionBox.CreateFromData(characterData.jumpSpriteData.collisionBoxData));
            CollisionBoxes.Add(MapCharacterAction.Fall, CollisionBox.CreateFromData(characterData.fallSpriteData.collisionBoxData));
            CollisionBoxes.Add(MapCharacterAction.Land, CollisionBox.CreateFromData(characterData.landSpriteData.collisionBoxData));

            CollisionSensors.Add(SensorType.Top, new CollisionSensor(CollisionBoxes[MapCharacterAction.Idle], SensorType.Top, 4));
            CollisionSensors.Add(SensorType.Bottom, new CollisionSensor(CollisionBoxes[MapCharacterAction.Idle], SensorType.Bottom, 4));
            CollisionSensors.Add(SensorType.Left, new CollisionSensor(CollisionBoxes[MapCharacterAction.Idle], SensorType.Left, 4));
            CollisionSensors.Add(SensorType.Right, new CollisionSensor(CollisionBoxes[MapCharacterAction.Idle], SensorType.Right, 4));

            portraitTexture = GameClass.ContentManager.Load<Texture2D>(characterData.portraitTextureName);
            walkSpeed = characterData.walkSpeed;
            airInfluence = characterData.airInfluence;
            currentFrictionFactor = characterData.frictionFactor;
            jumpStrength = characterData.jumpStrength;
            mass = characterData.mass;

            CurrentAction = MapCharacterAction.Idle;
            currentCollisionBox = CollisionBoxes[CurrentAction];
        }
 public void LoadContent(MapScreen mapScreen)
 {
     this.mapScreen = mapScreen;
     controls = new GamePadController(PlayerIndex.One);
     debugControls = new KeyboardController();
     GameClass.SoundManager.LoadSound("Audio/dialogSound");
 }
 public override void Initialise()
 {
     controls = new GamePadController(PlayerIndex.One);
     debugControls = new KeyboardController();
     base.Initialise();
 }
        public override void LoadContent()
        {
            //Loads the content for a battle.

            //load the static and resued textures.
            battleBG = GlobalGameInfo.CurrentBattleBG;
            battleHUD = GameClass.LoadTextureData("General/BattleHUD");
            turnChartBG = GameClass.LoadTextureData("General/TurnChartBG");
            statusBarTexture = GameClass.LoadTextureData("General/StatusBar");
            hpBarTexture = GameClass.LoadTextureData("General/HPBar");
            mpBarTexture = GameClass.LoadTextureData("General/MPBar");
            buffArrowTexture = GameClass.LoadTextureData("General/buffArrow");
            turnChartSelection = GameClass.LoadTextureData("General/turnChartSelection");

            //Load in the sound effects used by the BattleScreen.
            GameClass.SoundManager.LoadSound("Audio/dash");
            GameClass.SoundManager.LoadSound("Audio/victory");
            GameClass.SoundManager.LoadSound("Audio/loss");

            //reset the games camera to zero as the BattleScreen does not use the camera.
            GameClass.CurrentGameCamera.Position = Vector2.Zero;

            //Initialise the controllers.
            controls = new GamePadController(PlayerIndex.One);
            controls.ControlsActive = false;
            debugControls = new KeyboardController();
            debugControls.ControlsActive = false;
            restartScreenControls = new KeyboardController();

            //Set up the player turn menu.
            playerTurnMenu = new Menu("Player Turn Menu", new Vector2(138, 172), 8, "General/playerTurnMenuBG", "General/playerTurnMenuCursor", Vector2.Zero, Vector2.Zero, true);
            playerTechniqueMenu = new CharacterTechniqueMenu(new Vector2(150, 172), "General/playerTurnMenuCursor", "General/playerTechniqueMenuBG", new Vector2(59, 12));
            battleInventoryMenu = new BattleInventoryMenu(new Vector2(150, 172), "General/playerTurnMenuCursor", "General/battleInventoryMenuBG", new Vector2(59, 12));
            battleTargetSelector = new BattleTargetSelector("General/playerTurnMenuCursor");

            //Set up and add the options for the player turn menu.
            MenuOption attackOption = new MenuOption("Attack", "Perform a normal attack.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            playerTurnMenu.AddMenuOption(attackOption, true);
            MenuOption defendOption = new MenuOption("Defend", "Defend yourself.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            playerTurnMenu.AddMenuOption(defendOption, false);
            MenuOption skillsOption = new MenuOption("Skills", "Use a special skill.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            playerTurnMenu.AddMenuOption(skillsOption, false);
            MenuOption itemsOption = new MenuOption("Items", "Use an Item.", Color.Black,  Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            playerTurnMenu.AddMenuOption(itemsOption, false);

            //Set up the game over menu.
            gameOverMenu = new Menu("Game Over Menu", new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.CurrentGameCamera.Size.X / 2, GameClass.CurrentGameCamera.Position.Y + GameClass.CurrentGameCamera.Size.Y / 2), 8, "General/gameOverMenuBG", "General/playerTurnMenuCursor", Vector2.Zero, new Vector2(0, 50), true);
            MenuOption retryOption = new MenuOption("Retry", "Retry this battle from the beginning.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            gameOverMenu.AddMenuOption(retryOption, true);
            MenuOption quitOption = new MenuOption("Quit", "Quit the game.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected");
            gameOverMenu.AddMenuOption(quitOption, false);

            //Set up the info bar.
            infoBar = new InfoBar("General/InfoBarBG", new Vector2(230, 10), GameClass.Size8Font, Color.White, new Vector2(-225, -10), 0.1f);

            //For all the items in the players general inventory, check which are battle items and set them up as new BattleItem objects, loading their effect data from BattleCharacters/BattleItemList.xml into the battle inventory.
            List<BattleItemData> battleItemDataList = GameClass.ContentManager.Load<List<BattleItemData>>("BattleCharacters/BattleItemDataList");
            foreach (KeyValuePair<InventoryItemIdentity, int> inventoryItem in GlobalGameInfo.Inventory)
            {
                foreach (BattleItemData battleItemData in battleItemDataList)
                {
                    if (battleItemData.itemID == inventoryItem.Key)
                    {
                        BattleItem newBattleItem = new BattleItem();
                        newBattleItem.LoadContent(battleItemData, inventoryItem.Value);
                        battleItemInventory.Add(newBattleItem);
                    }
                }
            }

            //Initialise the status box list.
            playerStatusBoxes = new List<PlayerCharacterStatusBox>();

            //For the first three characters in the players party, load the characters sprites and techniques from <characterName>Battle.xml and load their stats from the PartyCharacter into a BattleCharacter
            //The players party takes up Battle Orders 0-2.
            int battleOrder = 0;
            int statusBoxDrawPos = 110;
            for (int count = 0; count < 3; count++)
            {
                if (GlobalGameInfo.CurrentPlayerParty[count] != null)
                {
                    PlayerBattleCharacter newPlayerCharacter = new PlayerBattleCharacter();
                    newPlayerCharacter.LoadContent(battleOrder, GlobalGameInfo.CurrentPlayerParty[count]);
                    activeCharacters.Add(newPlayerCharacter);
                    battleOrder ++;

                    //Create a new status box for each loaded character.
                    PlayerCharacterStatusBox newStatusBox = new PlayerCharacterStatusBox(new Vector2(statusBoxDrawPos, 170), PlayerCharacterStatusBoxMode.EndOfBattle);
                    newStatusBox.LoadContent(GlobalGameInfo.CurrentPlayerParty[count]);
                    playerStatusBoxes.Add(newStatusBox);
                    statusBoxDrawPos += 210;
                }
            }

            //Load the enemies.
            battleOrder = 3;
            if (retryingBattle == false)
            {//If this battle is a fresh battle....

                //load the 'mandatory' enemy (i.e. The map enemy that the player collided with) into the first enemy slot (Battle Order 3)
                EnemyBattleCharacter mandatoryEnemyCharacter = new EnemyBattleCharacter();
                mandatoryEnemyCharacter.LoadContent(battleOrder, GlobalGameInfo.CurrentEnemyInBattle.CharacterID);
                activeCharacters.Add(mandatoryEnemyCharacter);
                enemyGroupLostTo.Add(GlobalGameInfo.CurrentEnemyInBattle.CharacterID);
                battleOrder++;

                //Load in BattleCharacters/EnemyDifficultyList.xml and find the 'mandatory' enemy's difficulty rating.
                List<EnemyDifficultyData> enemyDifficultyList  = GameClass.ContentManager.Load<List<EnemyDifficultyData>>("BattleCharacters/EnemyDifficultyList");
                int currentEnemyDifficulty = -1;
                int spawnEnemy = 0;
                foreach (EnemyDifficultyData difficultyData in enemyDifficultyList)
                {
                    if (difficultyData.enemyID == GlobalGameInfo.CurrentEnemyInBattle.CharacterID)
                    {
                        currentEnemyDifficulty = difficultyData.difficultyLevel;
                    }
                }
                //Iterate through BattleCharacters/EnemyDifficultyList.xml and retrieve all enemies of a similar difficulty rating (i.e. within a range of -1 to 1 from it)
                List<CharacterIdentity> similarDifficultyEnemies = new List<CharacterIdentity>();
                foreach (EnemyDifficultyData difficultyData in enemyDifficultyList)
                {
                    if (Math.Abs(difficultyData.difficultyLevel - currentEnemyDifficulty) < 2)
                    {
                        similarDifficultyEnemies.Add(difficultyData.enemyID);
                    }
                }

                if (similarDifficultyEnemies.Count > 0)
                {//if there are more enemies of a similar difficulty....
                    for (int count = 0; count < 2; count++)
                    {//for the rest of the enemy slots (Battle Orders 4 and 5)....

                        //Decide randomly whether to spawn another enemy.
                        spawnEnemy = GameClass.Random.Next(0, 2);
                        if (spawnEnemy == 1)
                        {//if decided to spawn another enemy...
                            //Decide randomly which enemy to spawn, and load it in.
                            CharacterIdentity enemyToSpawn = similarDifficultyEnemies[GameClass.Random.Next(0, similarDifficultyEnemies.Count)];
                            EnemyBattleCharacter optionalEnemyCharacter = new EnemyBattleCharacter();
                            optionalEnemyCharacter.LoadContent(battleOrder, enemyToSpawn);
                            activeCharacters.Add(optionalEnemyCharacter);
                            enemyGroupLostTo.Add(enemyToSpawn);
                            battleOrder++;
                        }
                    }
                }
            }
            else if(retryingBattle == true)
            {//Otherwise if this battle is a retry, load the previous enemy group back in.
                foreach (CharacterIdentity enemyID in enemyGroupLostTo)
                {
                    EnemyBattleCharacter reloadedEnemyCharacter = new EnemyBattleCharacter();
                    reloadedEnemyCharacter.LoadContent(battleOrder, enemyID);
                    activeCharacters.Add(reloadedEnemyCharacter);
                    battleOrder++;
                }
                retryingBattle = false;
            }

            //Add all the loaded characters to the draw list.
            foreach (BattleCharacter character in activeCharacters)
            {
                drawList.Add(character);
            }

            //Initialise the turn chart and its indicator.
            turnChartSelectorFadeState = AlternatingFadeState.FadingOut;
            turnChartSelectionAlpha = 1.0f;
            currentTurnCount = 1;
            currentTurnIndex = 0;

            //Calculate the first turns order.
            CalculateTurnOrder();
        }