mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 19:05:54 +00:00
Extensions count in inventory
This commit is contained in:
parent
08a3f9acd1
commit
8f9e4f0bb9
6 changed files with 61 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=34 format=3 uid="uid://dkwi1hu1bixoe"]
|
||||
[gd_scene load_steps=35 format=3 uid="uid://dkwi1hu1bixoe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://baf6pxbvhqmjk" path="res://Scripts/Hud.cs" id="1_m0hb0"]
|
||||
[ext_resource type="PackedScene" uid="uid://cd3ee1adstcrw" path="res://Scenes/HUD/HudItemContainer.tscn" id="2_mattb"]
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="19_h6xwv"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8fr1ea20odaw" path="res://Sprites/Items/Heart_Extend.png" id="19_j6myr"]
|
||||
[ext_resource type="Texture2D" uid="uid://cid62phhew3ep" path="res://Sprites/UI/StatusSprite02.png" id="19_n0pka"]
|
||||
[ext_resource type="Script" uid="uid://bv1fkn7qiyyr1" path="res://Scripts/UI/StatusMenu.cs" id="20_qo5e4"]
|
||||
[ext_resource type="Texture2D" uid="uid://8n23xie4kore" path="res://Sprites/Items/Shield_Pickup.png" id="22_5cvcb"]
|
||||
[ext_resource type="Texture2D" uid="uid://cvc0x4bbnhusw" path="res://Sprites/Items/Ice_Crystal_Shield.png" id="22_jefn6"]
|
||||
|
||||
|
|
@ -219,7 +220,6 @@ offset_right = 226.0
|
|||
offset_bottom = 144.0
|
||||
|
||||
[node name="InventoryMenu" type="TabContainer" parent="."]
|
||||
visible = false
|
||||
offset_left = 16.0
|
||||
offset_top = 9.0
|
||||
offset_right = 305.0
|
||||
|
|
@ -279,10 +279,15 @@ script = ExtResource("10_oflr6")
|
|||
ItemsFilter = Array[int]([0, 1, 2, 13, 10, 11, 12])
|
||||
metadata/_tab_index = 3
|
||||
|
||||
[node name="Status" type="PanelContainer" parent="InventoryMenu"]
|
||||
[node name="Status" type="PanelContainer" parent="InventoryMenu" node_paths=PackedStringArray("HealthExpansionCounter", "ShieldExpansionCounter")]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("9_sx5r0")
|
||||
theme_override_styles/panel = ExtResource("13_sjdna")
|
||||
script = ExtResource("20_qo5e4")
|
||||
HealthExpansionName = &"HEALTH_EXTEND"
|
||||
ShieldExpansionName = &"SHIELD_EXTEND"
|
||||
HealthExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/HealthExtensions")
|
||||
ShieldExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/ShieldExtensions")
|
||||
metadata/_tab_index = 4
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="InventoryMenu/Status"]
|
||||
|
|
|
|||
|
|
@ -404,9 +404,8 @@ Targets = [NodePath("../VerticalDoor")]
|
|||
[node name="VerticalDoor2" parent="Tilemaps/Actors" instance=ExtResource("20_qudbj")]
|
||||
position = Vector2(28, 520)
|
||||
|
||||
[node name="Camera" parent="Tilemaps/Actors" node_paths=PackedStringArray("AlarmActivationTargets") instance=ExtResource("17_s23f3")]
|
||||
[node name="Camera" parent="Tilemaps/Actors" instance=ExtResource("17_s23f3")]
|
||||
position = Vector2(135, 459)
|
||||
AlarmActivationTargets = []
|
||||
|
||||
[node name="ControlPad2" parent="Tilemaps/Actors" node_paths=PackedStringArray("Targets") instance=ExtResource("24_fdi4d")]
|
||||
position = Vector2(40, 518)
|
||||
|
|
@ -558,13 +557,11 @@ position = Vector2(-103, 505)
|
|||
[node name="Fairy5" parent="Tilemaps/Actors" instance=ExtResource("37_sb7g3")]
|
||||
position = Vector2(287, 515)
|
||||
|
||||
[node name="Camera2" parent="Tilemaps/Actors" node_paths=PackedStringArray("AlarmActivationTargets") instance=ExtResource("17_s23f3")]
|
||||
[node name="Camera2" parent="Tilemaps/Actors" instance=ExtResource("17_s23f3")]
|
||||
position = Vector2(-56, 251)
|
||||
AlarmActivationTargets = []
|
||||
|
||||
[node name="Camera3" parent="Tilemaps/Actors" node_paths=PackedStringArray("AlarmActivationTargets") instance=ExtResource("17_s23f3")]
|
||||
[node name="Camera3" parent="Tilemaps/Actors" instance=ExtResource("17_s23f3")]
|
||||
position = Vector2(-121, 476)
|
||||
AlarmActivationTargets = []
|
||||
|
||||
[node name="VerticalDoor3" parent="Tilemaps/Actors" instance=ExtResource("20_qudbj")]
|
||||
position = Vector2(-324, 696)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
[sub_resource type="Resource" id="Resource_6wo78"]
|
||||
script = ExtResource("4_w0rax")
|
||||
EggIndex = 0
|
||||
StartingEquipment = Array[ExtResource("3_w0rax")]([])
|
||||
StartingEquipment = []
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tvyok"]
|
||||
size = Vector2(52, 64)
|
||||
|
|
|
|||
|
|
@ -1082,7 +1082,7 @@ position = Vector2(-2000, -736)
|
|||
[node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
|
||||
position = Vector2(-2027, -735)
|
||||
Targets = [NodePath("../HorizontalForceField")]
|
||||
Requirements = [ExtResource("84_ma1ta")]
|
||||
Requirements = Array[ExtResource("6_8tdlb")]([ExtResource("84_ma1ta")])
|
||||
|
||||
[node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")]
|
||||
position = Vector2(-872, -220)
|
||||
|
|
|
|||
47
Scripts/UI/StatusMenu.cs
Normal file
47
Scripts/UI/StatusMenu.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class StatusMenu : PanelContainer
|
||||
{
|
||||
[Export] public StringName HealthExpansionName { get; private set; }
|
||||
|
||||
[Export] public StringName ShieldExpansionName { get; private set; }
|
||||
|
||||
[Export] public Button HealthExpansionCounter { get; private set; }
|
||||
|
||||
[Export] public Button ShieldExpansionCounter { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CallDeferred(MethodName.InitializeDeferred);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
InventoryManager.Instance.ItemAdded -= InstanceOnItemAdded;
|
||||
}
|
||||
|
||||
private void InitializeDeferred()
|
||||
{
|
||||
var healthExpansions = InventoryManager.Instance.GetItemCount(HealthExpansionName);
|
||||
var shieldExpansions = InventoryManager.Instance.GetItemCount(ShieldExpansionName);
|
||||
|
||||
HealthExpansionCounter.Text = $"x{healthExpansions}";
|
||||
ShieldExpansionCounter.Text = $"x{shieldExpansions}";
|
||||
|
||||
InventoryManager.Instance.ItemAdded += InstanceOnItemAdded;
|
||||
}
|
||||
|
||||
private void InstanceOnItemAdded(LootItem item, int currentamount)
|
||||
{
|
||||
if (item.ItemKey == HealthExpansionName)
|
||||
{
|
||||
HealthExpansionCounter.Text = $"x{currentamount}";
|
||||
}
|
||||
else if (item.ItemKey == ShieldExpansionName)
|
||||
{
|
||||
ShieldExpansionCounter.Text = $"x{currentamount}";
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/UI/StatusMenu.cs.uid
Normal file
1
Scripts/UI/StatusMenu.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bv1fkn7qiyyr1
|
||||
Loading…
Add table
Add a link
Reference in a new issue