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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cxmr7ph6rmjii"
path="res://.godot/imported/CopperSymbol.png-af3bb022d337b2ee8d6321cb118fa961.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/CopperSymbol.png"
dest_files=["res://.godot/imported/CopperSymbol.png-af3bb022d337b2ee8d6321cb118fa961.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bfyo2pyq4l6fb"
path="res://.godot/imported/IronSymbol.png-b6bd85ad5ac27632d080a1fd3593a79b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/IronSymbol.png"
dest_files=["res://.godot/imported/IronSymbol.png-b6bd85ad5ac27632d080a1fd3593a79b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://uunnuou4g86w"
path="res://.godot/imported/MushroomSymbol.png-ccfc4e3446560281c0108d77581d75f8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/MushroomSymbol.png"
dest_files=["res://.godot/imported/MushroomSymbol.png-ccfc4e3446560281c0108d77581d75f8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cdpbu73lo0pvp"
path="res://.godot/imported/SpiderwebSymbol.png-8572f6b9f7ee6361afbd8999d8ff052d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/SpiderwebSymbol.png"
dest_files=["res://.godot/imported/SpiderwebSymbol.png-8572f6b9f7ee6361afbd8999d8ff052d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://141sj37rysng"
path="res://.godot/imported/TinSymbol.png-808770deada4fdfd3ee3dba8989dfec9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/TinSymbol.png"
dest_files=["res://.godot/imported/TinSymbol.png-808770deada4fdfd3ee3dba8989dfec9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+25 -1
View File
@@ -8,6 +8,7 @@
[ext_resource type="Script" uid="uid://bsd6n6b06a4pe" path="res://Scripts/DSL/CodingWindow.cs" id="6_7lihs"] [ext_resource type="Script" uid="uid://bsd6n6b06a4pe" path="res://Scripts/DSL/CodingWindow.cs" id="6_7lihs"]
[ext_resource type="Script" uid="uid://k6vlo7ulvtep" path="res://Scripts/Robot/RobotList.cs" id="7_2irst"] [ext_resource type="Script" uid="uid://k6vlo7ulvtep" path="res://Scripts/Robot/RobotList.cs" id="7_2irst"]
[ext_resource type="Script" uid="uid://c3v2vdj3ghp78" path="res://Scripts/Information.cs" id="7_fgofq"] [ext_resource type="Script" uid="uid://c3v2vdj3ghp78" path="res://Scripts/Information.cs" id="7_fgofq"]
[ext_resource type="Script" uid="uid://fegfbcnlk8p5" path="res://Scripts/WorldGeneration/Map.cs" id="8_bf53h"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"] [sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
@@ -54,7 +55,7 @@ environment = SubResource("Environment_sb48q")
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386] [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
follow_viewport_enabled = true follow_viewport_enabled = true
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "information", "mainCam")] [node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "information", "mainCam", "map")]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -70,6 +71,7 @@ codingWindow = NodePath("MainUI/Content/CodingWindow")
robotList = NodePath("MainUI/Content/RobotList") robotList = NodePath("MainUI/Content/RobotList")
information = NodePath("Popup/Information") information = NodePath("Popup/Information")
mainCam = NodePath("../../Camera3D") mainCam = NodePath("../../Camera3D")
map = NodePath("MainUI/Content/Map")
[node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209] [node name="MainUI" type="VBoxContainer" parent="CanvasLayer/UIHandler" unique_id=1437975209]
layout_mode = 1 layout_mode = 1
@@ -279,6 +281,28 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/separation = 10 theme_override_constants/separation = 10
[node name="Map" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=292881873 node_paths=PackedStringArray("grid")]
visible = false
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_bf53h")
grid = NodePath("GridContainer")
[node name="GridContainer" type="GridContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Map" unique_id=218955579]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="FooterContainer" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI" unique_id=1495029884] [node name="FooterContainer" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI" unique_id=1495029884]
layout_mode = 2 layout_mode = 2
+20 -2
View File
@@ -1,3 +1,4 @@
using System;
using Godot; using Godot;
using static GameData; using static GameData;
@@ -7,14 +8,31 @@ public partial class Camera3d : Camera3D
[Export] public float MouseSensitivity = 0.2f; [Export] public float MouseSensitivity = 0.2f;
[Export] public float ScrollStrength = 5.0f; [Export] public float ScrollStrength = 5.0f;
private bool isShowingMap = false;
private Vector3 previousPosition;
private Vector2 _mouseDelta; private Vector2 _mouseDelta;
public override void _Process(double delta) public override void _Process(double delta)
{ {
if (canMove) MoveCamera(delta); if (canMove) MoveCamera(delta);
if (Input.IsActionJustPressed("map"))
{
isShowingMap = !isShowingMap;
canMove = !isShowingMap;
if (isShowingMap)
{
previousPosition = Position;
Position = new Vector3(layerSize * tileWidth / 2 - tileWidth / 2, 90 - visibleLayer * 4, layerSize * tileWidth / 2 - tileWidth / 2);
RotationDegrees = new Vector3(-90, 0, 0);
}
else
{
Position = previousPosition;
RotationDegrees = new Vector3(-75, 0, 0);
}
if (!canMove) return; }
} }
public void MoveCamera(double delta) public void MoveCamera(double delta)
+2
View File
@@ -22,6 +22,8 @@ public class MoveNode : ProgramNode
if (distance < 0.1f) if (distance < 0.1f)
{ {
robot.Position = pathPoints[0]; robot.Position = pathPoints[0];
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z].wasVisited = true;
pathPoints.Remove(pathPoints[0]); pathPoints.Remove(pathPoints[0]);
if (pathPoints.Count <= 0) if (pathPoints.Count <= 0)
{ {
+13
View File
@@ -56,4 +56,17 @@ public partial class ResourceLoader
}; };
return nodes; return nodes;
} }
public static Dictionary<string, Texture2D> LoadResourceSymbols()
{
Dictionary<string, Texture2D> symbols = new()
{
{ "Iron ore", GD.Load<Texture2D>($"res://Assets/IronSymbol.png") },
{ "Tin ore", GD.Load<Texture2D>($"res://Assets/TinSymbol.png") },
{ "Copper ore", GD.Load<Texture2D>($"res://Assets/CopperSymbol.png") },
{ "Mushroom", GD.Load<Texture2D>($"res://Assets/MushroomSymbol.png") },
{ "Spiderweb", GD.Load<Texture2D>($"res://Assets/SpiderwebSymbol.png") },
};
return symbols;
}
} }
+10
View File
@@ -8,6 +8,7 @@ public partial class UIHandler : Control
[Export] RobotList robotList; [Export] RobotList robotList;
[Export] Information information; [Export] Information information;
[Export] Camera3D mainCam; [Export] Camera3D mainCam;
[Export] Map map;
public override void _Ready() public override void _Ready()
{ {
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor; GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
@@ -21,6 +22,15 @@ public partial class UIHandler : Control
mainCam.Position = new Vector3(robot.Position.X, mainCam.Position.Y, robot.Position.Z + 3f); mainCam.Position = new Vector3(robot.Position.X, mainCam.Position.Y, robot.Position.Z + 3f);
ShowCodingWindow(robot); ShowCodingWindow(robot);
}; };
if (Input.IsActionJustPressed("map"))
{
map.Visible = !map.Visible;
if (map.Visible)
{
map.ShowMap();
}
}
} }
public void ChangeColor(Color color) public void ChangeColor(Color color)
+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);
}
}
+1
View File
@@ -0,0 +1 @@
uid://fegfbcnlk8p5
+3 -11
View File
@@ -4,22 +4,14 @@ using Godot;
public class ResourceDistributor public class ResourceDistributor
{ {
public static List<string> resourceNames = new() public static Dictionary<string, Texture2D> resources = ResourceLoader.LoadResourceSymbols();
{
"Iron ore",
"Stone",
"Copper ore",
"Spiderweb",
"Mushroom",
"Tin ore"
};
public static string GetResource(List<string> current) public static string GetResource(List<string> current)
{ {
List<string> diff = resourceNames.Except(current).ToList(); List<string> diff = resources.Keys.Except(current).ToList();
if (diff.Count <= 0) if (diff.Count <= 0)
{ {
return resourceNames[GameData.rand.Next(resourceNames.Count)]; return resources.Keys.ToList()[GameData.rand.Next(resources.Keys.Count)];
} }
else else
{ {
+1
View File
@@ -13,6 +13,7 @@ public partial class Tile
public bool containsLight, containsDecoration, containsResource; public bool containsLight, containsDecoration, containsResource;
public GameResource resource; public GameResource resource;
public bool wasVisited;
public void SetMeshes(Dictionary<string, MeshInstance3D> tileMeshes) public void SetMeshes(Dictionary<string, MeshInstance3D> tileMeshes)
+5 -10
View File
@@ -77,21 +77,16 @@ spawn_robot={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
] ]
} }
codingwindow={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null)
]
}
left_click={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(394, 15),"global_position":Vector2(403, 63),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
robot_list={ robot_list={
"deadzone": 0.2, "deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
] ]
} }
map={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null)
]
}
[layer_names] [layer_names]