Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public bool ChkMSForState(ref MapSquare map_square, MSFlag checked_state, MSFlagIndex checked_index)
        {
            if (map_square.MSStates[(int)checked_index] == checked_state)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public bool ChkMSForState(ref MapSquare map_square, MSFlag checked_state)
        {
            for (int i = 0; i < map_square.MSStates.Count(); i++)
            {
                if (map_square.MSStates[i] == checked_state)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        public bool ChkRectForAllFlagged(ref AreaMap new_map, ref Rectangle rect, MSFlag flag, MSFlagIndex flag_index)
        {
            int y_max = (rect.Y + rect.Height);     int x_max = (rect.X + rect.Width);

            for (int tile_y = rect.Y; tile_y < y_max; tile_y++)
            {
                for (int tile_x = rect.X; tile_x < x_max; tile_x++)
                {
                    if (new_map.OffMap(tile_x, tile_y))
                    {
                        return(false);
                    }

                    if (!ChkMSForState(ref new_map.MSGrid[tile_y][tile_x], flag, flag_index))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }