static public void DelRevealer(FOWAbstractRevealer rev) { if (rev != null) { lock (mRemoved) mRemoved.Add(rev); } }
static public void AddRevealer(FOWAbstractRevealer rev) { if (rev != null) { lock (mAdded) mAdded.Add(rev); } }
void PaintCircle(FOWAbstractRevealer r) { // Position relative to the fog of war Vector3 pos = (r.worldPos - basePoint) * worldToTex; float radius = r.radius * worldToTex; // Coordinates we'll be dealing with int xmin = Mathf.RoundToInt(pos.x - radius); int ymin = Mathf.RoundToInt(pos.z - radius); int xmax = Mathf.RoundToInt(pos.x + radius); int ymax = Mathf.RoundToInt(pos.z + radius); int cx = Mathf.RoundToInt(pos.x); int cy = Mathf.RoundToInt(pos.z); cx = Mathf.Clamp(cx, 0, textureSize - 1); cy = Mathf.Clamp(cy, 0, textureSize - 1); int radiusSqr = Mathf.RoundToInt(radius * radius); if (ymin < 0) { ymin = 0; } if (xmin < 0) { xmin = 0; } if (xmax > textureSize - 1) { xmax = textureSize - 1; } if (ymax > textureSize - 1) { ymax = textureSize - 1; } for (int y = ymin; y <= ymax; y++) { int yw = y * textureSize; for (int x = xmin; x <= xmax; ++x) { int xd = x - cx; int yd = y - cy; int dist = xd * xd + yd * yd; // Reveal this pixel if (dist <= radiusSqr) { mBuffer1[x + yw].r = 255; } } } }
private void PaintCircle(FOWAbstractRevealer r) { PaintCircle(r.worldPos, r.radius); }