コード例 #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
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.frmMonster1 = ((Deliverable6.frmMonster)(target));
                return;

            case 2:
                this.tbHeroName = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.tbMonsterName = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 4:
                this.tbHeroHP = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 5:
                this.tbMonsterHP = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 6:
                this.btnAttack = ((System.Windows.Controls.Button)(target));

            #line 28 "..\..\frmMonster.xaml"
                this.btnAttack.Click += new System.Windows.RoutedEventHandler(this.btnAttack_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.btnRunAway = ((System.Windows.Controls.Button)(target));

            #line 29 "..\..\frmMonster.xaml"
                this.btnRunAway.Click += new System.Windows.RoutedEventHandler(this.btnRunAway_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }