예제 #1
0
        /// <summary>
        /// Displays dialogbox if needed
        /// </summary>
        /// <param name="cell"></param>
        public void HandleCell(MapCell cell)
        {
            if (cell.HasItem) {
                if (cell.Item is DoorKey) {
                    Game.Map.Adventurer.ApplyItem(cell.Item);
                    updateHeroDetails();
                }
                if (cell.Item is Door) {
                    //Had to cast to compare
                    Door mapDoor = (Door)cell.Item;
                    frmGameOver gameOver = new frmGameOver();
                    gameOver.ShowDialog();
                    return;
                }
                displayMap(Game.Map);
                frmItem founditem = new frmItem(cell.Item);
                founditem.ShowDialog();

                updateHeroDetails();
            }
            if (cell.HasMonster) {
                displayMap(Game.Map);
                frmMonster foundmonster = new frmMonster(cell.Monster);
                foundmonster.ShowDialog();

                updateHeroDetails();
                checkGameState();
            }
        }
예제 #2
0
 /// <summary>
 /// Displays frmItem if hero's location contains an item, or frmMonster if hero's location contains a monster.
 /// </summary>
 /// <param name="needsToAct">Whether or not hero needs to act in this cell. Get from Game.Map.moveHero().</param>
 private static void displayForm(bool needsToAct)
 {
     if (needsToAct)                                                   // if hero's cell contains an item or monster, display frmItem or frmMonster.
     {
         if (Game.Map.HeroLocation.HasItem)                            // if the cell contains an item, disply frmItem.
         {
             if (Game.Map.HeroLocation.Item.GetType() == typeof(Door)) // but, if the item is a door, display the Game Over screen.
             {
                 frmGameOver frmGameOver = new frmGameOver();
                 frmGameOver.ShowDialog();
             }
             else   // cell has item, which is not a door. display frmItem.
             {
                 frmItem frmItem = new frmItem(Game.Map.HeroLocation.Item);
                 frmItem.ShowDialog();
             }
         }
         else // cell doesn't have item, but does need attention.  display frmMonster.
         {
             // open new monster form window.
             frmMonster frmMonster = new frmMonster(Game.Map.HeroLocation.Monster);
             frmMonster.ShowDialog();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Displays game over window if game is lost.
 /// </summary>
 private static void handleGameState()
 {
     if (Game.GameState == Game.Gamestate.Lost) // if the current gamestate is lost, display the frmGameOver window.
     {
         frmGameOver frmGameOver = new frmGameOver();
         frmGameOver.ShowDialog();
     }
 }
예제 #4
0
 /// <summary>
 /// Checks game state and displays dialogbox if needed
 /// </summary>
 public void checkGameState()
 {
     if (Game.GameState == Game.GameStateEnum.Lost) {
         frmGameOver gameOver = new frmGameOver();
         gameOver.ShowDialog();
     }
     if (Game.GameState == Game.GameStateEnum.Won) {
         frmGameOver gameOver = new frmGameOver();
         gameOver.ShowDialog();
     }
 }