feat: add map levels
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
MouseLeave="ContentControl_MouseLeave"
|
||||
MouseMove="ContentControl_MouseMove"
|
||||
>
|
||||
<ContentControl.Resources>
|
||||
<BitmapImage x:Key="FallbackImage" UriSource="../../Assets/maps/fallback.jpg" />
|
||||
<Int32Collection x:Key="mapLevels">0,1,2,3,4,5</Int32Collection>
|
||||
</ContentControl.Resources>
|
||||
<Grid Background="Transparent">
|
||||
<Grid.InputBindings>
|
||||
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Grid}}" />
|
||||
@@ -29,7 +33,7 @@
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Image
|
||||
Source="{Binding ImageSource,Mode=OneWay}"
|
||||
Source="{Binding ImageSource,Mode=OneWay,FallbackValue={StaticResource FallbackImage},TargetNullValue={StaticResource FallbackImage}}"
|
||||
Width="{Binding Size,Mode=OneWay}"
|
||||
Height="{Binding Size,Mode=OneWay}"
|
||||
Visibility="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
@@ -286,10 +290,17 @@
|
||||
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Background="#66ffffff">
|
||||
<Grid Margin="10 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="90"></ColumnDefinition>
|
||||
<ColumnDefinition Width="30"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Padding="0 0 0 3">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label>Map level:</Label>
|
||||
<ComboBox
|
||||
SelectedValue="{Binding MapLevel}"
|
||||
ItemsSource="{StaticResource mapLevels}" Margin="0,0,10,0"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Padding="0 0 0 3" VerticalAlignment="Center">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="{}{0:F0}, {1:F0}">
|
||||
<Binding Path="MousePosition.X" Mode="OneWay"/>
|
||||
@@ -297,7 +308,7 @@
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Scale,Mode=OneWay,StringFormat='{}1:{0}'}" HorizontalAlignment="Right" />
|
||||
<Label Grid.Column="2" Content="{Binding Scale,Mode=OneWay,StringFormat='{}1:{0}'}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
@@ -11,7 +11,7 @@ namespace Client.Application.ViewModels
|
||||
{
|
||||
public class MapBlockViewModel : ObservableObject
|
||||
{
|
||||
public string ImageSource => "/Assets/maps/" + mapBlock.BlockX + "_" + mapBlock.BlockY + ".jpg";
|
||||
public string ImageSource => "/Assets/maps/" + mapBlock.BlockX + "_" + mapBlock.BlockY + (mapBlock.Level > 0 ? "_" + mapBlock.Level : "") + ".jpg";
|
||||
public float DeltaX => mapBlock.DeltaX;
|
||||
public float DeltaY => mapBlock.DeltaY;
|
||||
public float Size => mapBlock.Size;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Client.Application.Commands;
|
||||
using Client.Application.Components;
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.DTO;
|
||||
using Client.Domain.Entities;
|
||||
@@ -83,6 +84,19 @@ namespace Client.Application.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public int MapLevel
|
||||
{
|
||||
get => mapLevel;
|
||||
set
|
||||
{
|
||||
if (mapLevel != value)
|
||||
{
|
||||
mapLevel = value;
|
||||
UpdateMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 MousePosition
|
||||
{
|
||||
get => mousePosition;
|
||||
@@ -107,7 +121,7 @@ namespace Client.Application.ViewModels
|
||||
|
||||
if (hero != null)
|
||||
{
|
||||
var blocks = selector.SelectImages((float)ViewportWidth, (float)ViewportHeight, hero.Transform.Position, Scale);
|
||||
var blocks = selector.SelectImages((float)ViewportWidth, (float)ViewportHeight, hero.Transform.Position, Scale, MapLevel);
|
||||
|
||||
foreach (var block in blocks)
|
||||
{
|
||||
@@ -328,7 +342,7 @@ namespace Client.Application.ViewModels
|
||||
public readonly static float MAX_SCALE = 128;
|
||||
private readonly AsyncPathMoverInterface pathMover;
|
||||
private MapImageSelector selector = new MapImageSelector();
|
||||
private Dictionary<uint, MapBlockViewModel> blocks = new Dictionary<uint, MapBlockViewModel>();
|
||||
private Dictionary<int, MapBlockViewModel> blocks = new Dictionary<int, MapBlockViewModel>();
|
||||
private Hero? hero;
|
||||
private float scale = 8;
|
||||
private double viewportWidth = 0;
|
||||
@@ -336,5 +350,6 @@ namespace Client.Application.ViewModels
|
||||
private Vector3 mousePosition = new Vector3(0, 0, 0);
|
||||
private object pathCollectionLock = new object();
|
||||
private AICombatZoneMapViewModel? combatZone = null;
|
||||
private int mapLevel = 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user