public void ClearIntermediateConnections() { var oldHighlights = new HighlightMarker[_intermediateConnectionHighlights.Count]; _intermediateConnectionHighlights.CopyTo(oldHighlights, 0); _intermediateConnectionHighlights.Clear(); foreach (var highlight in oldHighlights) { highlight.Invalidate(this); } currentConnection = TileConnection.Invalid; }
private void listBox_SelectedIndexChanged(object sender, EventArgs e) { UpdateButtonsEnabled(); var index = listBox.SelectedIndex; _owner.CustomTileHighlights.Clear(); if (index > -1) { var current = _owner.Level.MonsterLocations[index]; _owner.CustomTileHighlights.Add(HighlightMarker.FromMonster(current)); } _owner.Invalidate(); }
public void SetTrapConnection(TileLocation location) { if (currentConnection.Source == TileLocation.Invalid) { currentConnection.Source = location; _intermediateConnectionHighlights.Add(new TileLocationMarker(location, Pens.Blue)); Invalidate(location); } else { currentConnection.Destination = location; _history.Do(new AddTrapConnectionCommand(currentConnection)); var marker = HighlightMarker.FromTrapConnection(currentConnection); _tileHighlights.Add(marker); ClearIntermediateConnections(); marker.Invalidate(this); } }
internal void UpdateTileCoordinatesAndHighlights() { var location = currentTileLocation; _owner.CoordinatesStatusText = string.Format(CultureInfo.CurrentCulture, "{0}", location); var oldHighlights = new TileConnectionMarker[_tileHighlights.Count]; _tileHighlights.CopyTo(oldHighlights, 0); _tileHighlights.Clear(); foreach (var highlight in oldHighlights) { highlight.Invalidate(this); } var upperTile = Level.UpperLayer[location]; if (upperTile == Tile.Teleport) { var nextTeleport = Level.UpperLayer.FindNextTeleport(location); if (nextTeleport.IsValid()) { var marker = HighlightMarker.FromTeleportConnection(new TileConnection(location, nextTeleport)); _tileHighlights.Add(marker); _owner.CoordinatesStatusText += string.Format(CultureInfo.CurrentCulture, " → {1}", location, nextTeleport); marker.Invalidate(this); } } var cloneDestinations = Level.CloneConnections.GetDestinationsFromSource(location); if (cloneDestinations != null && cloneDestinations.Count > 0) { var sb = new StringBuilder(); for (int i = 0; i < cloneDestinations.Count; i++) { if (i > 0) { sb.Append(", "); } var destination = cloneDestinations[i]; var marker = HighlightMarker.FromCloneConnection(new TileConnection(location, destination)); _tileHighlights.Add(marker); sb.AppendFormat("{0}", destination); marker.Invalidate(this); } _owner.CoordinatesStatusText += string.Format(CultureInfo.CurrentCulture, " → {1}", location, sb); } var cloneSources = Level.CloneConnections.GetSourcesFromDestination(location); if (cloneSources != null && cloneSources.Count > 0) { var sb = new StringBuilder(); for (int i = 0; i < cloneSources.Count; i++) { if (i > 0) { sb.Append(", "); } var source = cloneSources[i]; var marker = HighlightMarker.FromCloneConnection(new TileConnection(source, location)); _tileHighlights.Add(marker); sb.AppendFormat("{0}", source); marker.Invalidate(this); } _owner.CoordinatesStatusText += string.Format(CultureInfo.CurrentCulture, " ← {1}", location, sb); } var trapDestinations = Level.TrapConnections.GetDestinationsFromSource(location); if (trapDestinations != null && trapDestinations.Count > 0) { var sb = new StringBuilder(); for (int i = 0; i < trapDestinations.Count; i++) { if (i > 0) { sb.Append(", "); } var destination = trapDestinations[i]; var marker = HighlightMarker.FromTrapConnection(new TileConnection(location, destination)); _tileHighlights.Add(marker); sb.AppendFormat("{0}", destination); marker.Invalidate(this); } _owner.CoordinatesStatusText += string.Format(CultureInfo.CurrentCulture, " → {1}", location, sb); } var trapSources = Level.TrapConnections.GetSourcesFromDestination(location); if (trapSources != null && trapSources.Count > 0) { var sb = new StringBuilder(); for (int i = 0; i < trapSources.Count; i++) { if (i > 0) { sb.Append(", "); } var source = trapSources[i]; var marker = HighlightMarker.FromTrapConnection(new TileConnection(source, location)); _tileHighlights.Add(marker); sb.AppendFormat("{0}", source); marker.Invalidate(this); } _owner.CoordinatesStatusText += string.Format(CultureInfo.CurrentCulture, " ← {1}", location, sb); } }