Menus, sessions, save and load

This commit is contained in:
Michele Scandura 2020-10-31 08:34:54 +00:00
parent 024df6278c
commit 0c077ea713
3 changed files with 505 additions and 149 deletions

View file

@ -2,215 +2,497 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
// using MonoGame.Extended;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI.File;
using Myra;
using System.IO;
using Microsoft.Xna.Framework.Content;
using Newtonsoft.Json;
namespace MyGame
{
public struct Tile
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation{get;set;}
}
public struct Tile
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation { get; set; }
}
public struct Wall
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation{get;set;}
}
public struct Wall
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation { get; set; }
}
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private Vector2 _topLeft = new Vector2(-20,20);
private Vector2 _topLeft = new Vector2(-20, 20);
private List<Tile> _map = new List<Tile>();
private List<Wall> _mapWalls = new List<Wall>();
private Tile _selectedTile = new Tile{X=1,Y=1};
private Tile _selectedTile = new Tile { X = 1, Y = 1 };
private int _tileSize = 30;
HubConnection connection;
private Desktop _desktop;
private int _currentTileId = 1;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
_map.Add(new Tile{X=5,Y=5,ID=1 });
connection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/ChatHub")
.Build();
connection.StartAsync();
connection.On<string, string>("ReceiveMessage", (user, message) =>
{
var newMessage = $"{user}: {message}";
_map.Add(new Tile{X=int.Parse(user.Split('-')[0]),Y=int.Parse(user.Split('-')[1]),ID =int.Parse(message) });
});
_desktop = new Desktop();
MyraEnvironment.Game = this;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
IsMouseVisible = true;
Window.AllowUserResizing = true;
connection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/ChatHub")
.Build();
connection.On<string, string>("ReceiveMessage", (user, message) =>
{
var newMessage = $"{user}: {message}";
_map.Add(new Tile { X = int.Parse(user.Split(':')[0]), Y = int.Parse(user.Split(':')[1]), ID = int.Parse(message) });
});
connection.On<List<Tile>>("UpdateMap", (map) =>
{
_map = map;
});
base.Initialize();
}
private string _session;
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
MyraEnvironment.Game = this;
var panel = new VerticalStackPanel();
var menu = new HorizontalMenu();
var menuFile = new MenuItem("_file", "File");
var menuFileLoad = new MenuItem("_file_load", "Load");
var menuFileSave = new MenuItem("_file_save", "Save");
var menuConnect = new MenuItem("_connect", "Connect");
var menuConnectNew = new MenuItem("_connect_new", "New");
var menuConnectJoin = new MenuItem("_connect_join", "Join");
var menuConnectSync = new MenuItem("_connect_sync", "Sync");
menuConnectSync.Selected += async (s, e) =>
{
await connection?.InvokeAsync("Sync", _session, _map);
};
menuFileLoad.Selected += (s, e) =>
{
FileDialog dialog = new FileDialog(FileDialogMode.OpenFile)
{
Filter = "*.map"
//Folder = @"D:\Temp"
};
dialog.Closed += (s, a) =>
{
if (!dialog.Result)
{
// "Cancel" or Escape
return;
}
using (StreamReader file = File.OpenText(dialog.FilePath))
{
JsonSerializer serializer = new JsonSerializer();
_map = (List<Tile>)serializer.Deserialize(file, typeof(List<Tile>));
}
// "Ok" or Enter
// ...
};
dialog.ShowModal(_desktop);
};
menuFileSave.Selected += (s, e) =>
{
FileDialog dialog = new FileDialog(FileDialogMode.SaveFile)
{
Filter = "*.map"
//Folder = @"D:\Temp"
};
dialog.Closed += (s, a) =>
{
if (!dialog.Result)
{
// "Cancel" or Escape
return;
}
using (StreamWriter file = File.CreateText(dialog.FilePath))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, _map);
}
// "Ok" or Enter
// ...
};
dialog.ShowModal(_desktop);
};
menuConnectNew.Selected += (s, e) =>
{
Window window = new Window
{
Title = "New mapping session"
};
var content = new VerticalStackPanel();
var textbox = new TextBox();
TextButton button = new TextButton
{
Text = "Start",
HorizontalAlignment = HorizontalAlignment.Center
};
button.Click += async (s, e) =>
{
if (string.IsNullOrWhiteSpace(textbox.Text))
{
return;
}
if (connection.State != HubConnectionState.Connected)
{ await connection.StartAsync(); }
var successful = false;
try
{
await connection?.InvokeAsync("NewSession", textbox.Text);
successful = true;
}
catch { }
if (successful)
{
_session = textbox.Text;
window.Close();
}
};
content.Widgets.Add(textbox);
content.Widgets.Add(button);
window.Content = content;
window.Closed += (s, a) =>
{
// Called when window is closed
};
window.ShowModal(_desktop);
};
menuConnectJoin.Selected += (s, e) =>
{
Window window = new Window
{
Title = "Join mapping session"
};
var content = new VerticalStackPanel();
var textbox = new TextBox();
TextButton button = new TextButton
{
Text = "Start",
HorizontalAlignment = HorizontalAlignment.Center
};
button.Click += async (s, e) =>
{
if (string.IsNullOrWhiteSpace(textbox.Text))
{
return;
}
if (connection.State != HubConnectionState.Connected)
{ await connection.StartAsync(); }
var successful = false;
try
{
var result = await connection?.InvokeAsync<bool>("JoinSession", textbox.Text);
if (result)
{
_map = await connection.InvokeAsync<List<Tile>>("Refresh", textbox.Text);
}
successful = result;
}
catch { }
if (successful)
{
_session = textbox.Text;
window.Close();
}
};
content.Widgets.Add(textbox);
content.Widgets.Add(button);
window.Content = content;
window.Closed += (s, a) =>
{
// Called when window is closed
};
window.ShowModal(_desktop);
};
menuConnect.Items.Add(menuConnectNew);
menuConnect.Items.Add(menuConnectJoin);
menuConnect.Items.Add(menuConnectSync);
menu.Items.Add(menuConnect);
menuFile.Items.Add(menuFileLoad);
menuFile.Items.Add(menuFileSave);
menu.Items.Add(menuFile);
menu.Items.Add(menuConnect);
panel.Widgets.Add(menu);
_desktop.MenuBar = menu;
_desktop.MenuBar.Visible = true;
_desktop.MenuBar.Enabled = true;
var panel2 = new Grid { Width = 200 };
panel.Widgets.Add(panel2);
panel2.Background = new SolidBrush(Color.DarkGray);
panel2.Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200;this.h=W.h");
var grid = new Grid
{
RowSpacing = 8,
ColumnSpacing = 8
};
grid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));
grid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));
grid.RowsProportions.Add(new Proportion(ProportionType.Fill));
grid.RowsProportions.Add(new Proportion(ProportionType.Fill));
var helloWorld = new Label
{
Id = "label",
Text = "",
GridColumn = 1,
GridRow = 0
};
grid.Widgets.Add(helloWorld);
//var panel = new Panel {Width=100,Height=100, GridColumn=0,GridRow=1};
// ComboBox
//grid.Widgets.Add(panel);
// Button
var button = new TextButton
{
GridColumn = 0,
GridRow = 0,
Text = "Connect"
};
button.Click += async (s, a) =>
{
((TextButton)s).Text = "Connected";
};
grid.Widgets.Add(button);
var folderContent = Content.LoadContentFolder<Texture2D>("tiles");
var indexX = 0;
var indexY = 0;
foreach (var item in folderContent)
{
var tileButton = new ImageButton { Image = new TextureRegion(item.Value), GridColumn = indexY, GridRow = indexX, Id = item.Key };
tileButton.Click += (s, e) =>
{
_currentTileId = int.Parse(((ImageButton)s).Id.Replace("tile", ""));
foreach (var widget in panel2.Widgets)
{
widget.Border = null;
}
((ImageButton)s).Border = new SolidBrush(Color.Red);
((ImageButton)s).BorderThickness = new Myra.Graphics2D.Thickness(2);
};
panel2.Widgets.Add(tileButton);
indexY++;
if (indexY == 4)
{
indexY = 0;
indexX++;
}
}
// Add it to the desktop
// _desktop = new Desktop();
_desktop.Root = panel;
// TODO: use this.Content to load your game content here
}
private KeyboardState oldState;
private MouseState oldMouseState;
private KeyboardState oldState;
private MouseState oldMouseState;
private Vector3 _viewportCenter = new Vector3(0,0,0);
private Vector3 _viewportCenter = new Vector3(0, 0, 0);
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
KeyboardState newState = Keyboard.GetState();
KeyboardState newState = Keyboard.GetState();
// TODO: Add your update logic here
var mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton!=oldMouseState.LeftButton)
{
_selectedTile.X=(mouseState.Position.X-(int)_viewportCenter.X)/_tileSize;
_selectedTile.Y=(mouseState.Position.Y-(int)_viewportCenter.Y)/_tileSize;
}
var mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton != oldMouseState.LeftButton)
{
_selectedTile.X = (mouseState.Position.X - (int)_viewportCenter.X) / _tileSize;
_selectedTile.Y = (mouseState.Position.Y - (int)_viewportCenter.Y) / _tileSize;
if(mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton==oldMouseState.LeftButton)
{
_viewportCenter = new Vector3 (_viewportCenter.X+ mouseState.Position.X-oldMouseState.Position.X,_viewportCenter.Y+ mouseState.Position.Y-oldMouseState.Position.Y ,0);
}
System.Console.WriteLine(_viewportCenter.X);
System.Console.WriteLine(_viewportCenter.Y);
}
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton != oldMouseState.LeftButton)
{
_selectedTile.X = (mouseState.Position.X - (int)_viewportCenter.X) / _tileSize;
_selectedTile.Y = (mouseState.Position.Y - (int)_viewportCenter.Y) / _tileSize;
SetTile(_currentTileId);
foreach(var key in newState.GetPressedKeys())
{
switch(key)
{
case Keys.Left:
if (oldState.IsKeyUp(Keys.Left) && newState.IsKeyDown(Keys.Left))
{_selectedTile.X--;}
break;
case Keys.Right:
if (oldState.IsKeyUp(Keys.Right) && newState.IsKeyDown(Keys.Right))
{_selectedTile.X++;}
break;
case Keys.Up:
if (oldState.IsKeyUp(Keys.Up) && newState.IsKeyDown(Keys.Up))
{_selectedTile.Y--;}
break;
case Keys.Down:
if (oldState.IsKeyUp(Keys.Down) && newState.IsKeyDown(Keys.Down))
{_selectedTile.Y++;}
break;
}
if (oldState.IsKeyUp(key) && newState.IsKeyDown(key))
{
var tileId=((int)key)-48;
if (tileId>=1 && tileId<=9)
{
var tileExist = _map.Any(m=>m.X==_selectedTile.X && m.Y==_selectedTile.Y);
if (tileExist)
}
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == oldMouseState.LeftButton)
{
_viewportCenter = new Vector3(_viewportCenter.X + mouseState.Position.X - oldMouseState.Position.X, _viewportCenter.Y + mouseState.Position.Y - oldMouseState.Position.Y, 0);
}
foreach (var key in newState.GetPressedKeys())
{
switch (key)
{
var tile = _map.First(m=>m.X==_selectedTile.X && m.Y==_selectedTile.Y);
var index = _map.IndexOf(tile);
_map.RemoveAt(index);
if(tile.ID==tileId)
{
var newTile = new Tile{X=_selectedTile.X,Y=_selectedTile.Y,ID=tileId,Rotation=(tile.Rotation+1)%4};
_map.Add(newTile);
System.Console.WriteLine(newTile.Rotation);
}
else{
_map.Add(new Tile{X=_selectedTile.X,Y=_selectedTile.Y,ID=tileId});
}
case Keys.Left:
if (oldState.IsKeyUp(Keys.Left) && newState.IsKeyDown(Keys.Left))
{ _selectedTile.X--; }
break;
case Keys.Right:
if (oldState.IsKeyUp(Keys.Right) && newState.IsKeyDown(Keys.Right))
{ _selectedTile.X++; }
break;
case Keys.Up:
if (oldState.IsKeyUp(Keys.Up) && newState.IsKeyDown(Keys.Up))
{ _selectedTile.Y--; }
break;
case Keys.Down:
if (oldState.IsKeyUp(Keys.Down) && newState.IsKeyDown(Keys.Down))
{ _selectedTile.Y++; }
break;
}
else{
_map.Add(new Tile{X=_selectedTile.X,Y=_selectedTile.Y, ID=tileId});
connection.InvokeAsync("SendMessage",$"{_selectedTile.X}-{_selectedTile.Y}", tileId.ToString());
if (oldState.IsKeyUp(key) && newState.IsKeyDown(key))
{
var tileId = ((int)key) - 48;
if (tileId >= 1 && tileId <= 9)
{
SetTile(tileId);
}
}
}
}
}
oldState=newState;
oldMouseState=mouseState;
oldState = newState;
oldMouseState = mouseState;
base.Update(gameTime);
}
private void SetTile(int tileId)
{
var tileExist = _map.Any(m => m.X == _selectedTile.X && m.Y == _selectedTile.Y);
if (tileExist)
{
var tile = _map.First(m => m.X == _selectedTile.X && m.Y == _selectedTile.Y);
var index = _map.IndexOf(tile);
_map.RemoveAt(index);
if (tile.ID == tileId)
{
var newTile = new Tile { X = _selectedTile.X, Y = _selectedTile.Y, ID = tileId, Rotation = (tile.Rotation + 1) % 4 };
_map.Add(newTile);
System.Console.WriteLine(newTile.Rotation);
}
else
{
_map.Add(new Tile { X = _selectedTile.X, Y = _selectedTile.Y, ID = tileId });
}
}
else
{
_map.Add(new Tile { X = _selectedTile.X, Y = _selectedTile.Y, ID = tileId });
connection?.InvokeAsync("SendMessage", $"{_selectedTile.X}:{_selectedTile.Y}", tileId.ToString(),_session);
}
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
if (_spriteBatch is null)
{
return;
}
GraphicsDevice.Clear(Color.DarkGray);
// TODO: Add your drawing code here
var visibleTilesX = (int)GraphicsDevice.Viewport.Width/_tileSize +1;
var visibleTilesY = (int)GraphicsDevice.Viewport.Height/_tileSize +1;
_spriteBatch.Begin(transformMatrix:Matrix.CreateTranslation(_viewportCenter));
var visibleTilesX = (int)GraphicsDevice.Viewport.Width / _tileSize + 1;
var visibleTilesY = (int)GraphicsDevice.Viewport.Height / _tileSize + 1;
for (var i = 0;i<visibleTilesX;i++)
_spriteBatch.Begin(transformMatrix: Matrix.CreateTranslation(_viewportCenter));
for (var i = 0; i < visibleTilesX; i++)
{
var posX1=i*_tileSize-_viewportCenter.X;
var posY1=-_viewportCenter.Y;
posX1=posX1-posX1%_tileSize;
posY1=posY1-posY1%_tileSize;
var posX2=i*_tileSize-_viewportCenter.X;
var posY2=GraphicsDevice.Viewport.Height-_viewportCenter.Y;
posX2=posX2-posX2%_tileSize;
posY2=posY2-posY2%_tileSize;
var posX1 = i * _tileSize - _viewportCenter.X;
var posY1 = -_viewportCenter.Y;
posX1 = posX1 - posX1 % _tileSize;
posY1 = posY1 - posY1 % _tileSize;
var posX2 = i * _tileSize - _viewportCenter.X;
var posY2 = GraphicsDevice.Viewport.Height - _viewportCenter.Y;
posX2 = posX2 - posX2 % _tileSize;
posY2 = posY2 - posY2 % _tileSize;
_spriteBatch.DrawLine(
posX1,posY1,
posX1, posY1,
posX2,
posY2,
Color.Black);
}
for (var i = 0;i<visibleTilesY;i++)
for (var i = 0; i < visibleTilesY; i++)
{
var posX1=-_viewportCenter.X;
var posY1=i*_tileSize-_viewportCenter.Y;
posX1=posX1-posX1%_tileSize;
posY1=posY1-posY1%_tileSize;
var posX2=GraphicsDevice.Viewport.Width-_viewportCenter.X;
var posY2=i*_tileSize-_viewportCenter.Y;
posX2=posX2-posX2%_tileSize;
posY2=posY2-posY2%_tileSize;
var posX1 = -_viewportCenter.X;
var posY1 = i * _tileSize - _viewportCenter.Y;
posX1 = posX1 - posX1 % _tileSize;
posY1 = posY1 - posY1 % _tileSize;
var posX2 = GraphicsDevice.Viewport.Width - _viewportCenter.X;
var posY2 = i * _tileSize - _viewportCenter.Y;
posX2 = posX2 - posX2 % _tileSize;
posY2 = posY2 - posY2 % _tileSize;
_spriteBatch.DrawLine( posX1,posY1,
_spriteBatch.DrawLine(posX1, posY1,
posX2,
posY2,
Color.Black);
}
foreach(var tile in _map)
foreach (var tile in _map)
{
var content = Content.Load<Texture2D>($"tiles/tile{tile.ID.ToString().PadLeft(2,'0')}");
var destinationRectangle = new Rectangle(tile.X*_tileSize,tile.Y*_tileSize,_tileSize,_tileSize);
var content = Content.Load<Texture2D>($"tiles/tile{tile.ID.ToString().PadLeft(2, '0')}");
var destinationRectangle = new Rectangle(tile.X * _tileSize, tile.Y * _tileSize, _tileSize, _tileSize);
// _spriteBatch.Draw(
// content,
// destinationRectangle,
@ -220,30 +502,49 @@ posY2=posY2-posY2%_tileSize;
// new Vector2(tile.X*_tileSize+_tileSize/2f, tile.Y*_tileSize+_tileSize/2f),
// SpriteEffects.None,
// 1);
var posX=tile.X*_tileSize+_tileSize/2f;
var posY=tile.Y*_tileSize+_tileSize/2f;
_spriteBatch.Draw(content,new Vector2(posX, posY),
null,Color.White,MathHelper.ToRadians(90*tile.Rotation),new Vector2(content.Width/2,content.Height/2),1,SpriteEffects.None,0);
var posX = tile.X * _tileSize + _tileSize / 2f;
var posY = tile.Y * _tileSize + _tileSize / 2f;
// _spriteBatch.Draw(
// content,
// destinationRectangle,
// null,
// Color.White,MathHelper.ToRadians(90*tile.Rotation),new Vector2(destinationRectangle.X,destinationRectangle.Y)
// );
_spriteBatch.Draw(content, new Vector2(posX, posY),
null, Color.White, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(content.Width / 2, content.Height / 2), 1, SpriteEffects.None, 0);
//var rf = new RectangleF(tile.X*_tileSize,tile.Y*_tileSize,_tileSize,_tileSize);
// _spriteBatch.Draw(
// content,
// destinationRectangle,
// null,
// Color.White,MathHelper.ToRadians(90*tile.Rotation),new Vector2(destinationRectangle.X,destinationRectangle.Y)
// );
// _spriteBatch.DrawRectangle(rf,Color.Red,3,0);
//var rf = new RectangleF(tile.X*_tileSize,tile.Y*_tileSize,_tileSize,_tileSize);
// _spriteBatch.DrawRectangle(rf,Color.Red,3,0);
}
_spriteBatch.DrawRectangle(new RectangleF(_selectedTile.X*_tileSize,_selectedTile.Y*_tileSize,_tileSize,_tileSize),Color.Blue,3,0);
_spriteBatch.DrawRectangle(new Rectangle(_selectedTile.X * _tileSize, _selectedTile.Y * _tileSize, _tileSize, _tileSize), Color.Blue, 3);
_spriteBatch.End();
_desktop?.Render();
base.Draw(gameTime);
}
}
public static class ExtensionMethods
{
public static Dictionary<string, T> LoadContentFolder<T>(this ContentManager contentManager, string contentFolder)
{
DirectoryInfo dir = new DirectoryInfo(contentManager.RootDirectory + "/" + contentFolder);
if (!dir.Exists)
throw new DirectoryNotFoundException();
Dictionary<string, T> result = new Dictionary<string, T>();
FileInfo[] files = dir.GetFiles("*.*");
foreach (FileInfo file in files)
{
result.Add(file.Name.Split('.')[0], contentManager.Load<T>(contentFolder + "/" + file.Name.Split('.')[0]));
}
return result;
}
}
}

View file

@ -26,10 +26,12 @@
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<!-- <PackageReference Include="MonoGame.Extended" Version="3.8.0" /> -->
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client">
<Version>3.1.9</Version>
</PackageReference>
<PackageReference Include="Myra" Version="1.0.2.211" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>

View file

@ -1,13 +1,66 @@
using Microsoft.AspNetCore.SignalR;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SignalRChat.Hubs
{
public struct Tile
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation { get; set; }
}
public class SessionData
{
public SessionData()
{
Map = new List<Tile>();
}
public List<Tile> Map { get; set; }
public bool IsValid { get; set; }
}
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
private static Dictionary<string, SessionData> _sessions = new Dictionary<string, SessionData>();
public async Task SendMessage(string user, string message, string sessionName)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
await Clients.Group(sessionName).SendAsync("ReceiveMessage", user, message);
}
public async Task NewSession(string sessionName)
{
_sessions.Add(sessionName, new SessionData());
await Groups.AddToGroupAsync(Context.ConnectionId, sessionName);
}
public async Task<bool> JoinSession(string sessionName)
{
if (_sessions.ContainsKey(sessionName))
{
await Groups.AddToGroupAsync(Context.ConnectionId, sessionName);
return true;
}
else
{
return false;
}
}
public async Task<List<Tile>> Refresh(string sessionName)
{
return _sessions[sessionName].Map;
}
public async Task Sync(string sessionName, List<Tile> map)
{
_sessions[sessionName].Map = map;
await Clients.Group(sessionName).SendAsync("UpdateMap", map);
}
}
}