Throwable item rework, increase health on timer timeout, add boss 1 model

This commit is contained in:
2024-09-22 23:05:33 -07:00
parent f490a390aa
commit 59390c04bf
44 changed files with 3373 additions and 101 deletions

View File

@@ -32,8 +32,6 @@ public interface IInventory : INode
event Inventory.InventoryAtCapacityEventHandler InventoryAtCapacity;
event Inventory.AccessoryUnequippedEventHandler AccessoryUnequipped;
event Inventory.RaiseStatRequestEventHandler RaiseStatRequest;
}
public partial class Inventory : Node, IInventory

View File

@@ -14,5 +14,15 @@ public partial class InventoryItemStats : Resource
[Export(PropertyHint.Range, "0, 1, 0.01")]
public float SpawnRate { get; set; } = 0.5f;
public float ThrowSpeed { get; set; } = 7.0f;
[Export(PropertyHint.Range, "0, 25, 0.1")]
public float ThrowSpeed { get; set; } = 12.0f;
[Export(PropertyHint.Range, "0, 999, 1")]
public int HealHPAmount { get; set; }
[Export(PropertyHint.Range, "0, 999, 1")]
public int HealVTAmount { get; set; }
[Export(PropertyHint.Range, "0, 999, 1")]
public int ThrowDamage { get; set; } = 5;
}

View File

