Added better grid to the map and reworked camera positioning whilst map is open
This commit is contained in:
@@ -7,34 +7,55 @@ public partial class Map : PanelContainer
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
grid.Columns = GameData.layerSize + 1;
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
//TODO: This has to be temporary! Drawing each frame is way too expensive.
|
||||
if (Visible)
|
||||
{
|
||||
ShowMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ShowMap()
|
||||
{
|
||||
grid.Columns = GameData.layerSize;
|
||||
grid.AddThemeConstantOverride("h_separation", (int)(GameData.tileWidth * 2.5f));
|
||||
grid.AddThemeConstantOverride("v_separation", (int)(GameData.tileWidth * 2.5f));
|
||||
foreach (Node node in grid.GetChildren())
|
||||
{
|
||||
grid.RemoveChild(node);
|
||||
node.QueueFree();
|
||||
}
|
||||
TextureRect texture;
|
||||
Label label;
|
||||
Tile[,] tiles = GameData.map[GameData.currentLayer].tiles;
|
||||
for (int z = 0; z < GameData.layerSize; z++)
|
||||
int size = GameData.layerSize;
|
||||
for (int z = -1; z < size; z++)
|
||||
{
|
||||
for (int x = 0; x < GameData.layerSize; x++)
|
||||
for (int x = -1; x < size; x++)
|
||||
{
|
||||
if (z == -1 || x == -1)
|
||||
{
|
||||
label = new Label
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
|
||||
SizeFlagsHorizontal = SizeFlags.ExpandFill,
|
||||
SizeFlagsVertical = SizeFlags.ExpandFill
|
||||
};
|
||||
if (z == -1 && x == -1)
|
||||
{
|
||||
label.Text = "\u2193 Z | \u2192 X";
|
||||
}
|
||||
else if(z == -1)
|
||||
{
|
||||
label.Text = x.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
label.Text = z.ToString();
|
||||
}
|
||||
grid.AddChild(label);
|
||||
continue;
|
||||
}
|
||||
texture = new TextureRect();
|
||||
if (tiles[x, z].wasVisited)
|
||||
{
|
||||
@@ -44,14 +65,18 @@ public partial class Map : PanelContainer
|
||||
}
|
||||
else
|
||||
{
|
||||
texture.Texture = GenerateTexture(32, new Color(0,0,0,0));
|
||||
texture.Texture = GenerateTexture(32, new Color(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
texture.Texture = GenerateTexture(32, new Color(0,0,0,1));
|
||||
texture.Texture = GenerateTexture(32, new Color(0, 0, 0, 1));
|
||||
}
|
||||
|
||||
texture.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||
texture.SizeFlagsVertical = SizeFlags.ExpandFill;
|
||||
texture.StretchMode = TextureRect.StretchModeEnum.Scale;
|
||||
|
||||
grid.AddChild(texture);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user