From 4a45d1d615d9565b4b75b7f62068422bad57e8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=98=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD?= Date: Fri, 16 Aug 2024 09:22:34 +0200 Subject: [PATCH] feat: add map levels --- Client/Application/Components/Map.xaml | 17 +++++++++++++--- .../ViewModels/MapBlockViewModel.cs | 2 +- Client/Application/ViewModels/MapViewModel.cs | 19 ++++++++++++++++-- Client/Assets/maps/fallback.jpg | Bin 0 -> 17011 bytes Client/Domain/Service/MapImageSelector.cs | 4 ++-- Client/Domain/ValueObjects/MapBlock.cs | 8 ++++++-- 6 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 Client/Assets/maps/fallback.jpg 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 0000000000000000000000000000000000000000..d343dfb851bb0eb113dec1aa1d150c671ec72fc4 GIT binary patch literal 17011 zcmeIwIZPEn7zglgc4l{G_dSs1@@NbXP_*Mv(Z&G!6gp5*>A>3#JU|m;z?%+l?ZDd( z6;Uft6rsZtun|wB0&gu`XB0J|5*wTUw=>BmJ2UzIJHMbecuH|a(ZVP(#;8U=6g;5< zvKTXCw7AVpIYMw-I#Qac+>oo3r=;{^JTDa1CEeHwG2vMAZVoZq%`QE{N-DErd=<2j zuLKF=EJBvgxX*$Pno7iM-K}YOw3x+(?dX=gkY3Odr`zY;(#_gJ=+!&)cM`rGpOTs9 zBovp+NM&MHZ9}6<&2Mf`D(M+c%dV)ZbG_t=lO|6|pEf;X#>|{qv*+Z_oma46VRX^r z!lEThmz6GGv9fH{>NRWEt>3V5)8;K(t82Dx-?e+s-hKNI)E_)__{h;?$4{JWI(7QY z*>mSFT)cGoO3T&OYu9hwyw!30PUqdO?tAwiJbd)Hx37QT+4C1KU%eiDGc@w{-TMz8 zKYjl4)#PG2=db!1Y)md+=d$!22x)RLt6ER)3p*v#iO(yR<&_DMtXh?r-_Y3H?xtp! z3@24o^?1o?IRoh 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; } } }