2024-10-25 15:41:39 +08:00
|
|
|
extends Unit
|
2024-10-30 19:54:45 +08:00
|
|
|
class_name SelfUnit
|
2024-10-25 15:41:39 +08:00
|
|
|
func _ready() -> void:
|
2024-10-28 19:24:10 +08:00
|
|
|
unit_data=Database.get_unit_data(unit_data_from_id,unit_id)
|
2024-10-25 15:41:39 +08:00
|
|
|
super._ready()
|
|
|
|
state_machine.launch()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_state_value_changed(state_value_name: String, value: Variant) -> void:
|
|
|
|
match state_value_name:
|
|
|
|
"hp":
|
|
|
|
%hp.value=value
|
|
|
|
"hp_max":
|
|
|
|
%hp.max_value=value
|
|
|
|
pass # Replace with function body.
|
2024-10-30 19:54:45 +08:00
|
|
|
|
|
|
|
|
2024-11-01 23:23:07 +08:00
|
|
|
var e_interaction_item:EInteractionItem
|
2024-10-30 19:54:45 +08:00
|
|
|
var door_area:Door
|
|
|
|
func _on_touch_area_area_entered(area: Area2D) -> void:
|
|
|
|
if area is Door:
|
|
|
|
door_area=area
|
2024-11-01 23:23:07 +08:00
|
|
|
%door.show()
|
|
|
|
if area is EInteractionItem:
|
|
|
|
if e_interaction_item!=null:
|
|
|
|
e_interaction_item._exit_highlight()
|
|
|
|
e_interaction_item=area
|
|
|
|
|
|
|
|
|
2024-10-30 19:54:45 +08:00
|
|
|
%door.show()
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
func _on_touch_area_area_exited(area: Area2D) -> void:
|
2024-11-01 23:23:07 +08:00
|
|
|
if area is EInteractionItem:
|
|
|
|
if e_interaction_item==area:
|
|
|
|
e_interaction_item._exit_highlight()
|
|
|
|
e_interaction_item=null
|
2024-10-30 19:54:45 +08:00
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
func is_door_availible():
|
|
|
|
return door_area!=null
|
2024-11-01 23:23:07 +08:00
|
|
|
func get_e_interaction_item():
|
2024-10-30 19:54:45 +08:00
|
|
|
|
2024-11-01 23:23:07 +08:00
|
|
|
return e_interaction_item
|
2024-10-30 19:54:45 +08:00
|
|
|
|
2024-11-01 23:23:07 +08:00
|
|
|
func e_pressed():
|
|
|
|
if e_interaction_item!=null:
|
|
|
|
e_interaction_item.E_pressed()
|