diff --git a/Characters/Character.cs b/Characters/Character.cs index 192b9ab..da78557 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -255,7 +255,7 @@ public partial class Character : CharacterBody2D, IFaction } } - public void UseCurrentItemAlt() + public virtual void UseCurrentItemAlt() { if (StunTime > 0 || !IsAlive) { diff --git a/Characters/Player.cs b/Characters/Player.cs index fb23a51..9ad698a 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -79,7 +79,6 @@ public sealed partial class Player : Character deltaTheta, 1); _targetTracer.Intensity = Mathf.Max(_targetTracer.Intensity - Mathf.Pi / 4 * (float)delta, 0); - GD.Print(_targetTracer.Intensity); } public override void _Input(InputEvent @event) @@ -152,6 +151,22 @@ public sealed partial class Player : Character .Play(); } + public override void UseCurrentItemAlt() + { + // must have at least 1 level to use + if (Stats.Level.Value >= 1) + { + if (Inventory.SelectedItem is Items.Weapon weapon) + { + if (!weapon.IsUsingAlt) + { + Stats.Level.Value--; + } + } + base.UseCurrentItemAlt(); + } + } + public Vector2 GetDesiredInputFromInput() { Vector2 mousePos = GetGlobalMousePosition(); diff --git a/Items/Weapon.cs b/Items/Weapon.cs index ea4475c..1af5812 100644 --- a/Items/Weapon.cs +++ b/Items/Weapon.cs @@ -14,6 +14,9 @@ public abstract partial class Weapon : Item public virtual bool IsUsingAlt => false; + [Signal] + public delegate void UsedItemAltEventHandler(Weapon weapon); + /// /// How much damage in HP that this weapon deals. /// diff --git a/Items/Weapons/Pugio.tscn b/Items/Weapons/Pugio.tscn index af7653b..a1dc974 100644 --- a/Items/Weapons/Pugio.tscn +++ b/Items/Weapons/Pugio.tscn @@ -49,66 +49,52 @@ tracks/1/keys = { "update": 1, "values": [0] } -tracks/2/type = "method" +tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath(".") +tracks/2/path = NodePath("SwingSprite:modulate") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), -"values": [{ -"args": ["is_alternate", false], -"method": &"SetAnimationCondition" -}] +"update": 0, +"values": [Color(2, 2, 2, 1)] } tracks/3/type = "value" tracks/3/imported = false tracks/3/enabled = true -tracks/3/path = NodePath("SwingSprite:modulate") +tracks/3/path = NodePath("Anchor/Node2D/Sprite2D:visible") tracks/3/interp = 1 tracks/3/loop_wrap = true tracks/3/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(2, 2, 2, 1)] +"update": 1, +"values": [false] } tracks/4/type = "value" tracks/4/imported = false tracks/4/enabled = true -tracks/4/path = NodePath("Anchor/Node2D/Sprite2D:visible") +tracks/4/path = NodePath("Shield:scale") tracks/4/interp = 1 tracks/4/loop_wrap = true tracks/4/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), -"update": 1, -"values": [false] +"update": 0, +"values": [Vector2(1, 1)] } tracks/5/type = "value" tracks/5/imported = false tracks/5/enabled = true -tracks/5/path = NodePath("Shield:scale") +tracks/5/path = NodePath("Shield:material:shader_parameter/intensity") tracks/5/interp = 1 tracks/5/loop_wrap = true tracks/5/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Vector2(1, 1)] -} -tracks/6/type = "value" -tracks/6/imported = false -tracks/6/enabled = true -tracks/6/path = NodePath("Shield:material:shader_parameter/intensity") -tracks/6/interp = 1 -tracks/6/loop_wrap = true -tracks/6/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, "values": [0.0] } @@ -202,21 +188,10 @@ tracks/1/keys = { tracks/2/type = "method" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath(".") +tracks/2/path = NodePath("SwingSound") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { -"times": PackedFloat32Array(), -"transitions": PackedFloat32Array(), -"values": [] -} -tracks/3/type = "method" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("SwingSound") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { "times": PackedFloat32Array(0.1), "transitions": PackedFloat32Array(1), "values": [{ @@ -224,13 +199,13 @@ tracks/3/keys = { "method": &"play" }] } -tracks/4/type = "value" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath("Anchor/Node2D/Sprite2D:visible") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Anchor/Node2D/Sprite2D:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { "times": PackedFloat32Array(0, 0.35), "transitions": PackedFloat32Array(1, 1), "update": 1, @@ -288,20 +263,6 @@ tracks/3/keys = { "update": 1, "values": [3.14159, 0.785398] } -tracks/4/type = "method" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0.2), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": ["is_alternate", false], -"method": &"SetAnimationCondition" -}] -} [sub_resource type="Animation" id="Animation_x1aou"] resource_name = "block" diff --git a/Items/Weapons/Sword.tscn b/Items/Weapons/Sword.tscn index 3da3286..7a398c1 100644 --- a/Items/Weapons/Sword.tscn +++ b/Items/Weapons/Sword.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=37 format=3 uid="uid://dvqap2uhcah63"] +[gd_scene load_steps=25 format=3 uid="uid://dvqap2uhcah63"] [ext_resource type="Script" path="res://Items/Weapons/Sword.cs" id="1_mlo73"] [ext_resource type="Script" path="res://State/Weapon/WeaponStateMachine.cs" id="2_vwirq"] @@ -78,29 +78,15 @@ tracks/3/keys = { "update": 1, "values": [0.0, 0.0, 0.0] } -tracks/4/type = "method" +tracks/4/type = "value" tracks/4/imported = false tracks/4/enabled = true -tracks/4/path = NodePath(".") +tracks/4/path = NodePath("SwingSprite:modulate") tracks/4/interp = 1 tracks/4/loop_wrap = true tracks/4/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), -"values": [{ -"args": ["is_alternate", false], -"method": &"SetAnimationCondition" -}] -} -tracks/5/type = "value" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("SwingSprite:modulate") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), "update": 0, "values": [Color(2, 2, 2, 1)] } @@ -206,21 +192,10 @@ tracks/3/keys = { tracks/4/type = "method" tracks/4/imported = false tracks/4/enabled = true -tracks/4/path = NodePath(".") +tracks/4/path = NodePath("SwingSound") tracks/4/interp = 1 tracks/4/loop_wrap = true tracks/4/keys = { -"times": PackedFloat32Array(), -"transitions": PackedFloat32Array(), -"values": [] -} -tracks/5/type = "method" -tracks/5/imported = false -tracks/5/enabled = true -tracks/5/path = NodePath("SwingSound") -tracks/5/interp = 1 -tracks/5/loop_wrap = true -tracks/5/keys = { "times": PackedFloat32Array(0.1), "transitions": PackedFloat32Array(1), "values": [{ @@ -280,20 +255,6 @@ tracks/3/keys = { "update": 1, "values": [3.14159, 0.785398] } -tracks/4/type = "method" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath(".") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0.2), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": ["is_alternate", false], -"method": &"SetAnimationCondition" -}] -} [sub_resource type="AnimationLibrary" id="AnimationLibrary_tao4k"] _data = { @@ -305,55 +266,6 @@ _data = { "attack_alternate": SubResource("Animation_pclfs") } -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7lqgd"] -animation = &"RESET" - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_0in44"] -animation = &"anticipate" - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_2wqg6"] -animation = &"anticipate_bot" - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_2ei3g"] -animation = &"use" - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_esyoj"] - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_kg3rd"] -switch_mode = 2 -advance_mode = 2 - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_twtoe"] - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_73wvy"] -switch_mode = 2 -advance_mode = 2 - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_4wst0"] -switch_mode = 2 -advance_mode = 2 - -[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_2lfol"] -switch_mode = 2 -advance_mode = 2 -advance_condition = &"is_player" - -[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_q4hbp"] -states/End/position = Vector2(717, 75) -states/RESET/node = SubResource("AnimationNodeAnimation_7lqgd") -states/RESET/position = Vector2(275, 190) -states/Start/position = Vector2(109, 75) -states/anticipate/node = SubResource("AnimationNodeAnimation_0in44") -states/anticipate/position = Vector2(275, 75) -states/anticipate_bot/node = SubResource("AnimationNodeAnimation_2wqg6") -states/anticipate_bot/position = Vector2(456, 18) -states/use/node = SubResource("AnimationNodeAnimation_2ei3g") -states/use/position = Vector2(609, 75) -transitions = ["Start", "anticipate", SubResource("AnimationNodeStateMachineTransition_esyoj"), "use", "RESET", SubResource("AnimationNodeStateMachineTransition_kg3rd"), "RESET", "anticipate", SubResource("AnimationNodeStateMachineTransition_twtoe"), "anticipate", "anticipate_bot", SubResource("AnimationNodeStateMachineTransition_73wvy"), "anticipate_bot", "use", SubResource("AnimationNodeStateMachineTransition_4wst0"), "anticipate", "use", SubResource("AnimationNodeStateMachineTransition_2lfol")] -graph_offset = Vector2(0, -104.073) - -[sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_37556"] - [node name="Sword" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] y_sort_enabled = true texture_filter = 3 @@ -438,13 +350,6 @@ libraries = { "": SubResource("AnimationLibrary_tao4k") } -[node name="AnimationTree" type="AnimationTree" parent="."] -tree_root = SubResource("AnimationNodeStateMachine_q4hbp") -anim_player = NodePath("../AnimationPlayer") -active = true -parameters/playback = SubResource("AnimationNodeStateMachinePlayback_37556") -parameters/conditions/is_player = false - [node name="Hitbox" parent="." instance=ExtResource("3_up3ob")] IsDisabled = true diff --git a/State/Weapon/WeaponStateMachine.cs b/State/Weapon/WeaponStateMachine.cs index cab47cf..480392d 100644 --- a/State/Weapon/WeaponStateMachine.cs +++ b/State/Weapon/WeaponStateMachine.cs @@ -7,9 +7,16 @@ public partial class WeaponStateMachine : StateMachine [Export] public override WeaponState InitialState { get; set; } + /// + /// List of initial states when an item is being used. This should also + /// include alt use states. + /// [Export] public Godot.Collections.Array UsedItemStates { get; protected set; } + [Export] + public Godot.Collections.Array UsedItemAltStates { get; protected set; } + [Export] public Godot.Collections.Array DeusedItemStates { get; protected set; }