/// <summary> /// Checks if there is some point of the rectange with visiblity = vis /// (Might be a little wonky if the quality is too low) /// </summary> /// <param name="rect">Rectange in world coords to check</param> /// <param name="vis">visible.unexplored: means that a point has been never revealed /// visible.explored: means that a point has been explored OR is being explored /// visible.visible: means that a point is currently being revealed </param> /// <param name="checkForPlayer">Defaults to true. if true we will check the player visibility map /// if false we will check the AI visibility map.</param> /// <returns>true if atleast a pixel of the rectangle is in vis state, false otherwise</returns> public bool isThereinRect(Rect rect, visible vis, bool askForPlayer = true) { int xMin, xMax, yMin, yMax; getBounds(rect, 0, out xMin, out xMax, out yMin, out yMax); for (int x = xMin; x <= xMax; x++) { for (int y = yMin; y <= yMax; ++y) { int p = x + y * fowTex.width; if (p <= pixels.Length) { if (askForPlayer) { if ((vis == visible.explored && pixels[p].g > 0) || (vis == visible.visible && pixels[p].b > 200) || (vis == visible.unexplored && pixels[p].g == 0)) { return(true); } } else if ((vis & aiVision[p]) == vis) { return(true); } } } } return(false); }
/// <summary> /// Checks if there is some point of the rectange with visiblity = vis /// (Might be a little wonky if the quality is too low) /// </summary> /// <param name="rect">Rectange in world coords to check</param> /// <param name="vis">visible.unexplored: means that a point has been never revealed /// visible.explored: means that a point has been explored OR is being explored /// visible.visible: means that a point is currently being revealed </param> /// <param name="checkForPlayer">Defaults to true. if true we will check the player visibility map /// if false we will check the AI visibility map.</param> /// <returns>true if atleast a pixel of the rectangle is in vis state, false otherwise</returns> public bool isThereinRect(Rect rect,visible vis, bool askForPlayer=true) { int xMin, xMax, yMin, yMax; getBounds(rect, 0, out xMin, out xMax, out yMin, out yMax); for (int x = xMin; x <= xMax; x++) for (int y = yMin; y <= yMax; ++y) { int p = x + y * fowTex.width; if (p <= pixels.Length) if (askForPlayer) { if ((vis == visible.explored && pixels[p].g > 0) || (vis == visible.visible && pixels[p].b > 200) || (vis == visible.unexplored && pixels[p].g == 0)) return true; }else if ((vis & aiVision[p]) == vis) return true; } return false; }