mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 04:55:54 +00:00
Update Weapon in status
This commit is contained in:
parent
8f9e4f0bb9
commit
83d3cc7835
10 changed files with 45 additions and 15 deletions
|
|
@ -1,6 +1,5 @@
|
|||
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cfq121rs3bsu8"]
|
||||
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cfq121rs3bsu8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://pemr2lrv3ylk" path="res://Scenes/HUD/Items/ying_yang_gun_huditem.tscn" id="1_i6xgq"]
|
||||
[ext_resource type="Resource" uid="uid://ckppo2seg313h" path="res://Resources/Weapons/Cheat_Gun.tres" id="2_0na1t"]
|
||||
[ext_resource type="Texture2D" uid="uid://cwy7g861vnbj1" path="res://Sprites/Items/Cheat_Gun.png" id="2_0vddk"]
|
||||
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="3_i0e51"]
|
||||
|
|
@ -8,6 +7,7 @@
|
|||
[resource]
|
||||
script = ExtResource("3_i0e51")
|
||||
ItemName = &"Cheat Gun"
|
||||
ShortName = &"CHAET"
|
||||
ItemDescription = &"Does massive damage"
|
||||
ItemKey = &"CHEAT_GUN"
|
||||
Item = 9
|
||||
|
|
@ -19,5 +19,4 @@ ConsumeOnUse = false
|
|||
UiType = 1
|
||||
Selectable = true
|
||||
InventorySprite = ExtResource("2_0vddk")
|
||||
HudItemScene = ExtResource("1_i6xgq")
|
||||
DropScenePath = &"res://Scenes/Items/Cheat_Gun_Pickup.tscn"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://dau0s8ob7qnpc"]
|
||||
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://dau0s8ob7qnpc"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bqb3gbnrkqewt" path="res://Scenes/HUD/Items/ice_shotgun_huditem.tscn" id="1_13ven"]
|
||||
[ext_resource type="Resource" uid="uid://cyntngidhcbkc" path="res://Resources/Weapons/Ice_Shotgun_Weapon.tres" id="2_3le6e"]
|
||||
[ext_resource type="Texture2D" uid="uid://b46usr10jhmev" path="res://Sprites/Items/Ice_Shotgun.png" id="2_4ibag"]
|
||||
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="3_cjfxs"]
|
||||
|
|
@ -8,6 +7,7 @@
|
|||
[resource]
|
||||
script = ExtResource("3_cjfxs")
|
||||
ItemName = &"Ice Shotgun"
|
||||
ShortName = &"IC-27"
|
||||
ItemDescription = &"Shoots ice pellets in a wide spread"
|
||||
ItemKey = &"ICE_SHOTGUN"
|
||||
Item = 9
|
||||
|
|
@ -19,5 +19,4 @@ ConsumeOnUse = false
|
|||
UiType = 1
|
||||
Selectable = true
|
||||
InventorySprite = ExtResource("2_4ibag")
|
||||
HudItemScene = ExtResource("1_13ven")
|
||||
DropScenePath = &"res://Scenes/Items/Ice_Shotgun_Pickup.tscn"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cs3ihltcn2166"]
|
||||
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cs3ihltcn2166"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="1_itajb"]
|
||||
[ext_resource type="PackedScene" uid="uid://cicthr1v5v4s2" path="res://Scenes/HUD/Items/icicle_gun.tscn" id="1_lfbsh"]
|
||||
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="2_eaoas"]
|
||||
[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_hy2hk"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_hy2hk")
|
||||
ItemName = &"Icicle Gun"
|
||||
ShortName = &"IC-9"
|
||||
ItemDescription = &"Cirno\'s custom gun, shoots ice pellets and never runs out of ammo"
|
||||
ItemKey = &"ICICLE_GUN"
|
||||
Item = 9
|
||||
|
|
@ -19,5 +19,4 @@ ConsumeOnUse = false
|
|||
UiType = 1
|
||||
Selectable = true
|
||||
InventorySprite = ExtResource("2_eaoas")
|
||||
HudItemScene = ExtResource("1_lfbsh")
|
||||
DropScenePath = "res://Scenes/Items/IcicleGun.tscn"
|
||||
DropScenePath = null
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[resource]
|
||||
script = ExtResource("4_k6in2")
|
||||
ItemName = &"Icicle Repeater"
|
||||
ShortName = &"IC-18"
|
||||
ItemDescription = &"Shoots ice pellets at a high rate"
|
||||
ItemKey = &"ICICLE_REPEATER"
|
||||
Item = 9
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[resource]
|
||||
script = ExtResource("4_imbrn")
|
||||
ItemName = &"Nuclear Gun (MP-42)"
|
||||
ShortName = &"MP-42"
|
||||
ItemDescription = &"Shoots micro suns"
|
||||
ItemKey = &"NUCLEAR_GUN"
|
||||
Item = 9
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
[resource]
|
||||
script = ExtResource("2_2w24o")
|
||||
ItemName = &"Yin-Yang Gun"
|
||||
ShortName = &"SM-3"
|
||||
ItemDescription = &"A weapon that shoots explosive Yin-Yang Orbs"
|
||||
ItemKey = &"YINYANG_GUN"
|
||||
Item = 9
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ 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_paths=PackedStringArray("HealthExpansionCounter", "ShieldExpansionCounter")]
|
||||
[node name="Status" type="PanelContainer" parent="InventoryMenu" node_paths=PackedStringArray("HealthExpansionCounter", "ShieldExpansionCounter", "WeaponButton")]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("9_sx5r0")
|
||||
theme_override_styles/panel = ExtResource("13_sjdna")
|
||||
|
|
@ -288,6 +288,7 @@ HealthExpansionName = &"HEALTH_EXTEND"
|
|||
ShieldExpansionName = &"SHIELD_EXTEND"
|
||||
HealthExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/HealthExtensions")
|
||||
ShieldExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/ShieldExtensions")
|
||||
WeaponButton = NodePath("MarginContainer/HBoxContainer/VBoxContainer2/EquippedWeapon")
|
||||
metadata/_tab_index = 4
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="InventoryMenu/Status"]
|
||||
|
|
@ -304,7 +305,7 @@ layout_mode = 2
|
|||
size_flags_horizontal = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Button" type="Button" parent="InventoryMenu/Status/MarginContainer/HBoxContainer/VBoxContainer2"]
|
||||
[node name="EquippedWeapon" type="Button" parent="InventoryMenu/Status/MarginContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "IC-9
|
||||
"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
|
@ -8,4 +9,9 @@ public partial class ItemsDatabase : Resource
|
|||
{
|
||||
[Export]
|
||||
public Array<LootItem> LootItems { get; set; } = new();
|
||||
|
||||
public LootItem GetLootItem(string itemName)
|
||||
{
|
||||
return LootItems.FirstOrDefault(x => x.ItemKey == itemName);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ namespace Cirno.Scripts.Resources;
|
|||
public partial class LootItem : Resource
|
||||
{
|
||||
[Export] public StringName ItemName { get; set; }
|
||||
[Export] public StringName ShortName { get; set; }
|
||||
[Export] public StringName ItemDescription { get; set; }
|
||||
[Export] public StringName ItemKey { get; set; }
|
||||
[Export] public ItemTypes Item;
|
||||
|
|
@ -19,8 +20,8 @@ public partial class LootItem : Resource
|
|||
[Export] public UiItemType UiType;
|
||||
[Export] public bool Selectable;
|
||||
[Export] public Texture2D InventorySprite;
|
||||
[Export] public SpriteFrames WorldSprite;
|
||||
[Export] public PackedScene HudItemScene;
|
||||
//[Export] public SpriteFrames WorldSprite;
|
||||
//[Export] public PackedScene HudItemScene;
|
||||
[Export(PropertyHint.File)] public StringName DropScenePath { get; private set; } // Has to be a string path to avoid recursion issues
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class StatusMenu : PanelContainer
|
||||
|
|
@ -7,11 +8,15 @@ public partial class StatusMenu : PanelContainer
|
|||
[Export] public StringName HealthExpansionName { get; private set; }
|
||||
|
||||
[Export] public StringName ShieldExpansionName { get; private set; }
|
||||
|
||||
//[Export] public ItemsDatabase ItemsDatabase { get; private set; }
|
||||
|
||||
[Export] public Button HealthExpansionCounter { get; private set; }
|
||||
|
||||
[Export] public Button ShieldExpansionCounter { get; private set; }
|
||||
|
||||
[Export] public Button WeaponButton { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CallDeferred(MethodName.InitializeDeferred);
|
||||
|
|
@ -31,6 +36,23 @@ public partial class StatusMenu : PanelContainer
|
|||
ShieldExpansionCounter.Text = $"x{shieldExpansions}";
|
||||
|
||||
InventoryManager.Instance.ItemAdded += InstanceOnItemAdded;
|
||||
|
||||
InventoryManager.Instance.WeaponEquip += InstanceOnWeaponEquip;
|
||||
}
|
||||
|
||||
private void InstanceOnWeaponEquip(string itemKey)
|
||||
{
|
||||
//var weaponData = ItemsDatabase.GetLootItem(itemKey);
|
||||
|
||||
var succ = InventoryManager.Instance.TryGetItem(itemKey, out var item);
|
||||
if (!succ)
|
||||
{
|
||||
GD.Print($"Could not get item {itemKey}");
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponButton.Text = item.Item.ShortName;
|
||||
WeaponButton.Icon = item.Item.InventorySprite;
|
||||
}
|
||||
|
||||
private void InstanceOnItemAdded(LootItem item, int currentamount)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue