public void BuildFOV(TCODMap viewmap, int xpos, int ypos) { float Distance; Point currentLoc = new Point(0, 0); Point playerLoc = new Point(xpos, ypos); float intensity = 0.0f; viewmap.clear(false, false); for (int x = 0; x < 300; x++) { for (int y = 0; y < 200; y++) { viewmap.setProperties(x, y, this.Cells[x, y].Walkable, this.Cells[x, y].Walkable); } } viewmap.computeFov(xpos, ypos, 9, true, TCODFOVTypes.ShadowFov); for (int x = 0; x < 300; x++) { for (int y = 0; y < 200; y++) { if (this.Cells[x, y].Visible == Visiblity.Visible) { this.Cells[x, y].Visible = Visiblity.Previously; } if (viewmap.isInFov(x, y)) { this.Cells[x, y].Visible = Visiblity.Visible; } this.Cells[x, y].LightIntensity = 0.0f; } } for (int x = 0; x < 300; x++) { for (int y = 0; y < 200; y++) { if (this.Cells[x, y].Visible == Visiblity.Visible) { currentLoc.Set(x, y); Distance = (float)currentLoc.Dist(playerLoc); intensity = 0.5f - Distance / 12; if (intensity < 0.0f) { intensity = 0.0f; } this.Cells[x, y].LightIntensity = intensity; } if (this.Cells[x, y].Visible == Visiblity.Visible) { this.Cells[x, y].Visible = Visiblity.Previously; } if (viewmap.isInFov(x, y)) { this.Cells[x, y].Visible = Visiblity.Visible; } } } }
public LightSource() { position = new Point(0, 0); radius = 0; colour = new TCODColor(0, 0, 0); intensity = 0; lightMap = new TCODMap(300, 200); lightMap.clear(false, false); }
public LightSource(Point Position, int Radius, TCODColor Colour, float Intensity, Map mapData) { float Distance; Point currentLoc = new Point(0, 0); float workingIntensity = 0.0f; position = new Point(Position); radius = Radius; colour = new TCODColor(); colour = Colour; intensity = Intensity; int mapSize = 1 + (Radius * 2); lightMap = new TCODMap(300, 200); lightMap.clear(false, false); //for (int dx = Position.X - Radius; dx <= Position.X + Radius; dx++) for (int dx = 0; dx < 300; dx++) { //for (int dy = Position.Y - Radius; dy <= Position.Y + Radius; dy++) for (int dy = 0; dy < 200; dy++) { lightMap.setProperties(dx, dy, mapData.Cells[dx, dy].Walkable, mapData.Cells[dx, dy].Walkable); } } lightMap.computeFov(Position.X, Position.Y, Radius, true, TCODFOVTypes.ShadowFov); //for (int dx = Position.X - Radius; dx < Position.X + Radius; dx++) for (int dx = 0; dx < 300; dx++) { //for (int dy = Position.Y - Radius; dy <= Position.Y + Radius; dy++) for (int dy = 0; dy < 200; dy++) { if (lightMap.isInFov(dx, dy)) { currentLoc.Set(dx, dy); Distance = (float)currentLoc.Dist(Position); workingIntensity = Intensity - Distance / 12; if (workingIntensity < 0.0f) { workingIntensity = 0.0f; } mapData.Cells[dx, dy].AmbientLight = workingIntensity; mapData.Cells[dx, dy].AmbientLightColour = TCODColor.Interpolate(TCODColor.black, Colour, workingIntensity); } } } }
public void Clear(bool isTransparent = false, bool isWalkable = false) { TCODMap.clear(isTransparent, isWalkable); }