コード例 #1
0
        /**
         * Parse and execute the current command
         * Give "Warning" on illegal commands.
         */
        public static void process_command(bool no_request)
        {
            bool     done = true;
            ui_event e;

            /* Reset argument before getting command */
            Misc.p_ptr.command_arg = 0;
            e = TextUI.get_command();

            if (e.type == ui_event_type.EVT_RESIZE)
            {
                Do_Command.redraw();
            }

            else if (e.type == ui_event_type.EVT_MOUSE)
            {
                TextUI.process_click(e);
            }

            else if (e.type == ui_event_type.EVT_KBRD)
            {
                done = TextUI.process_key(e.key);
            }

            if (!done)
            {
                Do_Command.unknown();
            }
        }
コード例 #2
0
        /*
         * Move player in the given direction.
         *
         * This routine should only be called when energy has been expended.
         *
         * Note that this routine handles monsters in the destination grid,
         * and also handles attempting to move into walls/doors/rubble/etc.
         */
        public static void move_player(int dir, bool disarm)
        {
            int py = Misc.p_ptr.py;
            int px = Misc.p_ptr.px;

            int y = py + Misc.ddy[dir];
            int x = px + Misc.ddx[dir];

            int m_idx = Cave.cave.m_idx[y][x];

            /* Attack monsters */
            if (m_idx > 0)
            {
                /* Mimics surprise the player */
                if (Monster.Monster.is_mimicking(m_idx))
                {
                    throw new NotImplementedException();
                    //become_aware(m_idx);

                    ///* Mimic wakes up */
                    //mon_clear_timed(m_idx, MON_TMD_SLEEP, MON_TMD_FLG_NOMESSAGE, false);
                }
                else
                {
                    Attack.py_attack(y, x);
                }
            }

            /* Optionally alter traps/doors on movement */
            else if (disarm && (Cave.cave.info[y][x] & Cave.CAVE_MARK) != 0 &&
                     (Cave.cave_isknowntrap(Cave.cave, y, x) ||
                      Cave.cave_iscloseddoor(Cave.cave, y, x)))
            {
                /* Auto-repeat if not already repeating */
                if (Game_Command.get_nrepeats() == 0)
                {
                    Game_Command.set_repeat(99);
                }

                Do_Command.alter_aux(dir);
            }

            /* Cannot walk through walls */
            else if (!Cave.cave_floor_bold(y, x))
            {
                /* Disturb the player */
                Cave.disturb(Misc.p_ptr, 0, 0);

                /* Notice unknown obstacles */
                if ((Cave.cave.info[y][x] & Cave.CAVE_MARK) == 0)
                {
                    /* Rubble */
                    if (Cave.cave.feat[y][x] == Cave.FEAT_RUBBLE)
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "You feel a pile of rubble blocking your way.");
                        Cave.cave.info[y][x] |= (Cave.CAVE_MARK);
                        Cave.cave_light_spot(Cave.cave, y, x);
                    }

                    /* Closed door */
                    else if (Cave.cave.feat[y][x] < Cave.FEAT_SECRET)
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "You feel a door blocking your way.");
                        Cave.cave.info[y][x] |= (Cave.CAVE_MARK);
                        Cave.cave_light_spot(Cave.cave, y, x);
                    }

                    /* Wall (or secret door) */
                    else
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "You feel a wall blocking your way.");
                        Cave.cave.info[y][x] |= (Cave.CAVE_MARK);
                        Cave.cave_light_spot(Cave.cave, y, x);
                    }
                }

                /* Mention known obstacles */
                else
                {
                    if (Cave.cave.feat[y][x] == Cave.FEAT_RUBBLE)
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "There is a pile of rubble blocking your way.");
                    }
                    else if (Cave.cave.feat[y][x] < Cave.FEAT_SECRET)
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "There is a door blocking your way.");
                    }
                    else
                    {
                        Utilities.msgt(Message_Type.MSG_HITWALL, "There is a wall blocking your way.");
                    }
                }
            }

            /* Normal movement */
            else
            {
                /* See if trap detection status will change */
                bool old_dtrap = ((Cave.cave.info2[py][px] & (Cave.CAVE2_DTRAP)) != 0);
                bool new_dtrap = ((Cave.cave.info2[y][x] & (Cave.CAVE2_DTRAP)) != 0);

                /* Note the change in the detect status */
                if (old_dtrap != new_dtrap)
                {
                    Misc.p_ptr.redraw |= (Misc.PR_DTRAP);
                }

                /* Disturb player if the player is about to leave the area */
                if (Option.disturb_detect.value && Misc.p_ptr.running != 0 &&
                    !Misc.p_ptr.running_firststep && old_dtrap && !new_dtrap)
                {
                    Cave.disturb(Misc.p_ptr, 0, 0);
                    return;
                }

                /* Move player */
                Monster.Monster.monster_swap(py, px, y, x);

                /* New location */
                y = py = Misc.p_ptr.py;
                x = px = Misc.p_ptr.px;

                /* Searching */
                if (Misc.p_ptr.searching != 0 || (Misc.p_ptr.state.skills[(int)Skill.SEARCH_FREQUENCY] >= 50) ||
                    Random.one_in_(50 - Misc.p_ptr.state.skills[(int)Skill.SEARCH_FREQUENCY]))
                {
                    search(false);
                }

                /* Handle "store doors" */
                if ((Cave.cave.feat[Misc.p_ptr.py][Misc.p_ptr.px] >= Cave.FEAT_SHOP_HEAD) &&
                    (Cave.cave.feat[Misc.p_ptr.py][Misc.p_ptr.px] <= Cave.FEAT_SHOP_TAIL))
                {
                    /* Disturb */
                    Cave.disturb(Misc.p_ptr, 0, 0);
                    Game_Command.insert(Command_Code.ENTER_STORE);
                }

                /* All other grids (including traps) */
                else
                {
                    /* Handle objects (later) */
                    Misc.p_ptr.notice |= (Misc.PN_PICKUP);
                }


                /* Discover invisible traps */
                if (Cave.cave.feat[y][x] == Cave.FEAT_INVIS)
                {
                    /* Disturb */
                    Cave.disturb(Misc.p_ptr, 0, 0);

                    /* Message */
                    Utilities.msg("You found a trap!");

                    /* Pick a trap */
                    Trap.pick_trap(y, x);

                    /* Hit the trap */
                    Trap.hit_trap(y, x);
                }

                /* Set off an visible trap */
                else if (Cave.cave_isknowntrap(Cave.cave, y, x))
                {
                    /* Disturb */
                    Cave.disturb(Misc.p_ptr, 0, 0);

                    throw new NotImplementedException();
                    /* Hit the trap */
                    //hit_trap(y, x);
                }
            }

            Misc.p_ptr.running_firststep = false;
        }
