Add new level, collapsable component, knockback component
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
class_name HealthComponent
|
||||
extends Node2D
|
||||
extends Node
|
||||
|
||||
@export var health: float = 1.0
|
||||
@export var max_health: float = 1.0
|
||||
|
||||
signal on_health_change(delta: float)
|
||||
signal on_health_change(delta: float, total_health: float)
|
||||
signal on_death
|
||||
|
||||
func _get_delta(value: float) -> float:
|
||||
@@ -16,7 +16,7 @@ func set_health(new_value: float):
|
||||
|
||||
if new_value >= max_health:
|
||||
health = max_health
|
||||
on_health_change.emit(delta)
|
||||
on_health_change.emit(delta, health)
|
||||
return
|
||||
|
||||
health = new_value
|
||||
@@ -25,7 +25,7 @@ func set_health(new_value: float):
|
||||
on_death.emit()
|
||||
return
|
||||
|
||||
on_health_change.emit(delta)
|
||||
on_health_change.emit(delta, health)
|
||||
|
||||
func decrease_health(value: float):
|
||||
var delta = _get_delta(value)
|
||||
@@ -36,7 +36,7 @@ func decrease_health(value: float):
|
||||
on_death.emit()
|
||||
return
|
||||
|
||||
on_health_change.emit(delta)
|
||||
on_health_change.emit(delta, health)
|
||||
|
||||
func increase_health(value: float):
|
||||
var delta = _get_delta(value)
|
||||
@@ -45,9 +45,9 @@ func increase_health(value: float):
|
||||
|
||||
if health >= max_health:
|
||||
health = max_health
|
||||
on_health_change.emit(delta)
|
||||
on_health_change.emit(delta, health)
|
||||
return
|
||||
|
||||
health += value
|
||||
on_health_change.emit(delta)
|
||||
on_health_change.emit(delta, health)
|
||||
|
||||
|
Reference in New Issue
Block a user