diff --git a/player/player.gd b/player/player.gd index 6606bee..02d2c31 100644 --- a/player/player.gd +++ b/player/player.gd @@ -18,7 +18,7 @@ var gravity = 100; # Movement var facing = -1; -var hspeed = 150; +var base_hspeed = 150.0; var ground_jump_strength = 1400; var air_jump_strength = 1100; var air_jumps_max = 1; @@ -141,6 +141,7 @@ func manage_velocity(delta: float) -> void: local_velocity += Vector2(0, gravity) if handle_input: + var hspeed = base_hspeed if not Status.affects("Slow", self) else base_hspeed * get_node("Slow").params.slow_factor if(Input.is_action_pressed("move_right")): if local_velocity.x > -700: local_velocity += Vector2(hspeed, 0) @@ -179,6 +180,7 @@ func manage_velocity(delta: float) -> void: func hurt(dmg: int, dir: Vector2 = Vector2.ZERO): if(inv_time <= 0): + if Status.affects("Vulnerable", self): dmg += 1 $AudioStreamPlayer2D.play() current_hp -= dmg if(current_hp <= 0): diff --git a/statusses/status.gd b/statusses/status.gd new file mode 100644 index 0000000..294f970 --- /dev/null +++ b/statusses/status.gd @@ -0,0 +1,41 @@ +class_name Status extends Timer +var params = {} +const default_parameters = { + "Vulnerable": {}, + "Slow": { + "slow_factor": 0.6 + } + } + +static func apply(status_name : String, target : Node, duration : float, params_in : Dictionary = {}): + if not target.has_node(status_name): + var child = Status.new() + child.name = status_name + child.params = params_in + child.params.merge(get_default_parameters(status_name)) + target.add_child(child) + child.start(duration) + else: + var child : Status = target.get_node(status_name) + child.reapply(duration) + +static func affects(status_name : String, target : Node) -> bool: + return target.has_node(status_name) + +static func get_status(status_name : String, target : Node) -> Status: + if affects(status_name, target): + return target.get_node(status_name) + else: + return null + +func _enter_tree() -> void: + timeout.connect(expire) + +func reapply(duration_new : float): + self.start(max(duration_new, time_left)) + +func expire(): + queue_free() + +static func get_default_parameters(status_name : String) -> Dictionary: + return default_parameters.get(status_name) if default_parameters.has(status_name) else {} diff --git a/statusses/status.gd.uid b/statusses/status.gd.uid new file mode 100644 index 0000000..9f69596 --- /dev/null +++ b/statusses/status.gd.uid @@ -0,0 +1 @@ +uid://c574sege4i20i diff --git a/vines_petals/vine.gd b/vines_petals/vine.gd index ff03295..ebda4ed 100644 --- a/vines_petals/vine.gd +++ b/vines_petals/vine.gd @@ -6,6 +6,7 @@ class_name Vine extends Node2D @onready var grid : Grid var img_path_inactive = "res://vines_petals/vine_inactive.png" @export var img_path_active = "res://vines_petals/vine_active_green.png" +@export var status : Timer var active_depth = -1 var fully_active = false var vine_data = []