/// <summary> /// Boss room constructor /// </summary> /// <param name="finalBoss">Pass in true only if this is the final boss room</param> public Room(double level, Player player, bool finalBoss = false) { //Put the boss in the room // indicies 1-4 should be empty enemies = new Enemy[5]; if (finalBoss == false) { EnemyType temp = EnemiesDirectory.RANDOM(); enemies[0] = new Enemy(temp, level * 3, new Point(650, 100), 150, 380, player, temp.HatPosition); } else { enemies[0] = new Enemy(EnemiesDirectory.BOSS, level * 3, new Point(650, 100), 150, 380, player, EnemiesDirectory.BOSS.HatPosition); } enemies[0].Name += " Boss"; enemies[1] = null; enemies[2] = null; enemies[3] = null; enemies[4] = null; //Give the boss hats for (int k = 0; k < level; k++) { HatsDirectory.GetRandomHat(level * 2).Equip(enemies[0]); } //A currentAttacker of 5 indicates that all enemies have attacked IsVisible = false; currentAttacker = 0; description = ""; }
/// <summary> /// Initializes content that requires textures or fonts /// </summary> private void PostInitialize() { EnemiesDirectory.SetUp(); RoomsDirectory.ReadRooms("temp"); HatsDirectory.SetUp(); menu = new Menu(); instructions = new Instructions(); play = new Play(); }
/// <summary> /// Basic room constructor /// </summary> public Room(RoomLayout layout, double level, Player player) { //Fill the room with enemies enemies = new Enemy[5]; for (int k = 0; k < 5; k++) { if (layout[k] != null) { if (k % 2 == 0) { enemies[k] = new Enemy(layout[k], level, new Point((int)(SpritesDirectory.width * .8215), //650 (k * (int)(SpritesDirectory.height * .125)) + (int)(SpritesDirectory.height * .0625)), //(k * 60) + 30 (int)(SpritesDirectory.width * .09375), //75 (int)(SpritesDirectory.height * .3125), //150 player, layout[k].HatPosition); enemies[k].Name += (" " + (k + 1)); } else { enemies[k] = new Enemy(layout[k], level, new Point((int)(SpritesDirectory.width * .6875), //550 (k * (int)(SpritesDirectory.height * .125)) + (int)(SpritesDirectory.height * .125)), //(k * 60) + 60 (int)(SpritesDirectory.width * .09375), //75 (int)(SpritesDirectory.height * .3125), //150 player, layout[k].HatPosition); enemies[k].Name += (" " + (k + 1)); } } else { enemies[k] = null; } } //Give the enemies hats based on the current level int hats = (int)level; for (int k = 0; k < level; k++) { //get the index of a random non-null enemy int randomEnemy = EnemiesDirectory.random.Next(5); while (enemies[randomEnemy] == null) { randomEnemy = EnemiesDirectory.random.Next(5); } //Give a random hat to the random enemy HatsDirectory.GetRandomHat(level).Equip(enemies[randomEnemy]); } //A currentAttacker of 5 indicates that all enemies have attacked IsVisible = false; currentAttacker = 0; description = ""; }
public MainState Update(GameTime time) { #region Update //Update the current keyboard and mouse state mouseLast = mouseCurrent; mouseCurrent = Mouse.GetState(); keyboardLast = keyboardCurrent; keyboardCurrent = Keyboard.GetState(); //Update the gameplay based on the current state and inputs switch (state) { case PlayState.PlayerInput: if (!player.IsActive) { state = PlayState.CombatEnd; } else { state = GetPlayerInput(); } if (state == PlayState.PlayerAttack) { //Hide buttons foreach (Button ab in abilityButton) { ab.IsActive = ab.IsVisible = false; } player.Animation.SetSprite(SpritesDirectory.GetSprite("StatusEffect"), 10, 116, 1523, 826); description.IsVisible = true; } break; case PlayState.PlayerAttack: //Placeholder state for player animations player.Animation.UpdateAnimation(time); //call the event when the PlayState changes if (player.Animation.IsDone) { player.TurnEnd(); state = PlayState.EnemyTurn; } break; case PlayState.EnemyTurn: state = floor.Peek().TakeEnemyTurn(player, time); //Update the description text to describe the current enemy attack description.Text = floor.Peek().Description; if (state == PlayState.PlayerInput) { player.TurnStart(); //Reveal buttons foreach (Button ab in abilityButton) { ab.IsActive = ab.IsVisible = true; } } else if (state == PlayState.CombatEnd) { description.IsVisible = true; //Get the dropped hat and remove the room droppedHat = HatsDirectory.GetRandomHat(floorLevel, floor.Dequeue().GetDroppedHats()); if (player.IsActive) { player.Loot = droppedHat; } //Hide buttons abilityButton[4].IsVisible = abilityButton[4].IsActive = false; abilityButton[5].IsVisible = abilityButton[5].IsActive = false; if (droppedHat.HasAbility) { //Make and enable the ability to select the new ability Rectangle newAbilityRect = new Rectangle((int)(SpritesDirectory.width * .75), (int)(SpritesDirectory.height * .755), (int)(SpritesDirectory.width * .1875), (int)(SpritesDirectory.height * .1042)); newAbilityButton = new Button(droppedHat.Ability.Name, newAbilityRect, SpritesDirectory.GetFont("Arial40")); newAbilityButton.IsVisible = newAbilityButton.IsActive = true; abilityButton[0].IsVisible = abilityButton[0].IsActive = true; abilityButton[1].IsVisible = abilityButton[1].IsActive = true; abilityButton[2].IsVisible = abilityButton[2].IsActive = true; abilityButton[3].IsVisible = abilityButton[3].IsActive = true; } //Disable all the ability buttons if there is no new ability to select else { abilityButton[0].IsVisible = abilityButton[0].IsActive = false; abilityButton[1].IsVisible = abilityButton[1].IsActive = false; abilityButton[2].IsVisible = abilityButton[2].IsActive = false; abilityButton[3].IsVisible = abilityButton[3].IsActive = false; } } break; case PlayState.CombatEnd: if (keyboardCurrent.IsKeyDown(Keys.Enter) && keyboardLast.IsKeyUp(Keys.Enter) && (!player.IsActive || ((lastClicked != null && lastClicked.Clicked) || (player.Loot != null && !player.Loot.HasAbility)))) { if (!player.IsActive) { return(MainState.Menu); } if (player.Loot != null) { if (player.Loot.HasAbility && temp != 0) { player.Loot.Equip(player, temp); player.Loot = null; abilityButton[temp] = new Button(player.Abilities[temp].Name, abilityButton[temp].Rect, SpritesDirectory.GetFont("Arial40")); } else { player.Loot.Equip(player); player.Loot = null; } } //Move to the next combat if the floor still has rooms left if (floor.Count > 0) { state = PlayState.PlayerInput; } //Move to the safe room if the current floor has been completed else { state = PlayState.SafeRoom; } if (state == PlayState.PlayerInput) { floor.Peek().IsVisible = true; } if (state == PlayState.PlayerInput) { floor.Peek().IsVisible = true; } } else if (player.Loot != null) { if (player.Loot.HasAbility) { #region Ability selection //Enable ability buttons for (int k = 0; k < 4; k++) { if (abilityButton[k].IsPressed(mouseLast, mouseCurrent)) { if (lastClicked != null) { lastClicked.Clicked = false; } lastClicked = abilityButton[k]; abilityButton[k].Clicked = true; temp = k; } } if (newAbilityButton.IsPressed(mouseLast, mouseCurrent)) { if (lastClicked != null) { lastClicked.Clicked = false; } lastClicked = newAbilityButton; newAbilityButton.Clicked = true; } #endregion } } if (state == PlayState.PlayerInput) { //Reveal buttons foreach (Button ab in abilityButton) { ab.IsActive = ab.IsVisible = true; } } else if (state == PlayState.SafeRoom) { description.IsVisible = true; description.Text = "You feel safe here and take a moment to rest...\n" + "Press ENTER to continue"; safeRoom.SetUp(player.Hats.Count); } break; case PlayState.SafeRoom: state = safeRoom.Update(keyboardCurrent, keyboardLast); if (state == PlayState.PlayerInput) { player.CurrentMP = player.MaxMP; player.Health = player.MaxHealth; floorLevel++; GenerateFloor(); floor.Peek().IsVisible = true; //Reveal buttons foreach (Button ab in abilityButton) { ab.IsActive = ab.IsVisible = true; } description.IsVisible = false; } break; } return(MainState.Play); #endregion }