Added indicator for remaining uses of active item
This commit is contained in:
parent
697e5ad9e4
commit
85f7d32f71
14 changed files with 73 additions and 19 deletions
|
|
@ -1,10 +1,23 @@
|
||||||
class_name ActiveItem extends Item
|
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 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:
|
func collect() -> bool:
|
||||||
if (player.active_item == null):
|
if (player.active_item == null):
|
||||||
player.active_item = self
|
player.active_item = self
|
||||||
|
uses = uses
|
||||||
actually_collect()
|
actually_collect()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
@ -13,7 +26,17 @@ func collect() -> bool:
|
||||||
func actually_collect():
|
func actually_collect():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func trigger_activation():
|
||||||
|
activate()
|
||||||
|
if uses != -1:
|
||||||
|
uses -= 1
|
||||||
|
if uses == 0:
|
||||||
|
remove()
|
||||||
|
|
||||||
func activate():
|
func activate():
|
||||||
assert(false)
|
assert(false)
|
||||||
|
|
||||||
|
func remove():
|
||||||
|
uses = 0
|
||||||
|
player.active_item = null
|
||||||
|
self.queue_free()
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 770 B |
BIN
items/active_items/bow/arrow.png
Normal file
BIN
items/active_items/bow/arrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 875 B |
|
|
@ -3,15 +3,15 @@
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://bavoghl2pxs83"
|
uid="uid://bavoghl2pxs83"
|
||||||
path="res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex"
|
path="res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://items/active_items/bow/arror.png"
|
source_file="res://items/active_items/bow/arrow.png"
|
||||||
dest_files=["res://.godot/imported/arror.png-9ea2fbd842e6807dfd42e9ceed411fd2.ctex"]
|
dest_files=["res://.godot/imported/arrow.png-11da51178d457b4db8d73e91ed37096d.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://dfva4dhflxglr"]
|
[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="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"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tfcgf"]
|
||||||
size = Vector2(20, 5)
|
size = Vector2(20, 5)
|
||||||
|
|
|
||||||
9
items/active_items/bow/arrow_icon.tscn
Normal file
9
items/active_items/bow/arrow_icon.tscn
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
extends ActiveItem
|
extends ActiveItem
|
||||||
@export var cooldown = 1
|
@export var cooldown = 0.3
|
||||||
@export var arrow_scene : PackedScene
|
@export var arrow_scene : PackedScene
|
||||||
|
|
||||||
func actually_collect():
|
func actually_collect():
|
||||||
|
|
|
||||||
|
|
@ -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="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="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="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://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="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="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"]
|
[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")
|
script = ExtResource("1_xppub")
|
||||||
arrow_scene = ExtResource("2_0id2q")
|
arrow_scene = ExtResource("2_0id2q")
|
||||||
sprite = ExtResource("3_vkelq")
|
sprite = ExtResource("3_vkelq")
|
||||||
|
uses_left_icon = ExtResource("4_2dslu")
|
||||||
|
uses = 5
|
||||||
icon = ExtResource("3_vkelq")
|
icon = ExtResource("3_vkelq")
|
||||||
item_name = "Bow"
|
item_name = "Bow"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
extends ActiveItem
|
extends ActiveItem
|
||||||
var cooldown = 1.5
|
@export var cooldown = 0.2
|
||||||
var dash_time = 0.15
|
var dash_time = 0.15
|
||||||
var dashing = 0
|
var dash_timer : SceneTreeTimer
|
||||||
var dash_dir
|
var dash_dir
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super(delta)
|
super(delta)
|
||||||
if dashing > 0:
|
if dash_timer != null and dash_timer.time_left > 0:
|
||||||
dashing -= delta
|
|
||||||
player.reset_to_velocity = player.earth_aligner.local_from_global(dash_dir)
|
player.reset_to_velocity = player.earth_aligner.local_from_global(dash_dir)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,6 +17,14 @@ func activate():
|
||||||
$DashSound.play()
|
$DashSound.play()
|
||||||
player.activate_cooldown()
|
player.activate_cooldown()
|
||||||
player.air_jumps_current = min(player.air_jumps_current + 1, player.air_jumps_max)
|
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)
|
dash_dir = player.earth_aligner.global_from_local(Vector2.RIGHT * player.facing * 1600)
|
||||||
player.inv_time = max(player.inv_time, dash_time)
|
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()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ var cooldown = 10
|
||||||
func actually_collect():
|
func actually_collect():
|
||||||
player.set_cooldown(cooldown)
|
player.set_cooldown(cooldown)
|
||||||
|
|
||||||
|
|
||||||
func activate():
|
func activate():
|
||||||
$UpdashSound.play()
|
$UpdashSound.play()
|
||||||
player.activate_cooldown()
|
player.activate_cooldown()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,6 @@
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("6_rli0f")
|
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")])
|
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")])
|
unique = Array[PackedScene]([ExtResource("6_73uum"), ExtResource("7_k6eth"), ExtResource("8_8cxou"), ExtResource("9_esvgx")])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
extends Item
|
extends Item
|
||||||
|
|
||||||
func collect():
|
func collect():
|
||||||
player.jump_strength = 1600
|
player.ground_jump_strength = 1600
|
||||||
|
player.air_jump_strength = 1400
|
||||||
$SoundCollect.play()
|
$SoundCollect.play()
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
14
main.tscn
14
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="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"]
|
[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://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="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="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"]
|
[node name="main" type="Node2D"]
|
||||||
|
|
||||||
|
|
@ -55,6 +56,14 @@ texture = ExtResource("4_ycdy4")
|
||||||
offset_right = 96.0
|
offset_right = 96.0
|
||||||
offset_bottom = 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")]
|
[node name="ItemUI" parent="UIOverlay" node_paths=PackedStringArray("player") instance=ExtResource("6_4c57u")]
|
||||||
player = NodePath("../../Player")
|
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")
|
script = ExtResource("10_efxa6")
|
||||||
boss = ExtResource("11_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="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="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"]
|
[connection signal="max_hp_changed" from="Player" to="UIOverlay/Healthbar" method="_on_player_max_hp_changed"]
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,9 @@ func manage_attack(delta : float):
|
||||||
|
|
||||||
func manage_active(_delta : float):
|
func manage_active(_delta : float):
|
||||||
if(active_item != null and Input.is_action_just_pressed("item") and active_item_cooldown.is_stopped()):
|
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")):
|
if(Input.is_action_just_pressed("drop_item")):
|
||||||
active_item = null
|
active_item.remove()
|
||||||
|
|
||||||
func manage_movement_options() -> void:
|
func manage_movement_options() -> void:
|
||||||
if(is_on_floor()):
|
if(is_on_floor()):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue