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); }
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); }
public MSFlag ChkMSState(MapSquare map_square, MSFlagIndex checked_index) { if ((int)checked_index >= map_square.MSStates.Count()) { return(MSFlag.NULL); } else { return(map_square.MSStates[(int)checked_index]); } }
// 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); }
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); }