extends Control const EVENT_CHOICE_BUTTON = preload("res://scene/event_choice_button.tscn") @onready var choice_add_pos: VBoxContainer = $MarginContainer/NinePatchRect/VBoxContainer/VBoxContainer/choice_add_pos @onready var event_texture: TextureRect = $MarginContainer/HBoxContainer/event_texture @onready var event_intro: Label = $MarginContainer/NinePatchRect/VBoxContainer/event_intro @onready var event_name: Label = $MarginContainer/NinePatchRect/TextureRect/event_name @onready var animation_player: AnimationPlayer = $AnimationPlayer @onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer var data:Dictionary var text_ratio_tween:Tween # Called when the node enters the scene tree for the first time. func _ready() -> void: set_event_data("event_01") pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass #通过事件ID初始化界面 func set_event_data(id:String): data=Global.get_event_data(id) for i in choice_add_pos.get_children(): i.queue_free() event_texture.texture=Global.get_texture(data["texture"]) event_intro.text=data["text"] event_name.text=data["name"] var choice_data=data["choice"] for i in choice_data: var new_btn=EVENT_CHOICE_BUTTON.instantiate() choice_add_pos.add_child(new_btn) new_btn.set_data(i) new_btn.click.connect(choice_click) animation_player.play("open") func choice_click(event_data:Dictionary): if not event_data.has("triger"): return for i in event_data["triger"]: Global.call_triger(i["type"],i["data"]) pass pass func change_texture(texture_id:String): event_texture.texture=Global.get_texture(texture_id) func change_text(text:String): event_intro.text=text func change_choice(choice_data:Array): for i in choice_add_pos.get_children(): i.queue_free() for i in choice_data: var new_btn=EVENT_CHOICE_BUTTON.instantiate() choice_add_pos.add_child(new_btn) new_btn.set_data(i) new_btn.click.connect(choice_click) pass