Introduced Status Effects
This commit is contained in:
parent
2acc452f19
commit
a042bb1282
4 changed files with 46 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ var gravity = 100;
|
||||||
|
|
||||||
# Movement
|
# Movement
|
||||||
var facing = -1;
|
var facing = -1;
|
||||||
var hspeed = 150;
|
var base_hspeed = 150.0;
|
||||||
var ground_jump_strength = 1400;
|
var ground_jump_strength = 1400;
|
||||||
var air_jump_strength = 1100;
|
var air_jump_strength = 1100;
|
||||||
var air_jumps_max = 1;
|
var air_jumps_max = 1;
|
||||||
|
|
@ -141,6 +141,7 @@ func manage_velocity(delta: float) -> void:
|
||||||
local_velocity += Vector2(0, gravity)
|
local_velocity += Vector2(0, gravity)
|
||||||
|
|
||||||
if handle_input:
|
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(Input.is_action_pressed("move_right")):
|
||||||
if local_velocity.x > -700:
|
if local_velocity.x > -700:
|
||||||
local_velocity += Vector2(hspeed, 0)
|
local_velocity += Vector2(hspeed, 0)
|
||||||
|
|
@ -179,6 +180,7 @@ func manage_velocity(delta: float) -> void:
|
||||||
|
|
||||||
func hurt(dmg: int, dir: Vector2 = Vector2.ZERO):
|
func hurt(dmg: int, dir: Vector2 = Vector2.ZERO):
|
||||||
if(inv_time <= 0):
|
if(inv_time <= 0):
|
||||||
|
if Status.affects("Vulnerable", self): dmg += 1
|
||||||
$AudioStreamPlayer2D.play()
|
$AudioStreamPlayer2D.play()
|
||||||
current_hp -= dmg
|
current_hp -= dmg
|
||||||
if(current_hp <= 0):
|
if(current_hp <= 0):
|
||||||
|
|
|
||||||
41
statusses/status.gd
Normal file
41
statusses/status.gd
Normal file
|
|
@ -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 {}
|
||||||
1
statusses/status.gd.uid
Normal file
1
statusses/status.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c574sege4i20i
|
||||||
|
|
@ -6,6 +6,7 @@ class_name Vine extends Node2D
|
||||||
@onready var grid : Grid
|
@onready var grid : Grid
|
||||||
var img_path_inactive = "res://vines_petals/vine_inactive.png"
|
var img_path_inactive = "res://vines_petals/vine_inactive.png"
|
||||||
@export var img_path_active = "res://vines_petals/vine_active_green.png"
|
@export var img_path_active = "res://vines_petals/vine_active_green.png"
|
||||||
|
@export var status : Timer
|
||||||
var active_depth = -1
|
var active_depth = -1
|
||||||
var fully_active = false
|
var fully_active = false
|
||||||
var vine_data = []
|
var vine_data = []
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue