protected void ApagarSector(int fila, int columna, ISector[,] matrizLugar, int caudalAgua) { double porcentajeIncendio = matrizLugar[fila, columna].getPorcentajeIncendio(); ISector sectorProblematico = matrizLugar[fila, columna]; StringBuilder estado_Incendio = new StringBuilder(); if (porcentajeIncendio > caudalAgua) { sectorProblematico.mojar(caudalAgua); estado_Incendio.Append(" -> "); estado_Incendio.Append(sectorProblematico.getPorcentajeIncendio()); while (!sectorProblematico.estaApagado()) { sectorProblematico.mojar(caudalAgua); estado_Incendio.Append(" -> "); estado_Incendio.Append(sectorProblematico.getPorcentajeIncendio()); } } else { sectorProblematico.mojar(caudalAgua); estado_Incendio.Append(" -> 0"); } Console.WriteLine(" ({0},{1}) -> {2}{3}", fila, columna, porcentajeIncendio, estado_Incendio); }
private void CreateMonstersForRegion(ISector sector, IBotPlayer monsterPlayer, ISectorSubScheme sectorScheme, List <IActor> resultMonsterActors, MapRegion region, int[] rarityCounter) { var regionNodes = region.Nodes.OfType <HexNode>(); var staticObjectsNodes = sector.StaticObjectManager.Items.Select(x => x.Node); var availableMonsterNodes = regionNodes.Except(staticObjectsNodes); var freeNodes = new List <IGraphNode>(availableMonsterNodes); var monsterCount = _generatorRandomSource.RollRegionCount( sectorScheme.MinRegionMonsterCount, sectorScheme.RegionMonsterCount); for (var i = 0; i < monsterCount; i++) { // если в комнате все места заняты if (!freeNodes.Any()) { break; } var rollIndex = _generatorRandomSource.RollNodeIndex(freeNodes.Count); var monsterNode = freeNodes[rollIndex]; var monster = RollRarityAndCreateMonster(sector, monsterPlayer, sectorScheme, monsterNode, rarityCounter); freeNodes.Remove(monster.Node); resultMonsterActors.Add(monster); } }
public ImageTileBuffer(GraphicsDevice graphicsDevice, Texture2D rendered, ISector sector) { buffer = new VertexIndiceBuffer(); List <VertexPositionNormalTexture> vertices = new List <VertexPositionNormalTexture>(); // TODO: are all of these names wrong everywhere? the topleft etc? Vector2d topLeft = new Vector2d(0, 0); Vector2d topRight = new Vector2d(1, 0); Vector2d bottomLeft = new Vector2d(0, 1); Vector2d bottomRight = new Vector2d(1, 1); vertices.Add(new VertexPositionNormalTexture(new Vector3((float)topLeft.X, (float)topLeft.Y, 0), new Vector3(0, 0, 1), new Vector2(0, 0))); vertices.Add(new VertexPositionNormalTexture(new Vector3((float)topRight.X, (float)topRight.Y, 0), new Vector3(0, 0, 1), new Vector2(1, 0))); vertices.Add(new VertexPositionNormalTexture(new Vector3((float)bottomLeft.X, (float)bottomLeft.Y, 0), new Vector3(0, 0, 1), new Vector2(0, 1))); vertices.Add(new VertexPositionNormalTexture(new Vector3((float)bottomRight.X, (float)bottomRight.Y, 0), new Vector3(0, 0, 1), new Vector2(1, 1))); List <int> indices = new List <int>() { 0, 1, 3, 0, 3, 2 }; buffer.vertices = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly); buffer.vertices.SetData(vertices.ToArray()); buffer.indices = new IndexBuffer(graphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Count, BufferUsage.WriteOnly); buffer.indices.SetData(indices.ToArray()); buffer.texture = rendered; }
public ProceduralTileBuffer(ISector sector) { this.sector = sector; var landSource = new SubtractionPolygonSource(new RawPolygonSource("natural", "coastline", true), new RawPolygonSource("natural", "water", false)); var coastSource = new EdgeLineSource(landSource, true); var roadSource = new RawLineSource("highway", null); var buildingSource = new RawPolygonSource("building", "yes", false); descriptors.Add(new DepthClearDescriptor()); descriptors.Add(new PolygonRenderDescriptor(landSource, Pallete.GRASS_GREEN)); descriptors.Add(new LineRenderDescriptor(coastSource, 10.7 * 25 * 256, GlobalContent.Beach, true)); descriptors.Add(new DepthClearDescriptor()); descriptors.Add(new LineRenderDescriptor(roadSource, 10.7 * 2 * 256, GlobalContent.Road)); descriptors.Add(new DepthClearDescriptor()); descriptors.Add(new BuildingRenderDescriptor(buildingSource, 10.7 * 10, Color.LightGray, GlobalContent.BuildingWall)); treeDescriptors.Add(new DepthClearDescriptor()); treeDescriptors.Add(new PolygonRenderDescriptor(landSource, Color.White)); treeDescriptors.Add(new LineRenderDescriptor(coastSource, 10.7 * 25 * 256, GlobalContent.BeachTreeDensity, true)); treeDescriptors.Add(new DepthClearDescriptor()); treeDescriptors.Add(new LineRenderDescriptor(roadSource, 10.7 * 12 * 256, GlobalContent.RoadTreeDensity)); treeDescriptors.Add(new DepthClearDescriptor()); treeDescriptors.Add(new LineRenderDescriptor(roadSource, 10.7 * 2 * 256, Color.Black)); grassDescriptors.Add(new DepthClearDescriptor()); grassDescriptors.Add(new PolygonRenderDescriptor(landSource, Color.White)); grassDescriptors.Add(new LineRenderDescriptor(coastSource, 10.7 * 25 * 256, GlobalContent.BeachGrassDensity, true)); grassDescriptors.Add(new DepthClearDescriptor()); grassDescriptors.Add(new LineRenderDescriptor(roadSource, 10.7 * 2 * 256, Color.Black)); }
public StaticObjectGenerationContext(ISector sector, ISectorSubScheme scheme, IResourceDepositData resourceDepositData) { Sector = sector ?? throw new ArgumentNullException(nameof(sector)); Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); ResourceDepositData = resourceDepositData ?? throw new ArgumentNullException(nameof(resourceDepositData)); }
private static IEnumerable <IGraphNode> WriteObservedNodesOrGetFromFow(IActor actor, ILogicStrategyData strategyData, ISector sector) { IEnumerable <IGraphNode> frontNodes; var fowModule = actor.Person.GetModuleSafe <IFowData>(); if (fowModule is null) { frontNodes = GetNodesUsingStrategyData(actor, strategyData, sector); } else { frontNodes = GetNodesUsingFowModule(strategyData, sector, fowModule); } if (!frontNodes.Any()) { var closestNode = sector.Map.GetNext(actor.Node).FirstOrDefault(); if (closestNode != null) { frontNodes = new[] { closestNode }; } } return(frontNodes); }
internal static void ConvertHGTZIPsToHGTZIP(ISector sector, string rootFolder, bool overwrite) { string outputPath = Path.Combine(rootFolder, sector.GetAllParents().Where(x => x.Zoom == 4).Single().ToString(), sector.ToString() + ".HGT.ZIP"); if (!overwrite && File.Exists(outputPath)) { return; } int[,] shorts = ConvertHGTZIPsToShorts(sector); byte[] outputBytes = new byte[REZ * REZ * 2]; for (int x = 0; x < REZ; x++) { for (int y = 0; y < REZ; y++) { outputBytes[(REZ * y + x) * 2] = (byte)(shorts[x, y] / 256); outputBytes[(REZ * y + x) * 2 + 1] = (byte)(shorts[x, y] % 256); } } string directoryName = Path.GetDirectoryName(outputPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } Compression.ZipToFile(outputPath, outputBytes); }
// move some of our files to the Android assets folder private static void HelpZenithAndroid() { LongLat longLat = new LongLat(-87.3294527 * Math.PI / 180, 30.4668536 * Math.PI / 180); // Pensacola CubeSector ourRoot = new CubeSector(CubeSector.CubeSectorFace.LEFT, 0, 0, 0); Vector2d relativeCoord = ourRoot.ProjectToLocalCoordinates(longLat.ToSphereVector()); HashSet <ISector> sectorsToLoad = new HashSet <ISector>(); foreach (var r in ZCoords.GetSectorManager().GetTopmostOSMSectors()) { sectorsToLoad.Add(r); for (int z = 1; z <= 3; z++) { foreach (var child in r.GetChildrenAtLevel(z)) { sectorsToLoad.Add(child); } } } for (int z = 4; z <= 8; z++) { ISector sector = ourRoot.GetSectorAt(relativeCoord.X, relativeCoord.Y, z); for (int i = 0; i < 25; i++) { sectorsToLoad.Add(new CubeSector(((CubeSector)sector).sectorFace, sector.X + i / 5 - 2, sector.Y + i % 5 - 2, sector.Zoom)); } } foreach (var sector in sectorsToLoad) { MoveSectorImage(sector); MoveSectorOSM(sector); } }
/// <summary>Создаёт монстров в секторе по указанной схеме.</summary> /// <param name="sector">Целевой сектор.</param> /// <param name="monsterRegions">Регионы сектора, где могут быть монстры.</param> /// <param name="sectorScheme">Схема сектора. Отсюда берутся параметры генерации монстров.</param> public void CreateMonsters(ISector sector, IEnumerable <MapRegion> monsterRegions, ISectorSubScheme sectorScheme) { if (sector is null) { throw new ArgumentNullException(nameof(sector)); } if (monsterRegions is null) { throw new ArgumentNullException(nameof(monsterRegions)); } if (sectorScheme is null) { throw new ArgumentNullException(nameof(sectorScheme)); } var resultMonsterActors = new List <IActor>(); var rarityCounter = new int[3]; foreach (var region in monsterRegions) { CreateMonstersForRegion(sector, sectorScheme, resultMonsterActors, region, rarityCounter); } // Инфицируем монстров, если в секторе есть болезни. RollInfections(sector, resultMonsterActors); }
public SectorEntry(ISector sec) { Sector = sec; }
public void AssignSector(SectorRange range, ISector sector) { DeleteRange(range); sectors.Add(range, sector); }
/// <summary> /// Initializes a new instance of the <see cref="SectorData" /> class. /// </summary> /// <param name="sector">The sector.</param> /// <param name="sectorID">The sectorID.</param> /// <param name="owner">The owner.</param> public SectorData(ISector sector, IntVector3 sectorID, Player owner) : base(sector, owner) { SectorID = sectorID; Topography = Topography.OpenSpace; }
/// <summary> /// Initializes a new instance of the <see cref="SectorData" /> class /// with the owner initialized to NoPlayer. /// </summary> /// <param name="sector">The sector.</param> /// <param name="sectorID">The sectorID.</param> public SectorData(ISector sector, IntVector3 sectorID) : this(sector, sectorID, TempGameValues.NoPlayer) { }