Box item implementation
This commit is contained in:
@@ -4,5 +4,21 @@ public enum ItemTag
|
||||
{
|
||||
None,
|
||||
BreaksOnChange,
|
||||
MysteryItem
|
||||
MysteryItem,
|
||||
DamagesPlayer,
|
||||
ContainsRestorative,
|
||||
ContainsWeapon,
|
||||
ContainsArmor,
|
||||
ContainsBox,
|
||||
RandomSpell,
|
||||
ContainsAccessory,
|
||||
DropTo1HPAndGainRareItem,
|
||||
TradeOneRandomItem,
|
||||
TradeAllRandomItems,
|
||||
ContainsUnobtainedItem,
|
||||
ContainsBasicItem,
|
||||
RestrictUnequip,
|
||||
UnequipAllItems,
|
||||
EjectAllItems,
|
||||
UseAllItems
|
||||
}
|
||||
@@ -44,6 +44,8 @@ public interface IPlayer : IKillable, ICharacterBody3D
|
||||
|
||||
public void SetHealthTimerStatus(bool isActive);
|
||||
|
||||
public bool CanEquipState { get; set; }
|
||||
|
||||
public event Action PlayerDied;
|
||||
public delegate InventoryItem RerollItem(InventoryItem item);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ public partial class Game : Node3D, IGame
|
||||
public QuestData QuestData { get; private set; }
|
||||
|
||||
private EffectService _effectService;
|
||||
private ItemReroller _itemReroller;
|
||||
|
||||
private IInstantiator _instantiator;
|
||||
private IPlayer _player;
|
||||
@@ -88,7 +87,6 @@ public partial class Game : Node3D, IGame
|
||||
QuestData = new QuestData();
|
||||
RescuedItems = new RescuedItemDatabase();
|
||||
ItemDatabase = ItemDatabase.Instance;
|
||||
_itemReroller = new ItemReroller(ItemDatabase);
|
||||
|
||||
GameChunk = new SaveChunk<GameData>(
|
||||
(chunk) =>
|
||||
@@ -212,10 +210,13 @@ public partial class Game : Node3D, IGame
|
||||
public async Task UseItem(InventoryItem item)
|
||||
{
|
||||
if (item.ItemTag == ItemTag.MysteryItem)
|
||||
item = _itemReroller.RerollItem(item, _player.Inventory);
|
||||
_effectService.RerollItem(item);
|
||||
|
||||
switch (item)
|
||||
{
|
||||
case BoxItem boxItem:
|
||||
EnactBoxItemEffects(boxItem);
|
||||
break;
|
||||
case ConsumableItem consumableItem:
|
||||
EnactConsumableItemEffects(consumableItem);
|
||||
break;
|
||||
@@ -428,6 +429,16 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded);
|
||||
|
||||
private void EnactBoxItemEffects(BoxItem boxItem)
|
||||
{
|
||||
switch (boxItem.ItemTag)
|
||||
{
|
||||
case ItemTag.DamagesPlayer:
|
||||
_effectService.DamagesPlayer(boxItem.Stats.DamageToPlayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnactConsumableItemEffects(ConsumableItem consumableItem)
|
||||
{
|
||||
if (_player.HealthComponent.AtFullHealth && consumableItem.RaiseHPAmount > 0)
|
||||
@@ -519,7 +530,7 @@ public partial class Game : Node3D, IGame
|
||||
_effectService.ChangeAffinity(throwableItem);
|
||||
break;
|
||||
case ThrowableItemTag.WarpToExitIfFound:
|
||||
_effectService.WarpToExit(_player);
|
||||
_effectService.WarpToExit();
|
||||
GameRepo.CloseInventory();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -226,13 +226,90 @@ public class EffectService
|
||||
throwableItem.SetCount(throwableItem.Count + 1);
|
||||
}
|
||||
|
||||
public void WarpToExit(IPlayer player)
|
||||
public void WarpToExit()
|
||||
{
|
||||
var exitRoom = _game.CurrentFloor.Rooms.OfType<ExitRoom>().Single();
|
||||
if (exitRoom.PlayerDiscoveredRoom)
|
||||
{
|
||||
SfxDatabase.Instance.Play(SoundEffect.TeleportToExit);
|
||||
player.TeleportPlayer((exitRoom.PlayerSpawn.Rotation, exitRoom.PlayerSpawn.Position));
|
||||
_player.TeleportPlayer((exitRoom.PlayerSpawn.Rotation, exitRoom.PlayerSpawn.Position));
|
||||
}
|
||||
}
|
||||
|
||||
public void DamagesPlayer(int damage)
|
||||
{
|
||||
_player.TakeDamage(new AttackData(damage, ElementType.None, true, true));
|
||||
}
|
||||
|
||||
public void RerollItem(InventoryItem itemToReroll)
|
||||
{
|
||||
var itemReroller = new ItemReroller(ItemDatabase.Instance);
|
||||
itemReroller.RerollItem(itemToReroll, _player.Inventory);
|
||||
}
|
||||
|
||||
public void GetRandomItemOfType<T>(T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
_player.Inventory.TryAdd(ItemDatabase.Instance.PickItem(itemToExclude));
|
||||
}
|
||||
|
||||
public void RandomSpell()
|
||||
{
|
||||
throw new NotImplementedException("Spells not implemented yet.");
|
||||
}
|
||||
|
||||
public void DropTo1HPAndGainRareItem<T>()
|
||||
where T : InventoryItem
|
||||
{
|
||||
_player.HealthComponent.SetCurrentHealth(1);
|
||||
_player.Inventory.TryAdd(ItemDatabase.Instance.PickRareItem<T>());
|
||||
}
|
||||
|
||||
public void TradeRandomItem(BoxItem box)
|
||||
{
|
||||
if (_player.Inventory.Items.Count == 1)
|
||||
return;
|
||||
|
||||
var tradableItems = _player.Inventory.Items.Where(x => x != box).ToList();
|
||||
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var randomIndex = rng.RandiRange(0, _player.Inventory.Items.Count - 1);
|
||||
var randomItem = tradableItems[randomIndex];
|
||||
if (randomItem is EquipableItem equipableItem)
|
||||
{
|
||||
if (_player.EquipmentComponent.IsItemEquipped(equipableItem))
|
||||
_player.Unequip(equipableItem);
|
||||
}
|
||||
_player.Inventory.Remove(randomItem);
|
||||
|
||||
GetRandomItemOfType<InventoryItem>(box);
|
||||
}
|
||||
|
||||
public void TradeAllRandomItems(BoxItem box)
|
||||
{
|
||||
var tradableItems = _player.Inventory.Items.Where(x => x != box);
|
||||
foreach (var item in tradableItems)
|
||||
TradeRandomItem(box);
|
||||
}
|
||||
|
||||
public void GetUnobtainedItem()
|
||||
{
|
||||
var pickableItems = ItemDatabase.Instance.Items.Except(_player.Inventory.Items).ToList();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var randomIndex = rng.RandiRange(0, pickableItems.Count - 1);
|
||||
var selectedItem = pickableItems[randomIndex];
|
||||
|
||||
if (selectedItem is ThrowableItem throwableItem)
|
||||
throwableItem.SetCount(rng.RandiRange(throwableItem.Stats.MinimumCount, throwableItem.Stats.MaximumCount));
|
||||
|
||||
_player.Inventory.TryAdd(selectedItem);
|
||||
}
|
||||
|
||||
public void GetBasicItem<T>()
|
||||
where T : InventoryItem
|
||||
{
|
||||
_player.Inventory.TryAdd(ItemDatabase.Instance.PickBasicItem<T>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,31 @@ public class ItemDatabase
|
||||
|
||||
public T PickItem<T>(T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
var itemsToSelectFrom = Items;
|
||||
return PickItemInternal(itemsToSelectFrom, itemToExclude);
|
||||
}
|
||||
|
||||
public T PickRareItem<T>(T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
var getRareItems = Items.Where(x => x.SpawnRate < 0.1f);
|
||||
return PickItemInternal(getRareItems, itemToExclude);
|
||||
}
|
||||
|
||||
public T PickBasicItem<T>(T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
var getBasicItems = Items.Where(x => x.SpawnRate > 0.5f);
|
||||
return PickItemInternal(getBasicItems, itemToExclude);
|
||||
}
|
||||
|
||||
private T PickItemInternal<T>(IEnumerable<InventoryItem> itemsToSelectFrom, T itemToExclude = null)
|
||||
where T : InventoryItem
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
|
||||
var itemsToSelectFrom = Items;
|
||||
|
||||
if (itemToExclude is not null)
|
||||
itemsToSelectFrom = [.. itemsToSelectFrom.OfType<T>().Where(x => x.ItemName != itemToExclude.ItemName)];
|
||||
|
||||
|
||||
@@ -27,6 +27,21 @@ public class ItemReroller
|
||||
return rolledItem;
|
||||
}
|
||||
|
||||
public InventoryItem RerollItemToAny(InventoryItem itemToReroll, IInventory inventory, bool insertIntoInventory = true)
|
||||
{
|
||||
var currentIndex = inventory.Items.IndexOf(itemToReroll);
|
||||
|
||||
if (insertIntoInventory)
|
||||
inventory.Remove(itemToReroll);
|
||||
|
||||
var rolledItem = _database.PickItem(itemToReroll);
|
||||
|
||||
if (insertIntoInventory)
|
||||
inventory.TryInsert(rolledItem, currentIndex);
|
||||
|
||||
return rolledItem;
|
||||
}
|
||||
|
||||
private Weapon RerollItemInternal(Weapon itemToReroll) => _database.PickItem(itemToReroll);
|
||||
private Armor RerollItemInternal(Armor itemToReroll) => _database.PickItem(itemToReroll);
|
||||
private Accessory RerollItemInternal(Accessory itemToReroll) => _database.PickItem(itemToReroll);
|
||||
|
||||
12
Zennysoft.Game.Ma/src/items/accessory/BoxItemStats.cs
Normal file
12
Zennysoft.Game.Ma/src/items/accessory/BoxItemStats.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[GlobalClass]
|
||||
[Meta, Id("box_item_stat_type")]
|
||||
public partial class BoxItemStats : InventoryItemStats
|
||||
{
|
||||
[Export]
|
||||
public int DamageToPlayer { get; set; } = 10;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://vuavr681au06
|
||||
@@ -4,12 +4,12 @@ importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://dkpgrhj14phdd"
|
||||
path="res://.godot/imported/plastique.glb-38f4438846eaa3d64b225272714c5d02.scn"
|
||||
path="res://.godot/imported/plastique.glb-5845ad959844e1ca0c9791ff0287bc66.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/items/assetts/plastique.glb"
|
||||
dest_files=["res://.godot/imported/plastique.glb-38f4438846eaa3d64b225272714c5d02.scn"]
|
||||
source_file="res://src/items/assets/plastique.glb"
|
||||
dest_files=["res://.godot/imported/plastique.glb-5845ad959844e1ca0c9791ff0287bc66.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
@@ -3,7 +3,7 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dkqs4x4pi18on"
|
||||
path="res://.godot/imported/plastique_plastique.png-3ad121f0468f0ec1d61934d8a0e41cb7.ctex"
|
||||
path="res://.godot/imported/plastique_plastique.png-06bcea5737da44088a0bd794735523f0.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -13,8 +13,8 @@ generator_parameters={
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/items/assetts/plastique_plastique.png"
|
||||
dest_files=["res://.godot/imported/plastique_plastique.png-3ad121f0468f0ec1d61934d8a0e41cb7.ctex"]
|
||||
source_file="res://src/items/assets/plastique_plastique.png"
|
||||
dest_files=["res://.godot/imported/plastique_plastique.png-06bcea5737da44088a0bd794735523f0.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
37
Zennysoft.Game.Ma/src/items/box/BoxItem.cs
Normal file
37
Zennysoft.Game.Ma/src/items/box/BoxItem.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
[Meta(typeof(IAutoNode)), Id("box_item")]
|
||||
public partial class BoxItem : InventoryItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] private Sprite3D _sprite { get; set; }
|
||||
|
||||
[Export]
|
||||
[Save("box_stats")]
|
||||
public BoxItemStats Stats { get; set; } = new BoxItemStats();
|
||||
|
||||
public override string ItemName => Stats.Name;
|
||||
|
||||
public override string Description => Stats.Description;
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
public override ItemTag ItemTag => Stats.ItemTag;
|
||||
|
||||
public override Texture2D GetTexture() => Stats.Texture;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
_sprite.Texture = Stats.Texture;
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/items/box/BoxItem.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/items/box/BoxItem.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cqqqj4hgywst4
|
||||
40
Zennysoft.Game.Ma/src/items/box/BoxItem.tscn
Normal file
40
Zennysoft.Game.Ma/src/items/box/BoxItem.tscn
Normal file
@@ -0,0 +1,40 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bdygmhgk4k0qh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqqqj4hgywst4" path="res://src/items/box/BoxItem.cs" id="1_holk0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bg47n2tmintm0" path="res://src/items/consumable/textures/past self remnant.PNG" id="2_holk0"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_x6u08"]
|
||||
height = 0.725098
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1ceef"]
|
||||
radius = 0.470016
|
||||
|
||||
[node name="Box Item" type="RigidBody3D"]
|
||||
collision_layer = 0
|
||||
axis_lock_linear_x = true
|
||||
axis_lock_linear_z = true
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
script = ExtResource("1_holk0")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00908482, 0)
|
||||
shape = SubResource("CylinderShape3D_x6u08")
|
||||
|
||||
[node name="Pickup" type="Area3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
|
||||
[node name="Sprite" type="Sprite3D" parent="Pickup"]
|
||||
unique_name_in_owner = true
|
||||
pixel_size = 0.0025
|
||||
billboard = 2
|
||||
shaded = true
|
||||
texture_filter = 0
|
||||
render_priority = 100
|
||||
texture = ExtResource("2_holk0")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
|
||||
shape = SubResource("CapsuleShape3D_1ceef")
|
||||
25
Zennysoft.Game.Ma/src/items/box/resources/EmptyPromise.tres
Normal file
25
Zennysoft.Game.Ma/src/items/box/resources/EmptyPromise.tres
Normal file
@@ -0,0 +1,25 @@
|
||||
[gd_resource type="Resource" script_class="BoxItemStats" load_steps=3 format=3 uid="uid://cgkorwblwr12t"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bg47n2tmintm0" path="res://src/items/consumable/textures/past self remnant.PNG" id="1_650jj"]
|
||||
[ext_resource type="Script" uid="uid://vuavr681au06" path="res://src/items/accessory/BoxItemStats.cs" id="1_i336w"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_i336w")
|
||||
Name = "Empty Promise"
|
||||
Description = "An empty box."
|
||||
SpawnRate = 0.5
|
||||
BonusAttack = 0
|
||||
BonusDefense = 0
|
||||
BonusLuck = 0.05
|
||||
BonusHP = 0
|
||||
BonusVT = 0
|
||||
AeolicResistance = 0
|
||||
TelluricResistance = 0
|
||||
HydricResistance = 0
|
||||
IgneousResistance = 0
|
||||
FerrumResistance = 0
|
||||
ThrowSpeed = 12.0
|
||||
ThrowDamage = 5
|
||||
ItemTag = 0
|
||||
Texture = ExtResource("1_650jj")
|
||||
metadata/_custom_type_script = "uid://vuavr681au06"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://da8mhruqpgh6r" path="res://src/items/misc/SetItem.cs" id="1_m8dyi"]
|
||||
[ext_resource type="AudioStream" uid="uid://bjcersd5id8ee" path="res://src/audio/sfx/ITEM_PLASTIQUETIMER.ogg" id="2_kgxna"]
|
||||
[ext_resource type="Texture2D" uid="uid://dkqs4x4pi18on" path="res://src/items/assetts/plastique_plastique.png" id="2_m8dyi"]
|
||||
[ext_resource type="Texture2D" uid="uid://dkqs4x4pi18on" path="res://src/items/assets/plastique_plastique.png" id="2_m8dyi"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_eat5q"]
|
||||
length = 0.001
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using System;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
|
||||
room.SpawnEnemies(enemyOdds);
|
||||
}
|
||||
|
||||
public (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (_playerSpawnPoint.Rotation, new Vector3(_playerSpawnPoint.GlobalPosition.X, -2.5f, _playerSpawnPoint.GlobalPosition.Z)); }
|
||||
public (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (_playerSpawnPoint.Rotation, new Vector3(_playerSpawnPoint.GlobalPosition.X, 0, _playerSpawnPoint.GlobalPosition.Z)); }
|
||||
|
||||
|
||||
private Marker3D RandomizePlayerSpawnPoint()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://dl6h1djc27ddl"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://dl6h1djc27ddl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c1nhqlem1ew3m" path="res://src/map/dungeon/code/Altar.cs" id="1_5jip8"]
|
||||
[ext_resource type="Resource" uid="uid://bqnfw6r4085yv" path="res://src/dialog/Altar.dialogue" id="2_7xfp0"]
|
||||
[ext_resource type="PackedScene" uid="uid://co0fmuno2pjc7" path="res://src/map/dungeon/models/Special Floors & Rooms/Altar/02_ALTAR_FLOOR_ZER0_VER.1.glb" id="2_xpi6o"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdygmhgk4k0qh" path="res://src/items/box/BoxItem.tscn" id="6_rrmfo"]
|
||||
[ext_resource type="Shader" uid="uid://c4a68uhm5o2h4" path="res://src/map/map shaders/Altar Sky Environment.gdshader" id="27_lb4gb"]
|
||||
[ext_resource type="AudioStream" uid="uid://c4ud110da8efp" path="res://src/audio/AMB/amb_wind_loop_altar.wav" id="28_je2oh"]
|
||||
|
||||
@@ -212,3 +213,5 @@ collision_mask = 64
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="NoExitArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 72.5243, -2.06593, -2.02953)
|
||||
shape = SubResource("BoxShape3D_tp2pi")
|
||||
|
||||
[node name="Box Item" parent="." instance=ExtResource("6_rrmfo")]
|
||||
|
||||
@@ -94,6 +94,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
#endregion
|
||||
|
||||
public bool CanEquipState { get; set; } = true;
|
||||
|
||||
private bool flipAttack = false;
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [&"normal_slash"]
|
||||
"values": [&"Unarmed"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
@@ -417,7 +417,7 @@ tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [&"normal_slash"]
|
||||
"values": [&"Normal Slash 1"]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
@@ -12253,7 +12253,7 @@ position = Vector2(764, 544)
|
||||
position = Vector2(720, 580)
|
||||
scale = Vector2(2.25, 2.25)
|
||||
sprite_frames = SubResource("SpriteFrames_jtmj1")
|
||||
animation = &"normal_slash"
|
||||
animation = &"Unarmed"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="ScreenFX/SubViewportContainer/SubViewport"]
|
||||
anchors_preset = 15
|
||||
|
||||
@@ -63,6 +63,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
public override void _EnterTree()
|
||||
{
|
||||
SetProcessInput(false);
|
||||
SetProcessUnhandledInput(false);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -102,13 +103,10 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (!Visible)
|
||||
return;
|
||||
|
||||
if ((!Input.IsActionJustPressed(GameInputs.UiUp) && Input.IsActionPressed(GameInputs.UiUp)) || (!Input.IsActionJustPressed(GameInputs.UiDown) && Input.IsActionPressed(GameInputs.UiDown)))
|
||||
AcceptEvent();
|
||||
|
||||
if (Input.IsActionJustPressed(GameInputs.UiCancel) && (UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus()))
|
||||
if (Input.IsActionJustPressed(GameInputs.UiCancel) && (UseItemPrompt.Visible))
|
||||
{
|
||||
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
|
||||
AcceptEvent();
|
||||
@@ -141,12 +139,14 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
{
|
||||
if (Visible)
|
||||
{
|
||||
SetProcessUnhandledInput(true);
|
||||
SfxDatabase.Instance.Play(SoundEffect.OpenInventory);
|
||||
_currentlySelectedItem.GrabFocus();
|
||||
_enableMenuSound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetProcessUnhandledInput(false);
|
||||
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
|
||||
_enableMenuSound = false;
|
||||
}
|
||||
@@ -272,6 +272,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
ThrowButton.FocusMode = isItemEquipped ? FocusModeEnum.None : FocusModeEnum.All;
|
||||
DropButton.Disabled = isItemEquipped;
|
||||
DropButton.FocusMode = isItemEquipped ? FocusModeEnum.None : FocusModeEnum.All;
|
||||
|
||||
UseButton.GrabFocus();
|
||||
|
||||
if (!_player.CanEquipState && isItemEquipped)
|
||||
UseButton.Disabled = true;
|
||||
}
|
||||
else if (item is Plastique plastique)
|
||||
{
|
||||
@@ -281,8 +286,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
{
|
||||
UseButton.Text = "Use";
|
||||
}
|
||||
|
||||
UseButton.GrabFocus();
|
||||
_enableMenuSound = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public partial class PauseDebugMenu : Control, IDebugMenu
|
||||
{
|
||||
var enemyToSpawn = _spawnableEnemies.ElementAt((int)index);
|
||||
var loadedEnemy = GD.Load<PackedScene>(enemyToSpawn).Instantiate<Enemy>();
|
||||
AddChild(loadedEnemy);
|
||||
_game.AddChild(loadedEnemy);
|
||||
loadedEnemy.GlobalPosition = new Vector3(_player.GlobalPosition.X, _player.GlobalPosition.Y + 1, _player.GlobalPosition.Z) + (-_player.GlobalBasis.Z * 2);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public partial class PauseDebugMenu : Control, IDebugMenu
|
||||
{
|
||||
var itemToSpawn = _spawnableItems.ElementAt((int)index);
|
||||
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
AddChild(duplicated);
|
||||
_game.AddChild(duplicated);
|
||||
duplicated.GlobalPosition = new Vector3(_player.GlobalPosition.X, _player.GlobalPosition.Y + 1, _player.GlobalPosition.Z) + (-_player.GlobalBasis.Z * 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user