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 choice_data:Array=[] var text_ratio_tween:Tween # Called when the node enters the scene tree for the first time. func _ready() -> void: 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=Database.get_event_data(id) for i in choice_add_pos.get_children(): i.queue_free() event_texture.texture=Database.get_texture(data["texture"]) event_intro.text=data["text"] event_name.text=data["name"] var choice_data=data["choice"] self.choice_data=choice_data.duplicate(true) for i in choice_data: var enable:bool=true if i.has("condition"): var condition_data:Array=i["condition"] for j in condition_data: enable=enable and Global.call_condition_triger(j["type"],j["data"]) pass #print(enable) 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) new_btn.set_disable(not enable) 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 change_choice(self.choice_data) pass func change_texture(texture_id:String): event_texture.texture=Database.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() self.choice_data=choice_data.duplicate(true) for i in choice_data: var enable:bool=true if i.has("condition"): var condition_data:Array=i["condition"] for j in condition_data: enable=enable and Global.call_condition_triger(j["type"],j["data"]) #print(enable) 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) new_btn.set_disable(not enable) pass