132 lines
4.5 KiB
GDScript
132 lines
4.5 KiB
GDScript
extends Control
|
|
const BUXIANSHI = preload("res://res/ui/ui_029_multi_indetification/buxianshi.png")
|
|
const XIANSHI = preload("res://res/ui/ui_029_multi_indetification/xianshi.png")
|
|
const MULTI_INDETIFICATION_CHOICE = preload("res://scene/multi_indetification_choice.tscn")
|
|
@onready var result_hide_group:Array=[%result_label, $MarginContainer/HBoxContainer/VBoxContainer/result_panel/Label3, %identification_attribute_name, %identification_difficulty, %identification_value]
|
|
#鉴定数据
|
|
var data:Dictionary
|
|
#回合的数据
|
|
var round_data:Dictionary
|
|
|
|
var character_data:Dictionary={}
|
|
func set_data(_data:Dictionary):
|
|
data=_data
|
|
is_finish=false
|
|
round_data=_data["init_round"].duplicate(true)
|
|
round_data_update()
|
|
%AnimationPlayer.play("show_text")
|
|
pass
|
|
#根据round data更新显示
|
|
func round_data_update():
|
|
if round_data.has("left_cost"):
|
|
%left_value_panel.modulate.a=1
|
|
%left_cost_bar.max_value=round_data["left_cost_max"]
|
|
%left_cost_bar.value=round_data["left_cost"]
|
|
%left_cost_value.text=str(round_data["left_cost"])
|
|
%left_total_bar.max_value=round_data["left_total_max"]
|
|
%left_total_bar.value=round_data["left_total"]
|
|
%left_total_value.text=str(round_data["left_total"])
|
|
%left_cost_name.text=round_data["left_cost_name"]
|
|
%left_total_name.text=round_data["left_total_name"]
|
|
|
|
pass
|
|
else:
|
|
%left_value_panel.modulate.a=0
|
|
if round_data.has("right_cost"):
|
|
%right_value_panel.modulate.a=1
|
|
%right_cost_bar.max_value=round_data["right_cost_max"]
|
|
%right_cost_bar.value=round_data["right_cost"]
|
|
%right_cost_value.text=str(round_data["right_cost"])
|
|
%right_total_bar.max_value=round_data["right_total_max"]
|
|
%right_total_bar.value=round_data["right_total"]
|
|
%right_total_value.text=str(round_data["right_total"])
|
|
%right_cost_name.text=round_data["right_cost_name"]
|
|
%right_total_name.text=round_data["right_total_name"]
|
|
|
|
else:
|
|
%right_value_panel.modulate.a=0
|
|
if round_data.has("left_texture"):
|
|
%left_texture_panel.modulate.a=1
|
|
%left_texture.texture=Database.get_texture(round_data["left_texture"])
|
|
|
|
else:
|
|
%left_texture_panel.modulate.a=0
|
|
if round_data.has("right_texture"):
|
|
%right_texture_panel.modulate.a=1
|
|
%right_texture.texture=Database.get_texture(round_data["right_texture"])
|
|
else:
|
|
%right_texture_panel.modulate.a=0
|
|
|
|
%center_texture.texture=Database.get_texture(round_data["center_texture"])
|
|
%introduction_label.text=round_data["introduction"]
|
|
for i in %choice_add_pos.get_children():
|
|
i.queue_free()
|
|
for i in round_data["choice"]:
|
|
var new_choice=MULTI_INDETIFICATION_CHOICE.instantiate()
|
|
%choice_add_pos.add_child(new_choice)
|
|
new_choice.set_text(i)
|
|
new_choice.click.connect(choice_click.bind(i))
|
|
pass
|
|
%identification_attribute_name.text=round_data["identification_name"]
|
|
%identification_value.text=str(round_data["identification_value"])
|
|
# 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
|
|
|
|
|
|
func _on_introduction_visible_pressed() -> void:
|
|
if %introduction_panel.self_modulate.a==1:
|
|
%introduction_btn_texture.texture=BUXIANSHI
|
|
%introduction_panel.self_modulate.a=0
|
|
%introduction_label.hide()
|
|
%introduction_title.hide()
|
|
else:
|
|
%introduction_btn_texture.texture=XIANSHI
|
|
%introduction_panel.self_modulate.a=1
|
|
%introduction_label.show()
|
|
%introduction_title.show()
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_result_button_pressed() -> void:
|
|
if %result_panel.self_modulate.a==1:
|
|
%result_panel.self_modulate.a=0
|
|
%result_btn_texture.texture=BUXIANSHI
|
|
for i in result_hide_group:
|
|
i.hide()
|
|
else:
|
|
%result_panel.self_modulate.a=1
|
|
%result_btn_texture.texture=XIANSHI
|
|
for i in result_hide_group:
|
|
i.show()
|
|
pass # Replace with function body.
|
|
var is_finish:bool=false
|
|
#结束信号
|
|
signal finish
|
|
func choice_click(choice:String):
|
|
if not is_finish:
|
|
var is_success:bool=Global.call_round_triger(round_data["triger"][0],character_data,round_data,choice)
|
|
%AnimationPlayer.play("show_text")
|
|
var finish=Global.call_is_finish_triger(round_data["triger"][2],character_data,round_data)
|
|
if finish:
|
|
is_finish=finish
|
|
round_data["choice"]=["退出"]
|
|
|
|
round_data_update()
|
|
if is_success:
|
|
%result_label.add_theme_color_override("font_color",Color.GREEN)
|
|
%result_label.text="成功"
|
|
else:
|
|
%result_label.add_theme_color_override("font_color",Color.RED)
|
|
%result_label.text="失败"
|
|
|
|
else:
|
|
self.hide()
|
|
Global.call_finish_triger(round_data["triger"][3],character_data,round_data)
|
|
finish.emit()
|