Rework game over logic and game initialization
This commit is contained in:
@@ -7,7 +7,7 @@ using Zennysoft.Ma.Adapter.Entity;
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ThrownItem : RigidBody3D
|
||||
public partial class ThrownItem : RigidBody3D, IThrownItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
@@ -15,9 +15,10 @@ public partial class ThrownItem : RigidBody3D
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
public InventoryItem ItemThatIsThrown;
|
||||
public InventoryItem ItemThatIsThrown { get; set; }
|
||||
|
||||
private EffectService _effectService;
|
||||
private ItemReroller _itemReroller;
|
||||
|
||||
[Node] public Sprite2D Sprite { get; set; } = default!;
|
||||
|
||||
@@ -31,7 +32,7 @@ public partial class ThrownItem : RigidBody3D
|
||||
Sprite.Texture = ItemThatIsThrown.GetTexture();
|
||||
AddCollisionExceptionWith((Node)Player);
|
||||
Collision.SetCollisionLayerValue(3, false);
|
||||
|
||||
_itemReroller = new ItemReroller(ItemDatabase.Instance);
|
||||
}
|
||||
|
||||
private void Collision_AreaEntered(Area3D area)
|
||||
@@ -102,14 +103,14 @@ public partial class ThrownItem : RigidBody3D
|
||||
private void CalculateEffect(IEnemy enemy)
|
||||
{
|
||||
if (ItemThatIsThrown.ItemTag == ItemTag.MysteryItem)
|
||||
ItemThatIsThrown = Game.RerollItem(ItemThatIsThrown, false);
|
||||
ItemThatIsThrown = _itemReroller.RerollItem(ItemThatIsThrown, Player.Inventory, false);
|
||||
|
||||
if (ItemThatIsThrown is ThrowableItem throwableItem)
|
||||
{
|
||||
switch (throwableItem.ThrowableItemTag)
|
||||
{
|
||||
case ThrowableItemTag.LowerTargetTo1HP:
|
||||
enemy.HealthComponent.SetHealth(1);
|
||||
enemy.HealthComponent.SetCurrentHealth(1);
|
||||
break;
|
||||
case ThrowableItemTag.TeleportToRandomLocation:
|
||||
_effectService.TeleportToRandomRoom(enemy);
|
||||
|
||||
Reference in New Issue
Block a user