예제 #1
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateButtonsEnabled();
            var index = listBox.SelectedIndex;

            _owner.CustomTileHighlights.Clear();
            if (index > -1)
            {
                var current = _owner.Level.CloneConnections[index];
                _owner.CustomTileHighlights.Add(TileConnectionMarker.FromCloneConnection(current));
            }
            _owner.Invalidate(true);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public static bool Equals(TileConnectionMarker left, TileConnectionMarker right)
 {
     return(left.connection == right.connection && left.SourcePen == right.SourcePen && left.DestinationPen == right.DestinationPen && left.LinePen == right.LinePen);
 }