コード例 #3
0
        /* Allow the user to select from the current menu, and return the
         * corresponding command to the game.  Some actions are handled entirely
         * by the UI (displaying help text, for instance). */
        static birth_stage menu_question(birth_stage current, Menu_Type current_menu, Command_Code choice_command)
        {
            birthmenu_data menu_data = current_menu.menu_data as birthmenu_data;

            birth_stage next = birth_stage.BIRTH_RESET;

            /* Print the question currently being asked. */
            clear_question();
            Term.putstr(QUESTION_COL, QUESTION_ROW, -1, ConsoleColor.Yellow, menu_data.hint);

            current_menu.cmd_keys = "?=*\x18";                   /* ?, =, *, <ctl-X> */

            while (next == birth_stage.BIRTH_RESET)
            {
                /* Display the menu, wait for a selection of some sort to be made. */
                ui_event cx = current_menu.select(ui_event_type.EVT_KBRD, false);

                /* As all the menus are displayed in "hierarchical" style, we allow
                 * use of "back" (left arrow key or equivalent) to step back in
                 * the proces as well as "escape". */
                if (cx.type == ui_event_type.EVT_ESCAPE)
                {
                    next = birth_stage.BIRTH_BACK;
                }
                else if (cx.type == ui_event_type.EVT_SELECT)
                {
                    if (current == birth_stage.BIRTH_ROLLER_CHOICE)
                    {
                        Game_Command.insert(Command_Code.FINALIZE_OPTIONS);

                        if (current_menu.cursor != 0)
                        {
                            /* Do a first roll of the stats */
                            Game_Command.insert(Command_Code.ROLL_STATS);
                            next = current + 2;
                        }
                        else
                        {
                            /*
                             * Make sure we've got a point-based char to play with.
                             * We call point_based_start here to make sure we get
                             * an update on the points totals before trying to
                             * display the screen.  The call to CMD_RESET_STATS
                             * forces a rebuying of the stats to give us up-to-date
                             * totals.  This is, it should go without saying, a hack.
                             */
                            point_based_start();
                            Game_Command.insert(Command_Code.RESET_STATS);
                            Game_Command.get_top().set_arg_choice(0, 1);
                            next = current + 1;
                        }
                    }
                    else
                    {
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        next = current + 1;
                    }
                }
                else if (cx.type == ui_event_type.EVT_KBRD)
                {
                    /* '*' chooses an option at random from those the game's provided. */
                    if (cx.key.code == (keycode_t)'*' && menu_data.allow_random)
                    {
                        current_menu.cursor = Random.randint0(current_menu.count);
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        current_menu.refresh(false);
                        next = current + 1;
                    }
                    else if (cx.key.code == (keycode_t)'=')
                    {
                        Do_Command.options_birth();
                        next = current;
                    }
                    else if (cx.key.code == (keycode_t)UIEvent.KTRL('X'))
                    {
                        Game_Command.insert(Command_Code.QUIT);
                        next = birth_stage.BIRTH_COMPLETE;
                    }
                    else if (cx.key.code == (keycode_t)'?')
                    {
                        Do_Command.help();
                    }
                }
            }

            return(next);
        }