// Devuelve un booleano si la el sector tiene un jugador; public bool IsDangerZone(SectorControl sector) { if (sector.playersDetected.Count > 0) { return(true); } else { return(false); } }
private void AddOrRefreshChunk(Vector2Ushort chunkStartPosition) { var sectorPosition = this.CalculateSectorPosition(chunkStartPosition); if (!this.canvasMapSectorControls.TryGetValue(sectorPosition, out var sector)) { var sectorCanvas = new Canvas(); //var sectorVisualSize = SectorSize * WorldChunkMapTextureSize; //sectorCanvas.Width = sectorVisualSize; //sectorCanvas.Height = sectorVisualSize; var sectorVisualPosition = this.WorldToCanvasPosition(sectorPosition.ToVector2D()); Canvas.SetLeft(sectorCanvas, sectorVisualPosition.X); Canvas.SetTop(sectorCanvas, sectorVisualPosition.Y); sector = new SectorControl(sectorCanvas, sectorPosition); this.canvasMapChildren.Add(sectorCanvas); this.canvasMapSectorControls.Add(sectorPosition, sector); } var checksum = WorldService.GetWorldChunkChecksum(chunkStartPosition); if (sector.TryGetTileRectangle(chunkStartPosition, out var tileRectangle)) { // already added - need to refresh the texture Load(tileRectangle, chunkStartPosition, checksum, this.cancellationToken); return; } // need to create a new rectangle and add it to Canvas // to fix NoesisGUI rendering issue (1 px holes between rectangles) const double squareSize = WorldChunkMapTextureSize + 1; tileRectangle = new Rectangle { Width = squareSize, Height = squareSize, }; //RenderOptions.SetBitmapScalingMode(tileRectangle, BitmapScalingMode.NearestNeighbor); var chunkCanvasPosition = this.WorldToCanvasPosition(chunkStartPosition.ToVector2D()) - this.WorldToCanvasPosition(sectorPosition.ToVector2D()); Canvas.SetLeft(tileRectangle, chunkCanvasPosition.X); Canvas.SetTop(tileRectangle, chunkCanvasPosition.Y - squareSize); sector.AddTileRectangle(chunkStartPosition, tileRectangle); Load(tileRectangle, chunkStartPosition, checksum, this.cancellationToken); }