diff --git a/items/active_items/active_item.gd b/items/active_items/active_item.gd index 7a77194..06c9631 100644 --- a/items/active_items/active_item.gd +++ b/items/active_items/active_item.gd @@ -1,10 +1,23 @@ class_name ActiveItem extends Item +@onready var active_item_uses = get_tree().get_root().get_node_or_null("main/UIOverlay/ActiveItemUses") + @export var sprite : Texture2D +@export var uses_left_icon : PackedScene +@export var uses = 1: + set(new_uses): + uses = new_uses + if active_item_uses != null: + while active_item_uses.get_children().size() > uses: + active_item_uses.remove_child(active_item_uses.get_child(0)) + while active_item_uses.get_children().size() < uses: + if uses_left_icon != null: + active_item_uses.add_child(uses_left_icon.instantiate()) func collect() -> bool: if (player.active_item == null): player.active_item = self + uses = uses actually_collect() return true @@ -13,7 +26,17 @@ func collect() -> bool: func actually_collect(): pass +func trigger_activation(): + activate() + if uses != -1: + uses -= 1 + if uses == 0: + remove() + func activate(): assert(false) - - + +func remove(): + uses = 0 + player.active_item = null + self.queue_free() diff --git a/items/active_items/bow/arror.png b/items/active_items/bow/arror.png deleted file mode 100644 index dd3cf4d..0000000 Binary files a/items/active_items/bow/arror.png and /dev/null differ diff --git a/items/active_items/bow/arrow.png b/items/active_items/bow/arrow.png new file mode 100644 index 0000000..a8881fb Binary files /dev/null and b/items/active_items/bow/arrow.png differ diff --git a/items/active_items/bow/arror.png.import b/items/active_items/bow/arrow.png.import similarity index 77% rename from items/active_items/bow/arror.png.import rename to items/active_items/bow/arrow.png.import index b96ef8b..c80a6e0 100644 --- a/items/active_items/bow/arror.png.import +++ b/items/active_items/bow/arrow.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://bavoghl2pxs83" -path="res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex" +path="res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://items/active_items/bow/arror.png" -dest_files=["res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex"] +source_file="res://items/active_items/bow/arrow.png" +dest_files=["res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex"] [params] diff --git a/items/active_items/bow/arrow.tscn b/items/active_items/bow/arrow.tscn index 3c6c5b4..8c6b366 100644 --- a/items/active_items/bow/arrow.tscn +++ b/items/active_items/bow/arrow.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://dfva4dhflxglr"] [ext_resource type="Script" uid="uid://bglrm0bb4nla" path="res://items/active_items/bow/arrow.gd" id="1_lxthq"] -[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arror.png" id="2_ilsew"] +[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arrow.png" id="2_ilsew"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_tfcgf"] size = Vector2(20, 5) diff --git a/items/active_items/bow/arrow_icon.tscn b/items/active_items/bow/arrow_icon.tscn new file mode 100644 index 0000000..6f7fba2 --- /dev/null +++ b/items/active_items/bow/arrow_icon.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://bu3j6ambrybd2"] + +[ext_resource type="Texture2D" uid="uid://bavoghl2pxs83" path="res://items/active_items/bow/arrow.png" id="1_7lvex"] + +[node name="TextureRect" type="TextureRect"] +custom_minimum_size = Vector2(0, 3) +texture = ExtResource("1_7lvex") +expand_mode = 3 +stretch_mode = 3 diff --git a/items/active_items/bow/bow.gd b/items/active_items/bow/bow.gd index 9515847..5df10a8 100644 --- a/items/active_items/bow/bow.gd +++ b/items/active_items/bow/bow.gd @@ -1,5 +1,5 @@ extends ActiveItem -@export var cooldown = 1 +@export var cooldown = 0.3 @export var arrow_scene : PackedScene func actually_collect(): diff --git a/items/active_items/bow/bow.tscn b/items/active_items/bow/bow.tscn index 9bfa446..45a2339 100644 --- a/items/active_items/bow/bow.tscn +++ b/items/active_items/bow/bow.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=9 format=3 uid="uid://ddn025xnjngko"] +[gd_scene load_steps=10 format=3 uid="uid://ddn025xnjngko"] [ext_resource type="Script" uid="uid://bkcip66at5sug" path="res://items/active_items/bow/bow.gd" id="1_xppub"] [ext_resource type="PackedScene" uid="uid://dfva4dhflxglr" path="res://items/active_items/bow/arrow.tscn" id="2_0id2q"] [ext_resource type="Texture2D" uid="uid://d01h01le82gyh" path="res://items/active_items/bow/bow.png" id="3_vkelq"] [ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="4_0id2q"] +[ext_resource type="PackedScene" uid="uid://bu3j6ambrybd2" path="res://items/active_items/bow/arrow_icon.tscn" id="4_2dslu"] [ext_resource type="AudioStream" uid="uid://bg1w0fyeyys2p" path="res://sounds/item-equip-6904.mp3" id="5_gfbg0"] [ext_resource type="Texture2D" uid="uid://d4mrbgfl7jpqq" path="res://items/ItemShine.png" id="5_o1smo"] [ext_resource type="AudioStream" uid="uid://10ljbd4djqgb" path="res://sounds/263675__porkmuncher__bow_release_cut.wav" id="7_o1smo"] @@ -17,6 +18,8 @@ collision_mask = 4 script = ExtResource("1_xppub") arrow_scene = ExtResource("2_0id2q") sprite = ExtResource("3_vkelq") +uses_left_icon = ExtResource("4_2dslu") +uses = 5 icon = ExtResource("3_vkelq") item_name = "Bow" diff --git a/items/active_items/horizontal_dash/horizontal_dash.gd b/items/active_items/horizontal_dash/horizontal_dash.gd index a9cc308..599d6eb 100644 --- a/items/active_items/horizontal_dash/horizontal_dash.gd +++ b/items/active_items/horizontal_dash/horizontal_dash.gd @@ -1,13 +1,12 @@ extends ActiveItem -var cooldown = 1.5 +@export var cooldown = 0.2 var dash_time = 0.15 -var dashing = 0 +var dash_timer : SceneTreeTimer var dash_dir func _process(delta: float) -> void: super(delta) - if dashing > 0: - dashing -= delta + if dash_timer != null and dash_timer.time_left > 0: player.reset_to_velocity = player.earth_aligner.local_from_global(dash_dir) @@ -18,6 +17,14 @@ func activate(): $DashSound.play() player.activate_cooldown() player.air_jumps_current = min(player.air_jumps_current + 1, player.air_jumps_max) - dashing = dash_time + dash_timer = get_tree().create_timer(dash_time) dash_dir = player.earth_aligner.global_from_local(Vector2.RIGHT * player.facing * 1600) player.inv_time = max(player.inv_time, dash_time) + +func remove(): + if(dash_timer != null): + player.active_item = null + await dash_timer.timeout + super() + else: + super() diff --git a/items/active_items/updash/updash.gd b/items/active_items/updash/updash.gd index 2bd0662..b979af5 100644 --- a/items/active_items/updash/updash.gd +++ b/items/active_items/updash/updash.gd @@ -3,7 +3,6 @@ var cooldown = 10 func actually_collect(): player.set_cooldown(cooldown) - func activate(): $UpdashSound.play() diff --git a/items/generic/item_pool.tres b/items/generic/item_pool.tres index f902935..560cbd4 100644 --- a/items/generic/item_pool.tres +++ b/items/generic/item_pool.tres @@ -13,6 +13,6 @@ [resource] script = ExtResource("6_rli0f") -common = Array[PackedScene]([ExtResource("1_2l6sh")]) +common = Array[PackedScene]([ExtResource("1_2l6sh"), ExtResource("5_jwi73")]) rare = Array[PackedScene]([ExtResource("3_g002j"), ExtResource("2_rli0f"), ExtResource("4_vpswe"), ExtResource("5_jwi73")]) unique = Array[PackedScene]([ExtResource("6_73uum"), ExtResource("7_k6eth"), ExtResource("8_8cxou"), ExtResource("9_esvgx")]) diff --git a/items/permanent_items/high_jump/high_jump.gd b/items/permanent_items/high_jump/high_jump.gd index 4e5a65f..3e4e7ea 100644 --- a/items/permanent_items/high_jump/high_jump.gd +++ b/items/permanent_items/high_jump/high_jump.gd @@ -1,6 +1,7 @@ extends Item func collect(): - player.jump_strength = 1600 + player.ground_jump_strength = 1600 + player.air_jump_strength = 1400 $SoundCollect.play() return true diff --git a/main.tscn b/main.tscn index b334348..a5ddc91 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://cxo6bq26huau7"] +[gd_scene load_steps=17 format=3 uid="uid://cxo6bq26huau7"] [ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"] [ext_resource type="Texture2D" uid="uid://d3fpq76anm4t7" path="res://world/Background Prototype/Background prototype.png" id="3_kek77"] @@ -15,6 +15,7 @@ [ext_resource type="PackedScene" uid="uid://cqn67nwyrtq3k" path="res://ui/journal/journal.tscn" id="10_w48qg"] [ext_resource type="PackedScene" uid="uid://cpe4s6vsn0ujd" path="res://enemies/boss/boss.tscn" id="11_efxa6"] [ext_resource type="Script" uid="uid://gul4u5tw1vxk" path="res://bg_image.gd" id="13_vivmo"] +[ext_resource type="PackedScene" uid="uid://ddn025xnjngko" path="res://items/active_items/bow/bow.tscn" id="16_2cqfq"] [node name="main" type="Node2D"] @@ -55,6 +56,14 @@ texture = ExtResource("4_ycdy4") offset_right = 96.0 offset_bottom = 96.0 +[node name="ActiveItemUses" type="VBoxContainer" parent="UIOverlay"] +unique_name_in_owner = true +offset_left = 1863.0 +offset_top = 25.0 +offset_right = 1895.0 +offset_bottom = 120.0 +alignment = 2 + [node name="ItemUI" parent="UIOverlay" node_paths=PackedStringArray("player") instance=ExtResource("6_4c57u")] player = NodePath("../../Player") @@ -95,6 +104,9 @@ colors = Array[Color]([Color(0, 0.6441987, 0.6693053, 1), Color(0.90588236, 0.15 script = ExtResource("10_efxa6") boss = ExtResource("11_efxa6") +[node name="Bow" parent="." instance=ExtResource("16_2cqfq")] +position = Vector2(325, -3068) + [connection signal="active_item_changed" from="Player" to="UIOverlay/ItemUI" method="_on_player_active_item_changed"] [connection signal="health_changed" from="Player" to="UIOverlay/Healthbar" method="_on_player_health_changed"] [connection signal="max_hp_changed" from="Player" to="UIOverlay/Healthbar" method="_on_player_max_hp_changed"] diff --git a/player/player.gd b/player/player.gd index 4a356a3..46ec7e8 100644 --- a/player/player.gd +++ b/player/player.gd @@ -102,9 +102,9 @@ func manage_attack(delta : float): func manage_active(_delta : float): if(active_item != null and Input.is_action_just_pressed("item") and active_item_cooldown.is_stopped()): - active_item.activate() + active_item.trigger_activation() if(Input.is_action_just_pressed("drop_item")): - active_item = null + active_item.remove() func manage_movement_options() -> void: if(is_on_floor()):