// Interfaces to manipulate server's map. public void SetBlock(int x, int y, int z, int blocktype) { if (MapUtil.IsValidPos(d_Map, x, y, z)) { SetBlockAndNotify(x, y, z, blocktype); } }
public static Vector3[] GenerateTilesOfShape(MapShape shape, int size, float radius) { switch (shape) { case MapShape.HexagonalLattice: { return(MapUtil.HexagonalLattice(Vector3.zero, size, radius, 0f)); } case MapShape.Doughnut: { Vector3[] tiles = MapUtil.HexagonalLattice(Vector3.zero, size, radius, 0f); Vector3 pos = Vector3.zero; foreach (Vector3 t in tiles) { pos += t; } pos /= tiles.Length; return(tiles .Where(t => Vector3.Distance(t, pos) > 10f) .ToArray()); } default: { return(null); } } }
void ColorDownhill(Loc l) { GameObject go = Tiles[l]; ResetTile(go); Color cb = Color.black; Color ct = Color.white; if (mapGen.Elevation[l.x, l.y] > mapGen.seaLevel) { cb = Color.white; ct = Color.black; } go.GetComponent <Renderer>().material.SetColor("_Color", cb); TextMesh tm = go.GetComponentInChildren <TextMesh>(); tm.text = '\u2192'.ToString(); tm.color = ct; Vec v = mapGen.Downhill[l.x, l.y]; float z = 0f; float z2 = 90f; float d = 0f; if (!v.Equals(null)) { d = MapUtil.VectorToRadians(v.x, v.y); d = MapUtil.RadiansToDegrees(d); z = 90f; z2 = 0f; } Debug.Log("[" + l.x + "," + l.y + "] is " + z + "," + d); tm.GetComponentInParent <Transform>().eulerAngles = new Vector3(z, d, z2); }
public void SetNodeList(float[,] _elevation, float _seaLevel, delCost fCost, float _seaTravelCost = 0f) { int xDim = _elevation.GetLength(0); int yDim = _elevation.GetLength(1); Node[,] nodes = new Node[xDim, yDim]; for (int x = 0; x < xDim; x++) { for (int y = 0; y < yDim; y++) { nodes[x, y] = new Node(x, y); nodeDict[new Loc(x, y)] = nodes[x, y]; } } for (int x = 0; x < xDim; x++) { for (int y = 0; y < yDim; y++) { Node n = nodes[x, y]; n.Visited = false; Loc l = new Loc(x, y); Dictionary <Loc, float> d = MapUtil.GetValidNeighbors(_elevation, l); foreach (KeyValuePair <Loc, float> kvp in d) { n.neighborWeights[nodes[kvp.Key.x, kvp.Key.y]] = fCost(l, kvp.Key, _elevation, _seaLevel, _seaTravelCost); n.neighbors.Add(nodes[kvp.Key.x, kvp.Key.y]); } nodelist.Add(n); } } }
private IdTypeConfigurationProvider CreateIdTypeProvider() { IDictionary <string, string> @params = MapUtil.stringMap(EnterpriseEditionSettings.idTypesToReuse.name(), IdType.NODE + "," + IdType.RELATIONSHIP); Config config = Config.defaults(@params); return(new EnterpriseIdTypeConfigurationProvider(config)); }
public ushort[] GetChunkFromDatabase(int x, int y, int z, string filename) { if (MapUtil.IsValidPos(d_Map, x, y, z)) { if (!GameStorePath.IsValidName(filename)) { Console.WriteLine("Invalid backup filename: " + filename); return(null); } if (!Directory.Exists(GameStorePath.gamepathbackup)) { Directory.CreateDirectory(GameStorePath.gamepathbackup); } string finalFilename = Path.Combine(GameStorePath.gamepathbackup, filename + MapManipulator.BinSaveExtension); x = x / chunksize; y = y / chunksize; z = z / chunksize; byte[] serializedChunk = ChunkDb.GetChunkFromFile(d_ChunkDb, x, y, z, finalFilename); if (serializedChunk != null) { ServerChunk c = DeserializeChunk(serializedChunk); return(c.data); } } return(null); }
// generates a new spawn near initial spawn if initial spawn is in water public Vector3i DontSpawnPlayerInWater(Vector3i initialSpawn) { if (IsPlayerPositionDry(initialSpawn.x, initialSpawn.y, initialSpawn.z)) { return(initialSpawn); } //find shore //bonus +10 because player shouldn't be spawned too close to shore. bool bonusset = false; int bonus = -1; Vector3i pos = initialSpawn; for (int i = 0; i < playerareasize / 4 - 5; i++) { if (IsPlayerPositionDry(pos.x, pos.y, pos.z)) { if (!bonusset) { bonus = 10; bonusset = true; } } if (bonusset && bonus-- < 0) { break; } pos.x++; int newblockheight = MapUtil.blockheight(d_Map, 0, pos.x, pos.y); pos.z = newblockheight + 1; } return(pos); }
public void DeleteChunks(List <Vector3i> chunkPositions) { List <Xyz> chunks = new List <Xyz>(); foreach (Vector3i pos in chunkPositions) { if (MapUtil.IsValidPos(d_Map, pos.x, pos.y, pos.z)) { int x = pos.x / chunksize; int y = pos.y / chunksize; int z = pos.z / chunksize; d_Map.SetChunkValid(x, y, z, null); chunks.Add(new Xyz() { X = x, Y = y, Z = z }); } } if (chunks.Count != 0) { ChunkDb.DeleteChunks(d_ChunkDb, chunks); // force to update chunks at clients foreach (var k in clients) { //TODO: wrong? //k.Value.chunksseen.Clear(); Array.Clear(k.Value.chunksseen, 0, k.Value.chunksseen.Length); } } }
public void UpdateFeatureInfos(MapUtil.FeatureInformations featureInfos,Point mousePosition) { this.lsvFeatureProperties.Items.Clear(); if (featureInfos == null) { this.Hide(); } else { this.lsvFeatureProperties.Items.Clear(); Dictionary<string,string>.KeyCollection oFieldsCollection = featureInfos.FieldsAndValuesCollection.Keys; string sValue; foreach (string sFieldName in oFieldsCollection) { this.lsvFeatureProperties.Items.Add(sFieldName); featureInfos.FieldsAndValuesCollection.TryGetValue(sFieldName, out sValue); this.lsvFeatureProperties.Items[this.lsvFeatureProperties.Items.Count - 1].SubItems.Add(sValue); } this.labLayerInfos.Text = string.Format("ͼ�� : {0}", featureInfos.CurrentLayerInfos.AliasName); if (!this.Visible) this.Show(); this.Location = mousePosition; this.Activate(); } }
private void btnPan_Click(object sender, EventArgs e) { // Grab the MapPrinterLayer and adjust the extent PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"]; MapPrinterLayer mapPrinterLayer = ((MapPrinterLayer)(printerOverlay.PrinterLayers["MapLayer"])); if (sender == btnPanNorth) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Up, 30); } else if (sender == btnPanSouth) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Down, 30); } else if (sender == btnPanWest) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Left, 30); } else if (sender == btnPanEast) { mapPrinterLayer.MapExtent = MapUtil.Pan(mapPrinterLayer.MapExtent, PanDirection.Right, 30); } Map1.Refresh(); }
// TODO: Reimplement #region Unused assets code // public async Task<GetAssetDigestResponse> GetAssetsAsync() // { // // check if template cache has been set // // // Get DownloadRemoteConfig // var remoteConfigResponse = await SendRemoteProcedureCallAsync(new Request // { // RequestType = RequestType.DownloadRemoteConfigVersion, // RequestMessage = new DownloadRemoteConfigVersionMessage // { // Platform = Platform.Android, // AppVersion = 2903 // }.ToByteString() // }); // // var remoteConfigParsed = DownloadRemoteConfigVersionResponse.Parser.ParseFrom(remoteConfigResponse); // var timestamp = (ulong) TimeUtil.GetCurrentTimestampInMilliseconds(); // // // TODO: the timestamp comparisons seem to be used for determining if the stored data is invalid and needs refreshed, // // however, looking at this code I'm not sure it's implemented correctly - or if these refactors still match the behavior of // // the previous code... same concern with the next method GetItemTemplates().. // // var cachedMsg = _session.DataCache.GetCachedAssetDigest(); // if (cachedMsg != null && remoteConfigParsed.AssetDigestTimestampMs <= timestamp) // { // return cachedMsg; // } // else // { // // GetAssetDigest // var assetDigestResponse = await SendRemoteProcedureCallAsync(new Request // { // RequestType = RequestType.GetAssetDigest, // RequestMessage = new GetAssetDigestMessage // { // Platform = Platform.Android, // AppVersion = 2903 // }.ToByteString() // }); // var msg = GetAssetDigestResponse.Parser.ParseFrom(assetDigestResponse); // _session.DataCache.SaveData(DataCacheExtensions.AssetDigestFile, msg); // return msg; // } // } // // public async Task<DownloadItemTemplatesResponse> GetItemTemplatesAsync() // { // // Get DownloadRemoteConfig // var remoteConfigResponse = await SendRemoteProcedureCallAsync(new Request // { // RequestType = RequestType.DownloadRemoteConfigVersion, // RequestMessage = new DownloadRemoteConfigVersionMessage // { // Platform = Platform.Android, // AppVersion = 2903 // }.ToByteString() // }); // // var remoteConfigParsed = DownloadRemoteConfigVersionResponse.Parser.ParseFrom(remoteConfigResponse); // var timestamp = (ulong) TimeUtil.GetCurrentTimestampInMilliseconds(); // // var cachedMsg = _session.DataCache.GetCachedItemTemplates(); // if (cachedMsg != null && remoteConfigParsed.AssetDigestTimestampMs <= timestamp) // { // return cachedMsg; // } // else // { // // GetAssetDigest // var itemTemplateResponse = await SendRemoteProcedureCallAsync(new Request // { // RequestType = RequestType.DownloadItemTemplates // }); // var msg = DownloadItemTemplatesResponse.Parser.ParseFrom(itemTemplateResponse); // _session.DataCache.SaveData(DataCacheExtensions.ItemTemplatesFile, msg); // return msg; // } // } #endregion /// <summary> /// It is not recommended to call this. Map objects will update automatically and fire the map update event. /// </summary> public async Task RefreshMapObjectsAsync() { var cellIds = MapUtil.GetCellIdsForLatLong(_session.Player.Coordinate.Latitude, _session.Player.Coordinate.Longitude); var sinceTimeMs = new List <long>(cellIds.Length); foreach (var cellId in cellIds) { var cell = _session.Map.Cells.FirstOrDefault(x => x.S2CellId == cellId); // TODO: Using the cells' currenttimestamp gives a delta, which is probably better, but we need to merge the result with the existing ones //sinceTimeMs.Add(cell?.CurrentTimestampMs ?? 0); sinceTimeMs.Add(0); } var response = await SendRemoteProcedureCallAsync(new Request { RequestType = RequestType.GetMapObjects, RequestMessage = new GetMapObjectsMessage { CellId = { cellIds }, SinceTimestampMs = { sinceTimeMs.ToArray() }, Latitude = _session.Player.Coordinate.Latitude, Longitude = _session.Player.Coordinate.Longitude }.ToByteString() }); var mapObjects = GetMapObjectsResponse.Parser.ParseFrom(response); if (mapObjects.Status == MapObjectsStatus.Success) { // TODO: Cleaner? var pokemonCatchable = mapObjects.MapCells.SelectMany(c => c.CatchablePokemons).Count(); var pokemonWild = mapObjects.MapCells.SelectMany(c => c.WildPokemons).Count(); var pokemonNearby = mapObjects.MapCells.SelectMany(c => c.NearbyPokemons).Count(); var pokemonCount = pokemonCatchable + pokemonWild + pokemonNearby; Logger.Debug($"Received '{mapObjects.MapCells.Count}' map cells."); Logger.Debug($"Received '{pokemonCount}' pokemons. Catchable({pokemonCatchable}) Wild({pokemonWild}) Nearby({pokemonNearby})"); Logger.Debug($"Received '{mapObjects.MapCells.SelectMany(c => c.Forts).Count()}' forts."); if (mapObjects.MapCells.Count == 0) { Logger.Error("We received 0 map cells, are your GPS coordinates correct?"); return; } _session.Map.Cells = mapObjects.MapCells; } else { Logger.Error($"GetMapObjects status is: '{mapObjects.Status}'."); } }
public void generateMountains() { //top x,bottom x //left y,right y int tx = wy / 2 + wy / 4 * (sy % sx) / sx; int bx = wy / 2 - wy / 4 * (sy % sx) / sy; int ly = wy / 2 + wy / 4 * (sy % sx) / sx; int ry = wy / 2 - wy / 4 * (sy % sx) / sy; int waveNumX = sx % 10 + 3; int waveNumY = sy % 10 + 3; int waveWidthX = wx / 32; Boolean[,] mountainMap = new Boolean[wx, wy]; int px = Math.Max(tx, bx); int px2 = Math.Min(tx, bx); int py = Math.Max(ly, ry); int py2 = Math.Max(ly, ry); if (sx % 2 == 0) { mountainMap = MapUtil.generateSineWave(mountainMap, new Point(0, px), new Point(wx, px2), waveNumX, waveWidthX, sx, wx); } else { mountainMap = MapUtil.generateSineWave(mountainMap, new Point(px, 0), new Point(px, wy), waveNumX, waveWidthX, sx, wx); } int waterDistance = 4; for (int i = waterDistance; i < mountainMap.GetLength(0) - waterDistance; i++) { for (int j = waterDistance; j < mountainMap.GetLength(0) - waterDistance; j++) { if (IslandMap.l[i, j] && mountainMap[i, j]) { Boolean hasWater = false; for (int countX = -waterDistance; countX < waterDistance; countX++) { for (int countY = -waterDistance; countY < waterDistance; countY++) { if (IslandMap.o[i + countX, j + countY] || IslandMap.lk[i + countX, j + countY]) { hasWater = true; goto completedSearch; } } } completedSearch: if (!hasWater) { IslandMap.m[i, j] = true; } } } } }
public void GetMiddleCoordinateEmptyTest() { var coordinates = new PointF[] {}; var middle = MapUtil.GetMiddleCoordinate(coordinates); Assert.AreEqual(PointF.Empty, middle); }
private void MainFrom_FormClosing(object sender, FormClosingEventArgs e) { this.axMapControl1.Map.ClearSelection(); routeUI.ClearRouteAnalyst(this.axMapControl1); // MapUtil.SaveMap(Common.MapPath, this.axMapControl1.Map); MapUtil.SaveMxd(this.axMapControl1); Application.Exit(); }
private ConfigFileBuilder(File directory) { this._directory = directory; //initialize config with defaults that doesn't pollute //workspace with generated data this._config = MapUtil.stringMap(GraphDatabaseSettings.data_directory.name(), directory.AbsolutePath + "/data", ServerSettings.ManagementApiPath.name(), "http://localhost:7474/db/manage/", ServerSettings.RestApiPath.name(), "http://localhost:7474/db/data/"); }
static public MapUtil GetInstance() { if (instance == null) { instance = new MapUtil(); } return(instance); }
public virtual void ShouldReturn204WhenPropertiesAreUpdated() { Node jim = Data.get()["jim"]; assertThat(jim, inTx(Graphdb(), not(hasProperty("age")))); GenConflict.get().payload(JsonHelper.createJsonFrom(MapUtil.map("age", "18"))).expectedStatus(204).put(GetPropertiesUri(jim)); assertThat(jim, inTx(Graphdb(), hasProperty("age").withValue("18"))); }
private static PointF CalcCenter(IEnumerable <AddressVm> addresses) { var points = addresses .Select(address => new PointF((float)address.Latitude, (float)address.Longitude)) .ToArray(); return(MapUtil.GetMiddleCoordinate(points)); }
public void SetBlock(int x, int y, int z, int tileType) { byte[] chunk = GetChunk(x, y, z); chunk[MapUtil.Index3d(x % chunksize, y % chunksize, z % chunksize, chunksize, chunksize)] = (byte)tileType; chunks[x / chunksize, y / chunksize, z / chunksize].LastChange = d_CurrentTime.SimulationCurrentFrame; chunks[x / chunksize, y / chunksize, z / chunksize].DirtyForSaving = true; UpdateColumnHeight(x, y); }
private ExecutionPlanDescription GetMockDescription(string name) { ExecutionPlanDescription plan = mock(typeof(ExecutionPlanDescription)); when(plan.Name).thenReturn(name); when(plan.Arguments).thenReturn(MapUtil.map("argumentKey", "argumentValue")); return(plan); }
public void UpdateProduct(ProductDto productDto) { ProductContext.Execute(db => { db.Updateable <Product>(MapUtil.Map <Product>(productDto)) .ExecuteCommand(); }); }
//判断一个点是否为障碍物 private bool IsBar(Point p) { if (pointDic[MapUtil.GetInstance().GetIndex(p.y, p.x)].isActive) { return(true); } return(false); }
public int GetBlock(int x, int y, int z) { if (MapUtil.IsValidPos(d_Map, x, y, z)) { return(d_Map.GetBlock(x, y, z)); } return(0); }
private void btnDistance_Click(object sender, EventArgs e) { // Winner is MapUtil.GetDistance for pole to pole listBox1.Items.Add(""); var bb = new LLBoundingBox(0, 0, 0, 0, false); bb.West = -180.0; bb.East = -179.0; bb.South = 0.0; bb.North = 0.0; var d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{d1}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); Char myChar = 'K'; var d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{d2}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); var d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{d3}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); bb.West = -180.0; bb.East = -179.0; bb.South = -45.0; bb.North = -45.0; d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{Math.Round(d1,6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{Math.Round(d2,6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{Math.Round(d3,6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); bb.West = 0.0; bb.East = 1.0; bb.South = 0.0; bb.North = 0.0; d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{Math.Round(d1, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{Math.Round(d2, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{Math.Round(d3, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); bb.West = -179.0; bb.East = 170.0; bb.South = 0.0; bb.North = 0.0; d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{Math.Round(d1, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{Math.Round(d2, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{Math.Round(d3, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); bb.West = -90.0; bb.East = 90.0; bb.South = 0.0; bb.North = 0.0; d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{Math.Round(d1, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{Math.Round(d2, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{Math.Round(d3, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); bb.West = 1.0; bb.East = 1.1; bb.South = 0.0; bb.North = 1.0; d1 = MapUtil.GetDistance(bb.West, bb.South, bb.East, bb.North); listBox1.Items.Add($"Distance1:{Math.Round(d1, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d2 = MapUtil.Distance3(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance2:{Math.Round(d2, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); d3 = MapUtil.DistanceTo(bb.West, bb.South, bb.East, bb.South, myChar); listBox1.Items.Add($"Distance3:{Math.Round(d3, 6)}, (W,S - E,N) ,({bb.West} , {bb.South}) - ({bb.East} , {bb.North})"); }
private void UpdateArrow(GameObject go, Vector3 delta, Vector3 currentPos) { if (!m_isExploxe) { return; //还未探索,不做操作 } m_totalDelta += delta; var pos = go.transform.position; var targetPos = pos + m_totalDelta; if (m_movingDrawArrow) { m_movingDrawArrow.SetSourcePos(pos); if (m_currentTargetStar != null)//如果缓存的目标星球不为空,则每帧检测有没有拖出范围,保证效果 { var starPos = m_currentTargetStar.UnitGO.transform.position; if (Vector3.Distance(targetPos, starPos) < m_currentTargetStar.BaseData.radius * 1.5) { return; } } if (Time.time - m_totleDeltaTime > 0.2f)//隔固定时间检测有没有箭头顶点有没有在可达星球范围内 { m_totleDeltaTime = Time.time; for (int i = 0; i < MogoWorld.m_dataMapManager.ReachStarList.Count; i++) { var star = MogoWorld.m_dataMapManager.ReachStarList[i]; if (star == this) { continue; } var starPos = star.UnitGO.transform.position; //Debug.Log(Vector3.Distance(targetPos, starPos)); if (Vector3.Distance(targetPos, starPos) < star.BaseData.radius * 1.5) { m_currentPath = MapUtil.Plan(this, star).PassedStars; m_currentTargetStar = star; DrawAllPathLine(); return; } } } //都没有就跟着移动坐标画 m_movingDrawArrow.DrawArrowToTargetPoint(targetPos); m_currentTargetStar = null; HideOtherLines(); //var cam = UIManager.I.GetUILogic<MapUIMgr>().MyCameraController; ////cam.transform.localPosition -= delta; //TweenPosition.Begin(cam.gameObject, 0.2f, new Vector3(-targetPos.x, -targetPos.y, 0)); m_starInfoUIMgr.ShowOwnerRangle(true, true); } }
public PropertyQueryForm(string selectLayerName, AxMapControl mapControl) { InitializeComponent(); EventDeal(); this.mapControl = mapControl; layers = MapUtil.GetAllLayers(mapControl); this.selectLayerName = selectLayerName; // ListBox2ItemHandler = new EventHandler(listBoxControl2_SelectedIndexChanged); }
private void Event_ChunkDirty(Vec3i chunkCoord, IWorldChunk chunk, EnumChunkDirtyReason reason) { long index3d = MapUtil.Index3dL(chunkCoord.X, chunkCoord.Y, chunkCoord.Z, chunkMapSizeX, chunkMapSizeZ); lock (roomsByChunkIndexLock) { roomsByChunkIndex.Remove(index3d); } }
private void Set2SavePos() { Init2Wall(Enum_Wall.Wall, m_SaveData.saveWall); m_InitData.isSeted = true; this.transform.position = MapUtil.GetMap(m_InitData.m_CurWall).m_StartPos + m_SaveData.savePos.MulVal(GameApp.Inst.m_MapGridUnityLenHalf); MapUtil.GetMap(m_InitData.m_CurWall).SetOne(this.transform.position, m_Config.size); SetOutLineVisible(false); }
private void CalOffset() { Vector3 pos = MapUtil.GetMap(m_InitData.m_CurWall).Adjust2Wall(this.transform.position); //Debug.LogWarning("calOffset " + pos + " wall=" + m_InitData.m_CurWall + " " + MapUtil.Vector3String(this.transform.position)); m_Offset = JerryUtil.GetClickPos() - Camera.main.WorldToScreenPoint(pos); //第一步,先记录一下位置,不给走 m_LastDragingPos = JerryUtil.GetClickPos() - m_Offset; }
/// <summary> /// Todo: omg I can't wait for tuples - out parameters are bad. /// </summary> /// <param name="chunkIndex2d"></param> /// <param name="chunkMapSizeX"></param> /// <param name="chunkX"></param> /// <param name="chunkZ"></param> public static void ChunkPosFromChunkIndex2DL(long chunkIndex2d, int chunkMapSizeX, out int chunkX, out int chunkZ) { var retVec = new Vec2i(); MapUtil.PosInt2d(chunkIndex2d, chunkMapSizeX, retVec); chunkX = retVec.X; chunkZ = retVec.Y; }
private ImageSource GenerateMapImage() { Collection <Layer> layersToDraw = new Collection <Layer>(); // Create the background world maps using vector tiles stored locally in our MBTiles file and also set the styling though a json file ThinkGeoMBTilesLayer mbTilesLayer = new ThinkGeoMBTilesLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Mbtiles/Frisco.mbtiles"), new Uri(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Json/thinkgeo-world-streets-light.json"), UriKind.Relative)); mbTilesLayer.Open(); layersToDraw.Add(mbTilesLayer); // Create the new layer and set the projection as the data is in srid 2276 and our background is srid 3857 (spherical mercator). ShapeFileFeatureLayer zoningLayer = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Zoning.shp")); zoningLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857); zoningLayer.Open(); // Create an Area style on zoom level 1 and then apply it to all zoom levels up to 20. zoningLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoBrushes.Blue)); zoningLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; layersToDraw.Add(zoningLayer); // Create a GeoCanvas to do the drawing GeoCanvas canvas = GeoCanvas.CreateDefaultGeoCanvas(); // Create a GeoImage as the image to draw on GeoImage geoImage = new GeoImage(800, 600); // Start the drawing by specifying the image, extent and map units canvas.BeginDrawing(geoImage, MapUtil.GetDrawingExtent(zoningLayer.GetBoundingBox(), 800, 600), GeographyUnit.Meter); // This collection is used during drawing to pass labels in between layers so we can track collisions Collection <SimpleCandidate> labels = new Collection <SimpleCandidate>(); // Loop through all the layers and draw them to the GeoCanvas // The flush is to compact styles that use different drawing levels foreach (var layer in layersToDraw) { layer.Draw(canvas, labels); canvas.Flush(); } // End drawing, we can now use the GeoImage canvas.EndDrawing(); // Create a memory stream and save the GeoImage as a standard PNG formatted image MemoryStream imageStream = new MemoryStream(); geoImage.Save(imageStream, GeoImageFormat.Png); // Reset the image stream back to the beginning imageStream.Position = 0; return(ImageSource.FromStream(() => { return imageStream; })); }
public static MapUtil getInstance() { if(m_instance == null) return m_instance = new MapUtil(); return m_instance; }