Exemplo n.º 1
0
        /// <summary>
        /// Gets frmItem or frmMonster when hero moves down
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDown_Click(object sender, RoutedEventArgs e)
        {
            if (Game.Map.MoveHero(Actor.Direction.Down))
            {
                Window wind = null;

                if (Game.Map.CurrentLocation.HasItem)
                {
                    if (Game.Map.CurrentLocation.Item.GetType() == typeof(Door))
                    {
                        wind = new frmGameOver();
                    }
                    else
                    {
                        wind = new frmItem();
                    }
                }

                else if (Game.Map.CurrentLocation.HasMonster)
                {
                    wind = new frmMonster();
                }
                if (wind != null)
                {
                    wind.ShowDialog();
                }
            }
            ShowContent();
            AssignGameState();
        }
Exemplo n.º 2
0
        /// <summary>
        /// making the move button which make hero to enable in map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnMove_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            Actor.Direction dir       = (Actor.Direction)btn.Tag;
            bool            needToAct = Game.Map.MoveAdventurer(dir);

            if (needToAct)
            {
                Window wnd = null;

                if (Game.Map.CurrentLocation.HasItem)
                {
                    wnd = new frmItem();
                }
                // checking wether the hero current location has door
                if (Game.Map.CurrentLocation.Item is Door)
                {
                    Game.State = Game.GameState.Won;
                    wnd        = new frmGameOver();
                }
                else if (Game.Map.CurrentLocation.HasMonster)
                {
                    wnd = new frmMonster();
                }
                else
                {
                    // do nothing
                }
                if (wnd != null)
                {
                    wnd.ShowDialog();
                }
            }

            DrawMap();
            updateDetail();
        }