Static is fun!
This commit is contained in:
@@ -22,7 +22,6 @@ namespace DepthsBelow
|
||||
public Camera camera;
|
||||
MouseInput mouseInput;
|
||||
public Soldier soldier;
|
||||
public Grid GridChecker;
|
||||
private Map map;
|
||||
|
||||
public Core()
|
||||
@@ -69,8 +68,6 @@ namespace DepthsBelow
|
||||
Soldier.LoadContent(this);
|
||||
soldier = new Soldier(this);
|
||||
|
||||
GridChecker = new Grid();
|
||||
|
||||
mouseInput = new MouseInput(this);
|
||||
mouseInput.LoadContent();
|
||||
}
|
||||
|
||||
@@ -1,33 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DepthsBelow
|
||||
{
|
||||
public class Grid
|
||||
public static class Grid
|
||||
{
|
||||
public const int TilePixelSize = 32;
|
||||
public int TileSize() { return TilePixelSize; }
|
||||
/*public Vector2 GridToScreen(Vector2 gridPos);
|
||||
public Vector2 ScreenToGrid(Vector2 screenPos);*/
|
||||
public const int TileSize = 32;
|
||||
|
||||
public Vector2 GridToScreen;
|
||||
public Vector2 ScreenToGrid;
|
||||
|
||||
public Grid()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Vector2 FindScreenPos(Vector2 gridPos)
|
||||
{
|
||||
return gridPos * TileSize();
|
||||
}
|
||||
public Vector2 FindGridPos(Vector2 screenPos)
|
||||
{
|
||||
return screenPos / TileSize();
|
||||
}
|
||||
public static Vector2 GridToScreen(Vector2 gridPos)
|
||||
{
|
||||
return gridPos * TileSize;
|
||||
}
|
||||
public static Vector2 ScreenToGrid(Vector2 screenPos)
|
||||
{
|
||||
return screenPos / TileSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,12 @@ namespace DepthsBelow
|
||||
|
||||
selectionRectangle = Rectangle.Empty;
|
||||
}
|
||||
Vector2 currentGrid = core.GridChecker.FindGridPos(new Vector2(ms.X + core.camera.Position.X - core.GridChecker.TileSize() / 2, ms.Y + core.camera.Position.Y - core.GridChecker.TileSize() / 2));
|
||||
|
||||
Vector2 currentGrid = Grid.ScreenToGrid(new Vector2(ms.X + core.camera.Position.X - Grid.TileSize / 2, ms.Y + core.camera.Position.Y - Grid.TileSize / 2));
|
||||
currentGrid.X = Convert.ToInt32(currentGrid.X);
|
||||
currentGrid.Y = Convert.ToInt32(currentGrid.Y);
|
||||
Vector2 currentScreen = core.GridChecker.FindScreenPos(currentGrid);
|
||||
gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, core.GridChecker.TileSize(), core.GridChecker.TileSize());
|
||||
Vector2 currentScreen = Grid.GridToScreen(currentGrid);
|
||||
gridRectangle = new Rectangle((int)currentScreen.X, (int)currentScreen.Y, Grid.TileSize, Grid.TileSize;
|
||||
|
||||
lastMouseState = ms;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user