diff --git a/Client/Application/Components/Map.xaml b/Client/Application/Components/Map.xaml index 14ae1dd..6d4a5f8 100644 --- a/Client/Application/Components/Map.xaml +++ b/Client/Application/Components/Map.xaml @@ -13,6 +13,10 @@ MouseLeave="ContentControl_MouseLeave" MouseMove="ContentControl_MouseMove" > + + + 0,1,2,3,4,5 + @@ -29,7 +33,7 @@ + - + + + + + @@ -297,7 +308,7 @@ - + diff --git a/Client/Application/ViewModels/MapBlockViewModel.cs b/Client/Application/ViewModels/MapBlockViewModel.cs index 0fb111c..d6958fd 100644 --- a/Client/Application/ViewModels/MapBlockViewModel.cs +++ b/Client/Application/ViewModels/MapBlockViewModel.cs @@ -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; diff --git a/Client/Application/ViewModels/MapViewModel.cs b/Client/Application/ViewModels/MapViewModel.cs index 881c555..4743b28 100644 --- a/Client/Application/ViewModels/MapViewModel.cs +++ b/Client/Application/ViewModels/MapViewModel.cs @@ -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 blocks = new Dictionary(); + private Dictionary blocks = new Dictionary(); 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; } } diff --git a/Client/Assets/maps/fallback.jpg b/Client/Assets/maps/fallback.jpg new file mode 100644 index 0000000..d343dfb Binary files /dev/null and b/Client/Assets/maps/fallback.jpg differ diff --git a/Client/Domain/Service/MapImageSelector.cs b/Client/Domain/Service/MapImageSelector.cs index bf4fa3c..5eb9e36 100644 --- a/Client/Domain/Service/MapImageSelector.cs +++ b/Client/Domain/Service/MapImageSelector.cs @@ -14,7 +14,7 @@ namespace Client.Domain.Service private static readonly uint DELTA_X = 20; private static readonly uint DELTA_Y = 18; - public List SelectImages(float viewportWidth, float viewportHeight, Vector3 heroPosition, float scale) + public List SelectImages(float viewportWidth, float viewportHeight, Vector3 heroPosition, float scale, int level) { var viewportCenter = new Tuple(viewportWidth / 2, viewportHeight / 2); @@ -46,7 +46,7 @@ namespace Client.Domain.Service (blockTopLeft.Item2 - topLeft.Item2) / scale ); - result.Add(new MapBlock(x, y, delta.Item1, delta.Item2, BLOCK_SIZE / scale)); + result.Add(new MapBlock(x, y, delta.Item1, delta.Item2, BLOCK_SIZE / scale, level)); } } diff --git a/Client/Domain/ValueObjects/MapBlock.cs b/Client/Domain/ValueObjects/MapBlock.cs index 70eee59..db4d098 100644 --- a/Client/Domain/ValueObjects/MapBlock.cs +++ b/Client/Domain/ValueObjects/MapBlock.cs @@ -13,20 +13,24 @@ namespace Client.Domain.ValueObjects private float deltaY; private float size; - public uint Id => (BlockX + BlockY) * (BlockX + BlockY + 1) / 2 + BlockX; + public int Id => (IdWithOutLevel + Level) * (IdWithOutLevel + Level + 1) / 2 + IdWithOutLevel; public uint BlockX { get; set; } public uint BlockY { get; set; } public float DeltaX { get => deltaX; set { if (value != deltaX) { deltaX = value; OnPropertyChanged(); } } } public float DeltaY { get => deltaY; set { if (value != deltaY) { deltaY = value; OnPropertyChanged(); } } } public float Size { get => size; set { if (value != size) { size = value; OnPropertyChanged(); } } } + public int Level { get; set; } - public MapBlock(uint blockX, uint blockY, float deltaX, float deltaY, float size) + private int IdWithOutLevel => (int) ((BlockX + BlockY) * (BlockX + BlockY + 1) / 2 + BlockX); + + public MapBlock(uint blockX, uint blockY, float deltaX, float deltaY, float size, int level) { BlockX = blockX; BlockY = blockY; DeltaX = deltaX; DeltaY = deltaY; Size = size; + Level = level; } } }