Added basic symbols for most of the resources and changed map to be revealed whilst robots are exploring.

This commit is contained in:
=
2026-04-29 19:19:13 +02:00
parent c54ff3088e
commit 95455597da
25 changed files with 350 additions and 24 deletions
+70
View File
@@ -0,0 +1,70 @@
using Godot;
using System;
public partial class Map : PanelContainer
{
[Export] GridContainer grid;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// 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;
Tile[,] tiles = GameData.map[GameData.currentLayer].tiles;
for (int z = 0; z < GameData.layerSize; z++)
{
for (int x = 0; x < GameData.layerSize; x++)
{
texture = new TextureRect();
if (tiles[x, z].wasVisited)
{
if (tiles[x, z].containsResource)
{
texture.Texture = ResourceDistributor.resources[tiles[x, z].resource.name];
}
else
{
texture.Texture = GenerateTexture(32, new Color(0,0,0,0));
}
}
else
{
texture.Texture = GenerateTexture(32, new Color(0,0,0,1));
}
grid.AddChild(texture);
}
}
}
public Texture2D GenerateTexture(int size, Color fillColor)
{
Image image = Image.CreateEmpty(size, size, false, Image.Format.Rgba8);
image.Fill(fillColor);
return ImageTexture.CreateFromImage(image);
}
}