Esempio n. 1
0
        // checks immediate adjacent mapSquares (NESW or All, depending on itr passed) for a MSFlag,
        // if the number of flagged MS is >= max_states, returns true, otherwise false
        public bool ChkAdjacentForMState(ref AreaMap map, ref Point sqr, MSFlag state, MSFlagIndex state_index, int dir_itr, int max_states)
        {
            int   states_found = 0;
            Point ms_chk, dir_offset;

            dir_offset = ms_chk = Point.Zero;

            for (int dir = 0; dir < Globals.NumDirects; dir += dir_itr)
            {
                ms_chk     = sqr;
                dir_offset = Globals.Directions[dir];

                ms_chk = Globals.AddPoints(ref ms_chk, ref dir_offset);

                if (OffMap(ms_chk.X, ms_chk.Y))
                {
                    continue;
                }
                else if (map.ChkMSForState(ref map.MSGrid[ms_chk.Y][ms_chk.X], state, state_index))
                {
                    states_found++;
                }
            }

            if (states_found >= max_states)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns true if the given map location exists and is not
        /// blocked by a barrier
        /// </summary>
        /// <param name="column">column position(x)</param>
        /// <param name="row">row position(y)</param>
        static private bool IsOpen(ref AreaMap search_map, int column, int row)
        {
            if (!search_map.OffMap(column, row))
            {
                if (column == goal.X)
                {
                    if (row == goal.Y)
                    {
                        return(true);
                    }
                }

                if (search_map.ChkMSForState(ref search_map.MSGrid[row][column], MSFlag.BL, MSFlagIndex.BL_ST))
                {
                    return(true);
                }

                if (ignoreHallWalls)
                {
                    if (search_map.MSGrid[row][column].RoomID == -1)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        public bool ChkLinearPathForFlagged(ref AreaMap new_map, ref Point path_start, Point path_end,
                                            Directions direction, MSFlag flag, MSFlagIndex f_index, ref Point destination)
        {
            Point next = path_start;
            Point step = Point.Zero;

            step.X = Globals.Directions[(int)direction].X; step.Y = Globals.Directions[(int)direction].Y; // <----

            while (next != path_end)
            {
                next = Globals.AddPoints(ref next, ref step);

                if (new_map.OffMap((int)next.X, (int)next.Y))
                {
                    return(false);
                }
                else if (next == destination)
                {
                    return(true);
                }
                else if (!new_map.ChkMSForState(ref new_map.MSGrid[(int)next.Y][(int)next.X], flag, f_index))
                {
                    return(false);
                }
            }
            return(true);
        }