Throw item
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace GameJamDungeon
|
||||
@@ -15,9 +14,4 @@ namespace GameJamDungeon
|
||||
{
|
||||
public void Use();
|
||||
}
|
||||
|
||||
public interface IThrowableItem : IInventoryItem
|
||||
{
|
||||
public void Throw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Godot;
|
||||
using System;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Accessory : Node3D, IEquipableItem, IThrowableItem
|
||||
public partial class Accessory : Node3D, IEquipableItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Godot;
|
||||
using System;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Armor : Node3D, IEquipableItem, IThrowableItem
|
||||
public partial class Armor : Node3D, IEquipableItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Godot;
|
||||
using System;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ConsumableItem : Node3D, IUsableItem, IThrowableItem
|
||||
public partial class ConsumableItem : Node3D, IUsableItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Godot;
|
||||
using System;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ThrowableItem : Node3D, IThrowableItem
|
||||
public partial class ThrowableItem : Node3D, IInventoryItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
@@ -32,16 +32,6 @@ public partial class ThrowableItem : Node3D, IThrowableItem
|
||||
Pickup.BodyEntered += OnEntered;
|
||||
}
|
||||
|
||||
public void Throw()
|
||||
{
|
||||
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
|
||||
var throwable = throwableScene.Instantiate<ThrownItem>();
|
||||
throwable.ThrownItemStats = ThrowableItemInfo;
|
||||
Game.AddChild(throwable);
|
||||
throwable.Throw();
|
||||
GameRepo.PlayerData.Inventory.Remove(this);
|
||||
}
|
||||
|
||||
public void OnEntered(Node3D body)
|
||||
{
|
||||
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(this);
|
||||
|
||||
@@ -17,7 +17,7 @@ public partial class ThrownItem : RigidBody3D
|
||||
public void OnResolved()
|
||||
{
|
||||
BodyEntered += ThrownItem_BodyEntered;
|
||||
GlobalPosition = Game.Player.GlobalPosition + Vector3.Up;
|
||||
GlobalPosition = Game.Player.GlobalPosition + new Vector3(0, 1.5f, 0);
|
||||
Sprite.Texture = ThrownItemStats.Texture;
|
||||
AddCollisionExceptionWith((Node)Game.Player);
|
||||
}
|
||||
|
||||
@@ -4,19 +4,18 @@
|
||||
[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.288967, 0.302734, 0.28064)
|
||||
size = Vector3(1.43084, 1.23022, 1.52861)
|
||||
|
||||
[node name="Hitbox" type="RigidBody3D"]
|
||||
collision_layer = 17
|
||||
collision_mask = 16
|
||||
mass = 0.001
|
||||
gravity_scale = 0.0
|
||||
gravity_scale = 0.25
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 1
|
||||
script = ExtResource("1_wlplc")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00739601, 0.0986328, 0.137878)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0274667, 0.116821, 0.118644)
|
||||
shape = SubResource("BoxShape3D_s4ym5")
|
||||
|
||||
[node name="Sprite" type="Sprite3D" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user