Files
autgame/games/juggling_gym/scripts/gym_drop_zone.gd
T

34 lines
974 B
GDScript

class_name GymDropZone
extends ColorRect
## Zona invisibile di rilascio sopra un giocoliere del mockup P3B.
signal tool_dropped(zone_id: String, data: Dictionary)
var zone_id := ""
var _base_color := Color(0.95, 0.78, 0.28, 0.0)
func configure(id: String) -> void:
zone_id = id
color = _base_color
mouse_filter = Control.MOUSE_FILTER_STOP
func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
var valid: bool = data is Dictionary and data.has("tool_id")
color = Color(0.95, 0.78, 0.28, 0.18) if valid else _base_color
return valid
func _drop_data(_at_position: Vector2, data: Variant) -> void:
color = _base_color
if data is Dictionary:
tool_dropped.emit(zone_id, data)
func flash(success: bool) -> void:
var flash_color := Color(0.35, 0.82, 0.42, 0.42) if success else Color(0.9, 0.28, 0.24, 0.38)
var tween := create_tween()
tween.tween_property(self, "color", flash_color, 0.08)
tween.tween_property(self, "color", _base_color, 0.34)