Added Active Items, an Updash Item and the possibility for items to not be immediately connected
This commit is contained in:
parent
f19bda7886
commit
4be01c1aa1
10 changed files with 63 additions and 11 deletions
7
active_item.gd
Normal file
7
active_item.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class_name ActiveItem extends Item
|
||||||
|
|
||||||
|
func collect() -> bool:
|
||||||
|
if (player.active_item == null):
|
||||||
|
player.active_item = self
|
||||||
|
return true
|
||||||
|
return false
|
||||||
1
active_item.gd.uid
Normal file
1
active_item.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dyu8r5dt6qk8k
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
extends Item
|
extends Item
|
||||||
@export var heal_amount = 1
|
@export var heal_amount = 1
|
||||||
|
|
||||||
func collect():
|
func collect() -> bool:
|
||||||
if(player.current_hp < player.max_hp):
|
if(player.current_hp < player.max_hp):
|
||||||
player.current_hp += heal_amount
|
player.current_hp += heal_amount
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
|
||||||
11
item.gd
11
item.gd
|
|
@ -6,12 +6,11 @@ func _ready() -> void:
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D):
|
func _on_body_entered(body: Node2D):
|
||||||
if(body.name == "Player"):
|
if(body.name == "Player"):
|
||||||
set_deferred("monitoring", false)
|
if(self.has_method("collect") and collect()):
|
||||||
set_deferred("monitorable", false)
|
set_deferred("monitoring", false)
|
||||||
call_deferred("reparent", player)
|
set_deferred("monitorable", false)
|
||||||
collect_animation()
|
call_deferred("reparent", player)
|
||||||
if(self.has_method("collect")):
|
collect_animation()
|
||||||
collect()
|
|
||||||
|
|
||||||
func collect_animation():
|
func collect_animation():
|
||||||
self.visible = false
|
self.visible = false
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
[ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"]
|
[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"]
|
||||||
[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://platform.tscn" id="7_272bh"]
|
[ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://platform.tscn" id="7_272bh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b00185vygcka1" path="res://heal_item.tscn" id="8_5vw27"]
|
[ext_resource type="PackedScene" uid="uid://ennu3lalstdr" path="res://updash.tscn" id="9_4c57u"]
|
||||||
[ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="9_kek77"]
|
[ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="9_kek77"]
|
||||||
|
|
||||||
[node name="main" type="Node2D"]
|
[node name="main" type="Node2D"]
|
||||||
|
|
@ -49,12 +49,12 @@ visible = false
|
||||||
position = Vector2(900, -3000)
|
position = Vector2(900, -3000)
|
||||||
scale = Vector2(5, 3.1)
|
scale = Vector2(5, 3.1)
|
||||||
|
|
||||||
[node name="HealItem" parent="." instance=ExtResource("8_5vw27")]
|
|
||||||
position = Vector2(0, -3150)
|
|
||||||
|
|
||||||
[node name="Ghost" parent="." instance=ExtResource("9_kek77")]
|
[node name="Ghost" parent="." instance=ExtResource("9_kek77")]
|
||||||
position = Vector2(0, -3000)
|
position = Vector2(0, -3000)
|
||||||
|
|
||||||
|
[node name="Updash" parent="." instance=ExtResource("9_4c57u")]
|
||||||
|
position = Vector2(0, -3100)
|
||||||
|
|
||||||
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
[connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"]
|
||||||
[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]
|
[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"]
|
||||||
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
[connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"]
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,14 @@ var damage_knockup = 500
|
||||||
var atk_cooldown = 0.5
|
var atk_cooldown = 0.5
|
||||||
var atk_timer = 0
|
var atk_timer = 0
|
||||||
|
|
||||||
|
# Active Item
|
||||||
|
var active_item = null
|
||||||
|
var item_cooldown = 0
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
manage_iframes(delta)
|
manage_iframes(delta)
|
||||||
manage_movement_options()
|
manage_movement_options()
|
||||||
|
manage_active(delta)
|
||||||
manage_animation()
|
manage_animation()
|
||||||
manage_attack(delta)
|
manage_attack(delta)
|
||||||
manage_velocity(delta)
|
manage_velocity(delta)
|
||||||
|
|
@ -61,6 +66,11 @@ func manage_attack(delta : float):
|
||||||
sword.swing()
|
sword.swing()
|
||||||
atk_timer = atk_cooldown
|
atk_timer = atk_cooldown
|
||||||
|
|
||||||
|
func manage_active(delta : float):
|
||||||
|
item_cooldown = max(item_cooldown - delta, 0)
|
||||||
|
if(active_item != null and Input.is_action_just_pressed("item") and item_cooldown <= 0):
|
||||||
|
active_item.activate()
|
||||||
|
|
||||||
func manage_movement_options() -> void:
|
func manage_movement_options() -> void:
|
||||||
if(is_on_floor()):
|
if(is_on_floor()):
|
||||||
air_jumps_current = air_jumps_max
|
air_jumps_current = air_jumps_max
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,11 @@ drop={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
item={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
||||||
9
updash.gd
Normal file
9
updash.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends ActiveItem
|
||||||
|
var cooldown = 10
|
||||||
|
|
||||||
|
|
||||||
|
func activate():
|
||||||
|
player.item_cooldown = cooldown
|
||||||
|
player.reset_to_velocity = Vector2(0,1)
|
||||||
|
await get_tree().create_timer(0.1).timeout
|
||||||
|
player.reset_to_velocity = Vector2(0, -2400)
|
||||||
1
updash.gd.uid
Normal file
1
updash.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bbwsc2a2hd0ow
|
||||||
18
updash.tscn
Normal file
18
updash.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://ennu3lalstdr"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bbwsc2a2hd0ow" path="res://updash.gd" id="1_ghbl6"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cy70quh6k3s1j" path="res://icon.svg" id="1_ptc3l"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ghbl6"]
|
||||||
|
|
||||||
|
[node name="Updash" type="Area2D"]
|
||||||
|
script = ExtResource("1_ghbl6")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
scale = Vector2(3, 3)
|
||||||
|
shape = SubResource("CircleShape2D_ghbl6")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 0, 1, 1)
|
||||||
|
scale = Vector2(0.45, 0.45)
|
||||||
|
texture = ExtResource("1_ptc3l")
|
||||||
Loading…
Add table
Reference in a new issue