initial work on overlays

This commit is contained in:
Michele Scandura 2020-11-02 16:40:41 +00:00
parent c8e96425cd
commit c2be21dacb
62 changed files with 319 additions and 185756 deletions

View file

@ -13,7 +13,7 @@
#---------------------------------- Content ---------------------------------#
#begin tiles/tile01.png
#begin overlays/overlay01.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@ -23,7 +23,19 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:tiles/tile01.png
/build:overlays/overlay01.png
#begin overlays/overlay02.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:overlays/overlay02.png
#begin tiles/tile01.png
/importer:TextureImporter
@ -49,18 +61,6 @@
/processorParam:TextureFormat=Color
/build:tiles/tile02.png
#begin tiles/tile02.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:tiles/tile02.png
#begin tiles/tile03.png
/importer:TextureImporter
/processor:TextureProcessor
@ -73,30 +73,6 @@
/processorParam:TextureFormat=Color
/build:tiles/tile03.png
#begin tiles/tile03.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:tiles/tile03.png
#begin tiles/tile04.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:tiles/tile04.png
#begin tiles/tile04.png
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

View file

@ -2,63 +2,40 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
// using MonoGame.Extended;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Myra.Graphics2D.UI;
using Myra;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.UI.File;
using Myra;
using System.IO;
using Microsoft.Xna.Framework.Content;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MyGame
{
public enum InsertMode
{
Tile,
Wall,
Overlay
}
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 class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private Vector2 _topLeft = new Vector2(-20, 20);
private List<Tile> _map = new List<Tile>();
private List<Wall> _mapWalls = new List<Wall>();
private List<Overlay> _overlays = new List<Overlay>();
private Tile _selectedTile = new Tile { X = 1, Y = 1 };
private Tile _hoveredTile = new Tile { X = 1, Y = 1 };
private Wall _selectedWall = new Wall { X = 1, Y = 1 };
private Overlay _selectedOverlay = new Overlay { X = 1, Y = 1 };
private int _tileSize = 30;
HubConnection connection;
private Desktop _desktop;
private HubConnection connection;
private readonly Desktop _desktop;
private int _currentTileId = 1;
private int _currentWallId = 1;
private InsertMode _insertMode;
private string _session;
private KeyboardState oldState;
private MouseState oldMouseState;
private Vector3 _viewportCenter = new Vector3(0, 0, 0);
public Game1()
{
@ -76,18 +53,20 @@ namespace MyGame
connection = new HubConnectionBuilder()
.WithUrl("http://hub.michelescandura.com: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;
private HorizontalMenu BuildMenu()
{
@ -280,17 +259,22 @@ namespace MyGame
mainPanel.Widgets.Add(menu);
var sidePanel = new VerticalStackPanel { Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200;this.h=W.h"), Background = new SolidBrush(Color.DarkGray) };
var tileScrollView = new ScrollViewer { Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200;this.h=W.h/3") };
var tileGrid = new Grid { ColumnSpacing = 3, RowSpacing = 3, Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200"), Background = new SolidBrush(Color.DarkGray) };
tileScrollView.Content = tileGrid;
sidePanel.Widgets.Add(tileScrollView);
var wallScrollView = new ScrollViewer { Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200;this.h=W.h/3") };
var wallGrid = new Grid { ColumnSpacing = 3, RowSpacing = 3, Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200"), Background = new SolidBrush(Color.DarkGray) };
wallScrollView.Content = wallGrid;
sidePanel.Widgets.Add(wallScrollView);
// _desktop.MenuBar = menu;
// _desktop.MenuBar.Visible = true;
// _desktop.MenuBar.Enabled = true;
var overlayScrollView = new ScrollViewer { Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200;this.h=W.h/3") };
var overlayGrid = new Grid { ColumnSpacing = 3, RowSpacing = 3, Layout2d = new Myra.Graphics2D.UI.Properties.Layout2D("this.w=200"), Background = new SolidBrush(Color.DarkGray) };
overlayScrollView.Content = overlayGrid;
sidePanel.Widgets.Add(overlayScrollView);
mainPanel.Widgets.Add(sidePanel);
var tilesFolderContent = Content.LoadContentFolder<Texture2D>("tiles");
@ -306,6 +290,8 @@ namespace MyGame
ClearSelection(wallGrid);
ClearSelection(tileGrid);
ClearSelection(overlayGrid);
((ImageButton)s).Border = new SolidBrush(Color.Red);
((ImageButton)s).BorderThickness = new Myra.Graphics2D.Thickness(2);
_insertMode = InsertMode.Tile;
@ -331,6 +317,7 @@ namespace MyGame
_currentWallId = int.Parse(((ImageButton)s).Id.Replace("wall", ""));
ClearSelection(wallGrid);
ClearSelection(tileGrid);
ClearSelection(overlayGrid);
((ImageButton)s).Border = new SolidBrush(Color.Red);
@ -347,7 +334,34 @@ namespace MyGame
}
}
var overlayFolderContent = Content.LoadContentFolder<Texture2D>("overlays");
indexX = 0;
indexY = 0;
foreach (var item in overlayFolderContent)
{
var overlayButton = new ImageButton { Image = new TextureRegion(item.Value), GridColumn = indexY, GridRow = indexX, Id = item.Key, Width = 40, Height = 40 };
overlayButton.Click += (s, e) =>
{
_currentWallId = int.Parse(((ImageButton)s).Id.Replace("overlay", ""));
ClearSelection(wallGrid);
ClearSelection(tileGrid);
ClearSelection(overlayGrid);
((ImageButton)s).Border = new SolidBrush(Color.Red);
((ImageButton)s).BorderThickness = new Myra.Graphics2D.Thickness(2);
_insertMode = InsertMode.Overlay;
};
overlayGrid.Widgets.Add(overlayButton);
indexY++;
if (indexY == 4)
{
indexY = 0;
indexX++;
}
}
// Add it to the desktop
// _desktop = new Desktop();
@ -355,71 +369,6 @@ namespace MyGame
// TODO: use this.Content to load your game content here
}
private void ClearSelection(Grid grid)
{
foreach (var widget in grid.Widgets)
{
widget.Border = null;
}
}
private KeyboardState oldState;
private MouseState oldMouseState;
private Vector3 _viewportCenter = new Vector3(0, 0, 0);
float Sign2(Point p1, Point p2, Point p3) { return (p1.X - p3.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p3.Y); }
bool PointInTri(Point pt, Point v1, Point v2, Point v3)
{
bool b1, b2, b3;
b1 = Sign2(pt, v1, v2) < 0.0f;
b2 = Sign2(pt, v2, v3) < 0.0f;
b3 = Sign2(pt, v3, v1) < 0.0f;
return ((b1 == b2) && (b2 == b3));
}
private void SelectClosestWall(Point mousePosition)
{
var topLeft = new Point(_hoveredTile.X * _tileSize, _hoveredTile.Y * _tileSize);
var bottomLeft = new Point(_hoveredTile.X * _tileSize, _hoveredTile.Y * _tileSize + _tileSize);
var topRight = new Point(_hoveredTile.X * _tileSize + _tileSize, _hoveredTile.Y * _tileSize);
var bottomRight = new Point(_hoveredTile.X * _tileSize + _tileSize, _hoveredTile.Y * _tileSize + _tileSize);
var center = new Point(_hoveredTile.X * _tileSize + _tileSize / 2, _hoveredTile.Y * _tileSize + _tileSize / 2);
System.Console.WriteLine($"{mousePosition.X} - {mousePosition.Y}");
System.Console.WriteLine($"{_hoveredTile.X} - {_hoveredTile.Y}");
var leftWall = PointInTri(mousePosition, topLeft, center, bottomLeft);
var rightWall = PointInTri(mousePosition, topRight, bottomRight, center);
var topWall = PointInTri(mousePosition, topLeft, topRight, center);
var bottomtWall = PointInTri(mousePosition, bottomLeft, center, bottomRight);
if (leftWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 1;
}
else if (rightWall)
{
_selectedWall.X = _hoveredTile.X + 1;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 1;
}
else if (topWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 0;
}
else if (bottomtWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y + 1;
_selectedWall.Rotation = 0;
}
}
private int scrollvalue=0;
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
@ -442,18 +391,17 @@ private int scrollvalue=0;
_hoveredTile.Y--;
}
SelectClosestWall(screenPosition);
SelectOverlay(screenPosition);
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton != oldMouseState.LeftButton)
{
_selectedTile.X = _hoveredTile.X;
_selectedTile.Y = _hoveredTile.Y;
_selectedTile.X = _hoveredTile.X;
_selectedTile.Y = _hoveredTile.Y;
}
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton != oldMouseState.LeftButton)
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.LeftButton == ButtonState.Pressed)
{
switch (_insertMode)
{
@ -472,24 +420,42 @@ private int scrollvalue=0;
}
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == oldMouseState.LeftButton)
if (!newState.IsKeyDown(Keys.LeftControl) && 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);
}
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.ScrollWheelValue!=oldMouseState.ScrollWheelValue)
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.ScrollWheelValue != oldMouseState.ScrollWheelValue)
{
if (mouseState.ScrollWheelValue>oldMouseState.ScrollWheelValue)
if (mouseState.ScrollWheelValue > oldMouseState.ScrollWheelValue)
{
_tileSize=System.Math.Min(120, _tileSize+10);
_tileSize = System.Math.Min(120, _tileSize + 10);
}
else if (mouseState.ScrollWheelValue<oldMouseState.ScrollWheelValue)
else if (mouseState.ScrollWheelValue < oldMouseState.ScrollWheelValue)
{
_tileSize=System.Math.Max(10, _tileSize-10);
_tileSize = System.Math.Max(10, _tileSize - 10);
}
}
if (newState.IsKeyDown(Keys.Delete))
{
switch (_insertMode)
{
case InsertMode.Tile:
_selectedTile.X = _hoveredTile.X;
_selectedTile.Y = _hoveredTile.Y;
DeleteTile();
break;
case InsertMode.Wall:
DeleteWall();
break;
}
}
foreach (var key in newState.GetPressedKeys())
{
@ -528,51 +494,6 @@ private int scrollvalue=0;
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);
}
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);
}
}
private void SetWall(int wallId)
{
var tileExist = _mapWalls.Any(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
if (tileExist)
{
var wall = _mapWalls.First(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
var index = _mapWalls.IndexOf(wall);
_mapWalls.RemoveAt(index);
_mapWalls.Add(new Wall { X = _selectedWall.X, Y = _selectedWall.Y, ID = wallId, Rotation = _selectedWall.Rotation });
}
else
{
_mapWalls.Add(new Wall { X = _selectedWall.X, Y = _selectedWall.Y, ID = wallId, Rotation = _selectedWall.Rotation });
//connection?.InvokeAsync("SendMessage", $"{_selectedTile.X}:{_selectedTile.Y}", tileId.ToString(), _session);
}
}
protected override void Draw(GameTime gameTime)
{
if (_spriteBatch is null)
@ -583,8 +504,8 @@ private int scrollvalue=0;
// TODO: Add your drawing code here
var visibleTilesX = (int)GraphicsDevice.Viewport.Width / _tileSize + 1;
var visibleTilesY = (int)GraphicsDevice.Viewport.Height / _tileSize + 1;
var visibleTilesX = GraphicsDevice.Viewport.Width / _tileSize + 1;
var visibleTilesY = GraphicsDevice.Viewport.Height / _tileSize + 1;
_spriteBatch.Begin(transformMatrix: Matrix.CreateTranslation(_viewportCenter));
@ -633,32 +554,32 @@ private int scrollvalue=0;
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), ((float)_tileSize - 1) / (float)content.Width, SpriteEffects.None, 0);
null, Color.White, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(content.Width / 2, content.Height / 2), ((float)_tileSize - 1) / content.Width, SpriteEffects.None, 0);
}
foreach (var wall in _mapWalls)
{
var content = Content.Load<Texture2D>($"walls/wall{wall.ID.ToString().PadLeft(2, '0')}");
var scale = (float)_tileSize / (float)content.Height;
var offset = scale * (float)content.Width / 2f;
var scale = _tileSize / (float)content.Height;
var offset = scale * content.Width / 2f;
var posX = wall.X * _tileSize;
var posY = wall.Y * _tileSize;
if (wall.Rotation == 1)
{
posX -= (int)offset;
posX -= (int)offset;
}
else if (wall.Rotation == 0)
{
posY += (int)offset;
posY += (int)offset;
}
// _spriteBatch.Draw(content, new Vector2(posX, posY),null, Color.White, MathHelper.ToRadians(90 * (wall.Rotation - 1)), new Vector2(offset, 0), scale, SpriteEffects.None, 0);
_spriteBatch.Draw(content, new Vector2(posX, posY),null, Color.White, MathHelper.ToRadians(90 * (wall.Rotation - 1)), new Vector2(0, 0), scale, SpriteEffects.None, 0);
// _spriteBatch.Draw(content, new Vector2(posX, posY),null, Color.White, MathHelper.ToRadians(90 * (wall.Rotation - 1)), new Vector2(offset, 0), scale, SpriteEffects.None, 0);
_spriteBatch.Draw(content, new Vector2(posX, posY), null, Color.White, MathHelper.ToRadians(90 * (wall.Rotation - 1)), new Vector2(0, 0), scale, SpriteEffects.None, 0);
}
// _spriteBatch.DrawRectangle(new Rectangle(_selectedTile.X * _tileSize, _selectedTile.Y * _tileSize, _tileSize, _tileSize), Color.Blue, 3);
_spriteBatch.DrawRectangle(new Rectangle(_selectedTile.X * _tileSize, _selectedTile.Y * _tileSize, _tileSize, _tileSize), Color.Blue, 3);
var startWall = new Vector2(_selectedWall.X * _tileSize, _selectedWall.Y * _tileSize);
@ -666,6 +587,13 @@ private int scrollvalue=0;
{
_spriteBatch.DrawLine(startWall, _tileSize, MathHelper.ToRadians(90 * _selectedWall.Rotation), Color.Red, 2);
}
if (_insertMode == InsertMode.Overlay)
{
if (_selectedOverlay.Intersection)
{
_spriteBatch.DrawCircle(startWall, _tileSize / 3, 100, Color.Red, 2);
}
}
_spriteBatch.End();
@ -673,24 +601,149 @@ private int scrollvalue=0;
base.Draw(gameTime);
}
private float Sign(Point p1, Point p2, Point p3)
private void ClearSelection(Grid grid)
{
return (p1.X - p3.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p3.Y);
foreach (var widget in grid.Widgets)
{
widget.Border = null;
}
}
private bool PointInTriangle(Point pt, Point v1, Point v2, Point v3)
private float Sign(Point p1, Point p2, Point p3) { return (p1.X - p3.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p3.Y); }
private bool PointInTri(Point pt, Point v1, Point v2, Point v3)
{
float d1, d2, d3;
bool has_neg, has_pos;
bool b1, b2, b3;
b1 = Sign(pt, v1, v2) < 0.0f;
b2 = Sign(pt, v2, v3) < 0.0f;
b3 = Sign(pt, v3, v1) < 0.0f;
return ((b1 == b2) && (b2 == b3));
}
d1 = Sign(pt, v1, v2);
d2 = Sign(pt, v2, v3);
d3 = Sign(pt, v3, v1);
private void SelectClosestWall(Point mousePosition)
{
var topLeft = new Point(_hoveredTile.X * _tileSize, _hoveredTile.Y * _tileSize);
var bottomLeft = new Point(_hoveredTile.X * _tileSize, _hoveredTile.Y * _tileSize + _tileSize);
var topRight = new Point(_hoveredTile.X * _tileSize + _tileSize, _hoveredTile.Y * _tileSize);
var bottomRight = new Point(_hoveredTile.X * _tileSize + _tileSize, _hoveredTile.Y * _tileSize + _tileSize);
var center = new Point(_hoveredTile.X * _tileSize + _tileSize / 2, _hoveredTile.Y * _tileSize + _tileSize / 2);
var leftWall = PointInTri(mousePosition, topLeft, center, bottomLeft);
var rightWall = PointInTri(mousePosition, topRight, bottomRight, center);
var topWall = PointInTri(mousePosition, topLeft, topRight, center);
var bottomtWall = PointInTri(mousePosition, bottomLeft, center, bottomRight);
has_neg = (d1 < 0) || (d2 < 0) || (d3 < 0);
has_pos = (d1 > 0) || (d2 > 0) || (d3 > 0);
if (leftWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 1;
}
else if (rightWall)
{
_selectedWall.X = _hoveredTile.X + 1;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 1;
}
else if (topWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y;
_selectedWall.Rotation = 0;
}
else if (bottomtWall)
{
_selectedWall.X = _hoveredTile.X;
_selectedWall.Y = _hoveredTile.Y + 1;
_selectedWall.Rotation = 0;
}
}
return !(has_neg && has_pos);
private void SelectOverlay(Point mousePosition)
{
_selectedOverlay.X = _hoveredTile.X;
_selectedOverlay.Y = _hoveredTile.Y;
var q1 = System.Math.Pow(mousePosition.X - _hoveredTile.X * _tileSize, 2);
var q2 = System.Math.Pow((_hoveredTile.Y * _tileSize - mousePosition.Y), 2);
var s = System.Math.Sqrt(q1 + q2);
System.Console.WriteLine(s);
if (s < _tileSize / 3)
{
_selectedOverlay.Intersection = true;
}
else
{
_selectedOverlay.Intersection = false;
}
}
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);
}
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);
}
}
private void DeleteWall()
{
var tileExist = _mapWalls.Any(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
if (tileExist)
{
var wall = _mapWalls.First(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
var index = _mapWalls.IndexOf(wall);
_mapWalls.RemoveAt(index);
//connection?.InvokeAsync("SendMessage", $"{_selectedTile.X}:{_selectedTile.Y}", tileId.ToString(), _session);
}
}
private void DeleteTile()
{
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);
//connection?.InvokeAsync("SendMessage", $"{_selectedTile.X}:{_selectedTile.Y}", tileId.ToString(), _session);
}
}
private void SetWall(int wallId)
{
var tileExist = _mapWalls.Any(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
if (tileExist)
{
var wall = _mapWalls.First(m => m.X == _selectedWall.X && m.Y == _selectedWall.Y && m.Rotation == _selectedWall.Rotation);
var index = _mapWalls.IndexOf(wall);
_mapWalls.RemoveAt(index);
_mapWalls.Add(new Wall { X = _selectedWall.X, Y = _selectedWall.Y, ID = wallId, Rotation = _selectedWall.Rotation });
}
else
{
_mapWalls.Add(new Wall { X = _selectedWall.X, Y = _selectedWall.Y, ID = wallId, Rotation = _selectedWall.Rotation });
//connection?.InvokeAsync("SendMessage", $"{_selectedTile.X}:{_selectedTile.Y}", tileId.ToString(), _session);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Before After
Before After

9
MyGame/InsertMode.cs Normal file
View file

@ -0,0 +1,9 @@
namespace MyGame
{
public enum InsertMode
{
Tile,
Wall,
Overlay
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,67 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"mgfxc/3.8.0.1641": {
"dependencies": {
"CppNet": "1.0.0.0",
"SharpDX.D3DCompiler": "4.0.1.0",
"SharpDX": "4.0.1.0"
},
"runtime": {
"mgfxc.dll": {}
}
},
"CppNet/1.0.0.0": {
"runtime": {
"CppNet.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"SharpDX.D3DCompiler/4.0.1.0": {
"runtime": {
"SharpDX.D3DCompiler.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.0.1.0"
}
}
},
"SharpDX/4.0.1.0": {
"runtime": {
"SharpDX.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.0.1.0"
}
}
}
}
},
"libraries": {
"mgfxc/3.8.0.1641": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"CppNet/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"SharpDX.D3DCompiler/4.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"SharpDX/4.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

View file

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\tom\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\tom\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}

View file

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}

View file

@ -1,67 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"mgfxc/3.8.0.1641": {
"dependencies": {
"CppNet": "1.0.0.0",
"SharpDX.D3DCompiler": "4.0.1.0",
"SharpDX": "4.0.1.0"
},
"runtime": {
"mgfxc.dll": {}
}
},
"CppNet/1.0.0.0": {
"runtime": {
"CppNet.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"SharpDX.D3DCompiler/4.0.1.0": {
"runtime": {
"SharpDX.D3DCompiler.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.0.1.0"
}
}
},
"SharpDX/4.0.1.0": {
"runtime": {
"SharpDX.dll": {
"assemblyVersion": "4.0.1.0",
"fileVersion": "4.0.1.0"
}
}
}
}
},
"libraries": {
"mgfxc/3.8.0.1641": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"CppNet/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"SharpDX.D3DCompiler/4.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"SharpDX/4.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

View file

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\tom\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\tom\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}

