prototype vibe
This commit is contained in:
19
systems/xp_system.gd
Normal file
19
systems/xp_system.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Node
|
||||
|
||||
const XP_PER_ENEMY: int = 3
|
||||
const XP_PER_BOSS: int = 30
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
|
||||
func _on_entity_died(entity: Node) -> void:
|
||||
if not entity or not is_instance_valid(entity):
|
||||
return
|
||||
if not entity.is_in_group("enemies"):
|
||||
return
|
||||
var is_boss: bool = entity.is_in_group("boss")
|
||||
var data_source: Node = BossData if is_boss else EnemyData
|
||||
var scale_val: Variant = data_source.get_stat(entity, "scale")
|
||||
var scale: float = scale_val if scale_val != null else 1.0
|
||||
var base_xp: int = XP_PER_BOSS if is_boss else XP_PER_ENEMY
|
||||
PlayerData.add_xp(int(base_xp * scale))
|
||||
Reference in New Issue
Block a user