private void layer_ValueChanged(object sender, EventArgs e) { if (!canDetect) { return; } Tilemapper.AdjustLayer(tm.id, (int)layer.Value); Tilemapper.ConvertAndSetMap(tm); }
private void tileSelection_MouseUp(object sender, MouseEventArgs e) { dragging = false; resizing = false; if (selectedSize.Width != 1 || selectedSize.Height != -1) { Tilemapper.SelectTile(tm.id, selected.X * tm.tilesize, selected.Y * tm.tilesize, selectedSize.Width * tm.tilesize, selectedSize.Height * tm.tilesize); } }
private void y_ValueChanged(object sender, EventArgs e) { if (!canDetect) { return; } tm.y = (int)y.Value; Tilemapper.ConvertAndSetMap(tm); Tilemapper.SetCurrentTile(); }
private void tilesize_ValueChanged(object sender, EventArgs e) { if (!canDetect) { return; } tm.tilesize = (int)tilesize.Value; Tilemapper.RefreshEditingEvent(); Tilemapper.SetCurrentTile(); }
private void collides_CheckedChanged(object sender, EventArgs e) { tm.collides = collides.Checked; if (tm.collides) { Tilemapper.ConvertAndSetMap(tm); } else { Engine.form.RefreshBrowser(); } }
private void scale_ValueChanged(object sender, EventArgs e) { if (!canDetect) { return; } tm.scale = (int)scale.Value; if (Tilemapper.editing != -1) { Tilemapper.StopEditing(); Tilemapper.BeginEditing(tm.id); } selected = default(Point); Tilemapper.ConvertAndSetMap(tm); }
private void SelectTile(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left || selected == GetCursorTile()) { return; } try { selected = GetCursorTile(); Tilemapper.SelectTile(tm.id, selected.X * tm.tilesize, selected.Y * tm.tilesize, selectedSize.Width * tm.tilesize, selectedSize.Width * tm.tilesize); } catch (Exception exc) { Feed.GiveException("Tile Selection", exc); } }
public BoundsInt GetWorldBoundary() { return(Tilemapper.GetMaxBoundsOfGrid(gameWorldBaseGrid)); }
public bool IsTilePassable(Vector2Int tileCoords) { return(Tilemapper.IsGridPassableAtCoordinate(gameWorldBaseGrid, tileCoords)); }
private void TilemapForm_Closing(object sender, FormClosingEventArgs e) { Tilemapper.StopEditing(); }
public MovementPath FindShortestPath(Vector2Int source, List <Vector2Int> validDestinations, PathOptions pathOptions) { SortedList <double, Vector2Int> toVisitList = new SortedList <double, Vector2Int>(new DuplicateKeyComparer <double>()); HashSet <Vector2Int> visited = new HashSet <Vector2Int>(); Dictionary <Vector2Int, Vector2Int> originPosition = new Dictionary <Vector2Int, Vector2Int>(); //instantiate the to-visit list toVisitList.Add(0, source); while ((toVisitList.Count > 0) && (!visited.Intersect(validDestinations).Any())) { var currentPosition = toVisitList.Values[0]; var currentCost = toVisitList.Keys[0]; toVisitList.RemoveAt(0); // Debug.Log("visiting " + currentPosition); if (visited.Contains(currentPosition)) { continue; } visited.Add(currentPosition); var neighbours = GetAllNeighbours(currentPosition); foreach (Vector2Int neighbour in neighbours) { if (visited.Contains(neighbour) || toVisitList.ContainsValue(neighbour)) { continue; } if (!Tilemapper.IsGridPassableAtCoordinate(_gameWorld, neighbour)) { continue; } originPosition.Add(neighbour, currentPosition); double newCost = currentCost + CalculateCost(currentPosition, neighbour, 1f); toVisitList.Add(newCost, neighbour); } } if (visited.Intersect(validDestinations).Any()) { //build the return path List <Vector2Int> listOfCoords = new List <Vector2Int>(); var currentPosition = visited.Intersect(validDestinations).First(); var timeout = 0; while (currentPosition != source || timeout > 5000) { listOfCoords.Insert(0, currentPosition); currentPosition = originPosition[currentPosition]; timeout++; } listOfCoords.Insert(0, currentPosition); if (timeout >= 5000) { throw new TimeoutException("Finding source of path timed out -- unexpected!"); } return(new MovementPath(listOfCoords.Select(it => it.ToVec3()).ToList())); } return(null); }