View file

@ -1,9 +0,0 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.1.0"
}
}
}

View file

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2007 James Newton-King
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

11
MyGame/Overlay.cs Normal file
View file

@ -0,0 +1,11 @@
namespace MyGame
{
public struct Overlay
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public bool Intersection { get; set; }
public int Rotation { get; set; }
}
}

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>

10
MyGame/Tile.cs Normal file
View file

@ -0,0 +1,10 @@
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; }
}
}

10
MyGame/Wall.cs Normal file
View file

@ -0,0 +1,10 @@
namespace MyGame
{
public struct Wall
{
public int X { get; set; }
public int Y { get; set; }
public int ID { get; set; }
public int Rotation { get; set; }
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyGame"/>
<assemblyIdentity version="1.0.0.0" name="Sledgemapper"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

25
Sledgemapper.sln Normal file
View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30626.31
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sledgemapper", "MyGame\Sledgemapper.csproj", "{3E895B69-EBD7-4FDD-84D0-BEC18FC5D658}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3E895B69-EBD7-4FDD-84D0-BEC18FC5D658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E895B69-EBD7-4FDD-84D0-BEC18FC5D658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E895B69-EBD7-4FDD-84D0-BEC18FC5D658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E895B69-EBD7-4FDD-84D0-BEC18FC5D658}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3897FFF7-DD63-4C55-9047-AFD7573D2208}
EndGlobalSection
EndGlobal