public void ShadowOnPos(int x, int posY) { LevelTile_Dig tile = GetTile <LevelTile_Dig>(x, posY); var pos = Vector3Int.zero; var data = tile.data as LevelTileData_Dig; //if (data != null) // return; bool lastHit = false; float value = 1; if (tile.IsEmpty()) { value = 0; } int penetration = 5; for (int y = posY; y > 0; y--) { if (penetration <= 0) { break; } tile = GetTile <LevelTile_Dig>(x, posY); if (tile == null) { break; } value -= GetAbsorption(tile); tile.inSunLight = false; SetLight(tile, value); if (tile.IsEmpty() == false) { penetration--; lastHit = true; } } }
float GetAbsorption(LevelTile_Dig tile) { if (tile.IsEmpty()) { return(0); } var data = tile.data as LevelTileData_Dig; if (data != null) { return(data.isTranslucent? 0 : 1); } else { return(1); } }
public void LightOnPos(int x, int posY, bool sunLight = false) { LevelTile_Dig tile = GetTile <LevelTile_Dig>(x, posY + 1); if (sunLight == true && tile.inSunLight == false) { return; } var pos = Vector3Int.zero; bool lastHit = false; float value = 1; int penetration = 5; for (int y = posY; y > 0; y--) { if (penetration <= 0) { break; } tile = GetTile <LevelTile_Dig>(x, y); if (tile == null) { break; } value -= GetAbsorption(tile); if (value == 1) { tile.inSunLight = true; } SetLight(tile, value); if (tile.IsEmpty() == false) { penetration--; lastHit = true; } } }