Finished first EA Version #1
+17
-2
@@ -17,6 +17,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://b77mo4fhklnja" path="res://Assets/Images/OptionsSymbol.png" id="12_3so38"]
|
[ext_resource type="Texture2D" uid="uid://b77mo4fhklnja" path="res://Assets/Images/OptionsSymbol.png" id="12_3so38"]
|
||||||
[ext_resource type="Script" uid="uid://drscsrkfphpy7" path="res://Scripts/Research/ResearchList.cs" id="12_4q8tf"]
|
[ext_resource type="Script" uid="uid://drscsrkfphpy7" path="res://Scripts/Research/ResearchList.cs" id="12_4q8tf"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dt84awx33mulb" path="res://Assets/Images/ResearchSymbol.png" id="13_alh3a"]
|
[ext_resource type="Texture2D" uid="uid://dt84awx33mulb" path="res://Assets/Images/ResearchSymbol.png" id="13_alh3a"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bmcpkt6mae2qi" path="res://Assets/Images/AlarmSign.png" id="13_x3xnh"]
|
||||||
|
|
||||||
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_u44n3"]
|
||||||
|
|
||||||
@@ -66,7 +67,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", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu", "inventory", "researchList")]
|
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu", "inventory", "researchList", "robotAlarm")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@@ -89,6 +90,7 @@ uiContent = NodePath("MainUI/Content")
|
|||||||
menu = NodePath("MainUI/Content/Menu")
|
menu = NodePath("MainUI/Content/Menu")
|
||||||
inventory = NodePath("MainUI/Content/Inventory")
|
inventory = NodePath("MainUI/Content/Inventory")
|
||||||
researchList = NodePath("MainUI/Content/Research")
|
researchList = NodePath("MainUI/Content/Research")
|
||||||
|
robotAlarm = NodePath("MainUI/FooterContainer/HBoxContainer/RobotAlarm")
|
||||||
|
|
||||||
[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
|
||||||
@@ -361,7 +363,7 @@ text = "Exit"
|
|||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
||||||
[node name="Inventory" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=407422598 node_paths=PackedStringArray("itemList")]
|
[node name="Inventory" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=407422598 node_paths=PackedStringArray("itemList", "inventorySpace")]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 11
|
anchors_preset = 11
|
||||||
@@ -373,6 +375,7 @@ grow_horizontal = 0
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("11_acvyw")
|
script = ExtResource("11_acvyw")
|
||||||
itemList = NodePath("VBoxContainer/ScrollContainer/VBoxContainer")
|
itemList = NodePath("VBoxContainer/ScrollContainer/VBoxContainer")
|
||||||
|
inventorySpace = NodePath("VBoxContainer/RichTextLabel")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory" unique_id=1776118554]
|
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory" unique_id=1776118554]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -385,6 +388,13 @@ fit_content = true
|
|||||||
autowrap_mode = 0
|
autowrap_mode = 0
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory/VBoxContainer" unique_id=1572448693]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Available Space:"
|
||||||
|
fit_content = true
|
||||||
|
autowrap_mode = 0
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory/VBoxContainer" unique_id=1743833752]
|
[node name="ScrollContainer" type="ScrollContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Inventory/VBoxContainer" unique_id=1743833752]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
@@ -429,6 +439,11 @@ layout_mode = 2
|
|||||||
fit_content = true
|
fit_content = true
|
||||||
autowrap_mode = 0
|
autowrap_mode = 0
|
||||||
|
|
||||||
|
[node name="RobotAlarm" type="TextureRect" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=439539299]
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("13_x3xnh")
|
||||||
|
expand_mode = 2
|
||||||
|
|
||||||
[node name="Inventory" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1598826377]
|
[node name="Inventory" type="TextureButton" parent="CanvasLayer/UIHandler/MainUI/FooterContainer/HBoxContainer" unique_id=1598826377]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Inventory (I)"
|
tooltip_text = "Inventory (I)"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
@@ -6,6 +7,7 @@ public class Inventory
|
|||||||
public List<Item> items = new();
|
public List<Item> items = new();
|
||||||
|
|
||||||
public int maxInventorySize = 8;
|
public int maxInventorySize = 8;
|
||||||
|
public event EventHandler OnInventoryUpdate;
|
||||||
|
|
||||||
public bool AddItem(Item item, int amount)
|
public bool AddItem(Item item, int amount)
|
||||||
{
|
{
|
||||||
@@ -13,6 +15,7 @@ public class Inventory
|
|||||||
if (inventoryItem != null)
|
if (inventoryItem != null)
|
||||||
{
|
{
|
||||||
inventoryItem.currentAmount += amount;
|
inventoryItem.currentAmount += amount;
|
||||||
|
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -21,6 +24,7 @@ public class Inventory
|
|||||||
{
|
{
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
items[items.Count - 1].currentAmount += amount;
|
items[items.Count - 1].currentAmount += amount;
|
||||||
|
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +53,7 @@ public class Inventory
|
|||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
item.currentAmount -= amount;
|
item.currentAmount -= amount;
|
||||||
|
OnInventoryUpdate?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,31 @@
|
|||||||
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
public partial class InventoryDisplay : PanelContainer
|
public partial class InventoryDisplay : PanelContainer
|
||||||
{
|
{
|
||||||
PackedScene itemDisplayPrefab = ResourceLoader.LoadItemDisplay();
|
PackedScene itemDisplayPrefab = ResourceLoader.LoadItemDisplay();
|
||||||
[Export] VBoxContainer itemList;
|
[Export] VBoxContainer itemList;
|
||||||
|
[Export] RichTextLabel inventorySpace;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
GameData.inventory.OnInventoryUpdate += OnInventoryUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
public override void _Notification(int id)
|
public override void _Notification(int id)
|
||||||
{
|
{
|
||||||
if (id == NotificationVisibilityChanged)
|
if (id == NotificationVisibilityChanged)
|
||||||
{
|
{
|
||||||
if (Visible) ReloadItems();
|
if (Visible) ReloadItems();
|
||||||
|
if (Visible) UpdateInventorySpace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateInventorySpace()
|
||||||
|
{
|
||||||
|
inventorySpace.Text = $"Used space: {GameData.inventory.items.Count}/{GameData.inventory.maxInventorySize}";
|
||||||
|
}
|
||||||
|
|
||||||
public void ReloadItems()
|
public void ReloadItems()
|
||||||
{
|
{
|
||||||
foreach (Node node in itemList.GetChildren())
|
foreach (Node node in itemList.GetChildren())
|
||||||
@@ -27,9 +40,15 @@ public partial class InventoryDisplay : PanelContainer
|
|||||||
display = itemDisplayPrefab.Instantiate<ItemDisplay>();
|
display = itemDisplayPrefab.Instantiate<ItemDisplay>();
|
||||||
display.item = item;
|
display.item = item;
|
||||||
display.text.Text = item.data.GetReadableName();
|
display.text.Text = item.data.GetReadableName();
|
||||||
display.amount.Text = item.currentAmount.ToString();
|
display.amount.Text = $"{item.currentAmount}/{item.data.StackSize}";
|
||||||
display.texture.Texture = ResourceLoader.LoadPath(item.data.Texture);
|
display.texture.Texture = ResourceLoader.LoadPath(item.data.Texture);
|
||||||
itemList.AddChild(display);
|
itemList.AddChild(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnInventoryUpdate(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
ReloadItems();
|
||||||
|
UpdateInventorySpace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public partial class UIHandler : Control
|
|||||||
[Export] PanelContainer menu;
|
[Export] PanelContainer menu;
|
||||||
[Export] PanelContainer inventory;
|
[Export] PanelContainer inventory;
|
||||||
[Export] ResearchList researchList;
|
[Export] ResearchList researchList;
|
||||||
|
[Export] TextureRect robotAlarm;
|
||||||
|
|
||||||
bool receivedRobotJumpSignal = false;
|
bool receivedRobotJumpSignal = false;
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -28,6 +29,7 @@ public partial class UIHandler : Control
|
|||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
DisplayStats();
|
DisplayStats();
|
||||||
|
DisplayRobotAlarm();
|
||||||
robotList.OnRobotJumpTo += (robot) =>
|
robotList.OnRobotJumpTo += (robot) =>
|
||||||
{
|
{
|
||||||
if(receivedRobotJumpSignal) return;
|
if(receivedRobotJumpSignal) return;
|
||||||
@@ -113,4 +115,21 @@ public partial class UIHandler : Control
|
|||||||
child.Visible = false;
|
child.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DisplayRobotAlarm()
|
||||||
|
{
|
||||||
|
string messages = "";
|
||||||
|
foreach (Robot robot in GameData.robots)
|
||||||
|
{
|
||||||
|
if(robot.currentMessage.Length > 0)
|
||||||
|
{
|
||||||
|
messages += $"{robot.Name}: {robot.currentMessage}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
robotAlarm.Visible = messages.Length > 0;
|
||||||
|
if (messages.Length >= 0)
|
||||||
|
{
|
||||||
|
robotAlarm.TooltipText = messages;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public partial class Robot : Node3D
|
|||||||
bool isExecuting = false;
|
bool isExecuting = false;
|
||||||
ProgramNode currentNode;
|
ProgramNode currentNode;
|
||||||
public string currentProgram;
|
public string currentProgram;
|
||||||
|
public string currentMessage = "";
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,6 @@ public partial class Robot : Node3D
|
|||||||
switch (currentNode.Execute(this, delta))
|
switch (currentNode.Execute(this, delta))
|
||||||
{
|
{
|
||||||
case NodeResult.SUCCESS:
|
case NodeResult.SUCCESS:
|
||||||
GD.Print(currentNode.lastExecutionMessage);
|
|
||||||
currentNode = currentNode.nextNode;
|
currentNode = currentNode.nextNode;
|
||||||
if (currentNode == null)
|
if (currentNode == null)
|
||||||
{
|
{
|
||||||
@@ -31,13 +31,17 @@ public partial class Robot : Node3D
|
|||||||
break;
|
break;
|
||||||
case NodeResult.FAILURE:
|
case NodeResult.FAILURE:
|
||||||
isExecuting = false;
|
isExecuting = false;
|
||||||
GD.Print(currentNode.lastExecutionMessage);
|
currentMessage = "(FAILED)" + currentNode.lastExecutionMessage;
|
||||||
break;
|
break;
|
||||||
case NodeResult.RUNNING:
|
case NodeResult.RUNNING:
|
||||||
//Currently does nothing.
|
currentMessage = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(currentMessage.Length <= 0)
|
||||||
|
{
|
||||||
|
currentMessage = "No script executing";
|
||||||
|
}
|
||||||
|
|
||||||
Visible = Math.Round(Math.Abs(Position.Y / GameData.tileHeight), 0) == GameData.visibleLayer;
|
Visible = Math.Round(Math.Abs(Position.Y / GameData.tileHeight), 0) == GameData.visibleLayer;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user