@@ -9,6 +9,9 @@ public partial class ConsumableItem : Node3D, IUsableItem
{
public override void _Notification(int what) => this.Notify(what);
[Signal]
public delegate void RaiseStatRequestEventHandler(ConsumableItemStats consumableItemStats);
[Dependency] public IGame Game => this.DependOn<IGame>();
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
@@ -26,17 +29,15 @@ public partial class ConsumableItem : Node3D, IUsableItem
public void Use()
{
GameEventDepot.OnHealingItemConsumed(ConsumableItemInfo);
}
if (ConsumableItemInfo.RaiseHPAmount > 0)
Game.RaiseHP(ConsumableItemInfo.RaiseHPAmount);
if (ConsumableItemInfo.RaiseVTAmount > 0)
Game.RaiseVT(ConsumableItemInfo.RaiseVTAmount);
public void Throw()
{
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
var throwable = throwableScene.Instantiate<ThrownItem>();
throwable.ThrownItemStats = ConsumableItemInfo;
Game.AddChild(throwable);
throwable.Throw();
GameRepo.PlayerData.Inventory.Remove(this);
if (ConsumableItemInfo.HealHPAmount > 0)
Game.HealHP(ConsumableItemInfo.HealHPAmount);
if (ConsumableItemInfo.HealVTAmount > 0)
Game.HealVT(ConsumableItemInfo.HealVTAmount);
}
public void OnReady()

View File

@@ -5,15 +5,9 @@ namespace GameJamDungeon;
[GlobalClass]
public partial class ConsumableItemStats : InventoryItemStats
{
[Export]
public int HealHPAmount { get; set; } = 0;
[Export]
public int RaiseHPAmount { get; set; } = 0;
[Export]
public int HealVTAmount { get; set; } = 0;
[Export]
public int RaiseVTAmount { get; set; } = 0;
}

View File

@@ -5,7 +5,7 @@ using Godot;
using System;
[Meta(typeof(IAutoNode))]
public partial class ThrowableItem : Node3D, IInventoryItem
public partial class ThrowableItem : Node3D, IUsableItem
{
public override void _Notification(int what) => this.Notify(what);
@@ -32,6 +32,14 @@ public partial class ThrowableItem : Node3D, IInventoryItem
Pickup.BodyEntered += OnEntered;
}
public void Use()
{
if (ThrowableItemInfo.HealHPAmount > 0)
Game.HealHP(ThrowableItemInfo.HealHPAmount);
if (ThrowableItemInfo.HealVTAmount > 0)
Game.HealVT(ThrowableItemInfo.HealVTAmount);
}
public void OnEntered(Node3D body)
{
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(this);

View File

@@ -5,9 +5,6 @@ namespace GameJamDungeon;
[GlobalClass]
public partial class ThrowableItemStats : InventoryItemStats
{
[Export]
public int Damage { get; set; } = 0;
[Export]
public Godot.Collections.Array<ThrowableItemTag> ThrowableItemTags { get; set; } = new Godot.Collections.Array<ThrowableItemTag>();
}

View File

@@ -5,13 +5,27 @@
InflictHydricDamage,
InflictIgneousDamage,
InflictFerrumDamage,
LowerTargetTo1HP,
}
public enum UsableItemTag
{
DoubleEXP,
RandomWarp,
LowerTargetTo1HP,
IdentifyAllItemsCostHP,
BriefImmunity,
WarpToExitIfFound,
RandomNewItem,
BasicItem,
}
public enum EnhancingItemTag
{
Add1ATK,
Add1DEF,
RaiseLevelBy1,
}
public enum EffectorItemTag
{
SwapHPandVTWithEntitiesInRoom,
TeleportAllEnemiesToRoom,
TurnAllEnemiesIntoHealingItem,
@@ -19,8 +33,9 @@
AbsorbHPFromAllEnemiesInRoom,
HealsAllInRoomToMaxHP,
RandomEffect,
Add1ATK,
Add1DEF,
RaiseLevelBy1,
BriefImmunity
}
public enum BoxItemTag
{
RandomNewItem,
}

View File

@@ -5,9 +5,12 @@
[resource]
script = ExtResource("1_ewck5")
Damage = 0
ThrowableItemTags = []
Name = "Geomantic Dice"
Description = "Inflicts Affinity damage when thrown."
Texture = ExtResource("1_jhits")
SpawnRate = 0.1
ThrowSpeed = 20.0
HealHPAmount = 0
HealVTAmount = 0
ThrowDamage = 20

View File

@@ -17,7 +17,7 @@ public partial class ThrownItem : RigidBody3D
public void OnResolved()
{
BodyEntered += ThrownItem_BodyEntered;
GlobalPosition = Game.Player.GlobalPosition + new Vector3(0, 1f, 0);
GlobalPosition = Game.Player.GlobalPosition + new Vector3(0, 1.5f, 0);
Sprite.Texture = ThrownItemStats.Texture;
AddCollisionExceptionWith((Node)Game.Player);
}
@@ -26,39 +26,26 @@ public partial class ThrownItem : RigidBody3D
{
if (body is IEnemy enemy)
{
if (ThrownItemStats is ThrowableItemStats throwableItemStats)
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(throwableItemStats.Damage));
CalculateEffect(enemy);
}
QueueFree();
}
public void Throw()
{
ThrowInternal((dynamic)ThrownItemStats);
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * ThrownItemStats.ThrowSpeed);
}
private void ThrowInternal(WeaponStats weaponStats)
private void CalculateEffect(IEnemy enemy)
{
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 12.0f);
}
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(ThrownItemStats.ThrowDamage));
private void ThrowInternal(ArmorStats armorStats)
{
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 12.0f);
}
if (ThrownItemStats is ThrowableItemStats throwableItemStats)
{
if (throwableItemStats.ThrowableItemTags.Contains(ThrowableItemTag.LowerTargetTo1HP))
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(enemy.CurrentHP.Value - 1));
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(DamageCalculator.CalculateThrownItemDamage(throwableItemStats.ThrowDamage, enemy.EnemyStatResource, throwableItemStats)));
private void ThrowInternal(AccessoryStats accessoryStats)
{
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 12.0f);
}
private void ThrowInternal(ConsumableItemStats consumableItemStats)
{
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 12.0f);
}
private void ThrowInternal(ThrowableItemStats throwableItemStats)
{
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 20.0f);
}
}
}

View File

@@ -4,7 +4,7 @@
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_alcjn"]
[sub_resource type="BoxShape3D" id="BoxShape3D_s4ym5"]
size = Vector3(0.884321, 0.999205, 1.52861)
size = Vector3(0.46632, 0.507293, 0.586082)
[node name="Hitbox" type="RigidBody3D"]
collision_layer = 16
@@ -15,7 +15,7 @@ max_contacts_reported = 50
script = ExtResource("1_wlplc")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0347672, 0.152068, 0.118644)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.129255, 0.162556, 0.00695503)
shape = SubResource("BoxShape3D_s4ym5")
[node name="Sprite" type="Sprite3D" parent="."]