202 lines
5.9 KiB
GDScript
202 lines
5.9 KiB
GDScript
extends Control
|
|
class_name GameFlow
|
|
@onready var back: TextureRect = $back
|
|
@onready var event: HBoxContainer = $bottom_container/event
|
|
@onready var place_add: VBoxContainer = $place_add
|
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
|
@onready var animation_mask: ColorRect = $animation_mask
|
|
@onready var character_texture: TextureRect = $hbox/TextureRect/TextureRect/character_texture
|
|
@onready var event_panel: Control = $event_panel
|
|
@onready var character_name: Label = $hbox/TextureRect2/vbox/HBoxContainer/character_name
|
|
@onready var map: Control = $map
|
|
@onready var touch_add_pos: Control = $touch_add_pos
|
|
|
|
const GAME_FLOW_TOUCH = preload("res://scene/game_flow_touch.tscn")
|
|
|
|
const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn")
|
|
const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn")
|
|
var scene_data:Dictionary
|
|
func _ready() -> void:
|
|
Global.scene_explore_changed.connect(explore_update)
|
|
#get_window().size=Vector2i(2560,1440)
|
|
if Global.is_script_finish():
|
|
%points_settlement.show()
|
|
%points_settlement.show_mes({})
|
|
set_scene(Global.get_now_scene())
|
|
update_date()
|
|
Global.time_changed.connect(update_date)
|
|
Global.now_game_flow=self
|
|
var character_data=Global.get_now_character_data()
|
|
character_texture.texture=Database.get_texture(CharacterTool.get_head(character_data))
|
|
character_name.text=CharacterTool.get_character_name(character_data)
|
|
update_game_currency()
|
|
Global.game_currency_changed.connect(update_game_currency)
|
|
func set_scene(id:String):
|
|
scene_data=Database.get_scene_data(id)
|
|
back.texture=Database.get_texture(scene_data["texture"])
|
|
for i in event.get_children():
|
|
i.queue_free()
|
|
for i in place_add.get_children():
|
|
i.queue_free()
|
|
for i in touch_add_pos.get_children():
|
|
i.queue_free()
|
|
for i in scene_data["quick_event"]:
|
|
var new_btn=GAME_FLOW_EVENT.instantiate()
|
|
event.add_child(new_btn)
|
|
new_btn.set_data(i)
|
|
new_btn.pressed.connect(show_event)
|
|
for i in scene_data["linked_scene"]:
|
|
var new_place=GAME_FLOW_PLACE.instantiate()
|
|
place_add.add_child(new_place)
|
|
new_place.set_data(i)
|
|
new_place.pressed.connect(place_pressed)
|
|
pass
|
|
if scene_data.has("touch"):
|
|
var touch_data:Dictionary=scene_data["touch"].duplicate()
|
|
for i in touch_data.keys():
|
|
var new_touch=GAME_FLOW_TOUCH.instantiate()
|
|
touch_add_pos.add_child(new_touch)
|
|
touch_data[i]["scene_id"]=id
|
|
touch_data[i]["name"]=i
|
|
new_touch.set_data(touch_data[i])
|
|
new_touch.judge()
|
|
#更新探索度
|
|
explore_update(id)
|
|
#判断是否判断进入事件
|
|
try_init_event()
|
|
|
|
func judge_touch():
|
|
for i in touch_add_pos.get_children():
|
|
i.judge()
|
|
#交互点按下触发,传入交互点的字典数据(暂未实现)
|
|
func touch_click(data:Dictionary):
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
func update_date():
|
|
Global.judge_clock_event()
|
|
var time_dic=Global.get_time_dictionary()
|
|
%date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"])
|
|
|
|
%time.text="%02d:%02d"%[time_dic["hour"],time_dic["minute"]]
|
|
|
|
judge_touch()
|
|
if Global.is_script_finish():
|
|
%points_settlement.show()
|
|
%points_settlement.show_mes({})
|
|
func place_pressed(data:Dictionary):
|
|
|
|
Global.move_scene(data["id"],data["distance"])
|
|
func change_scene(scene_id:String,distance:float):
|
|
|
|
animation_mask.show()
|
|
animation_player.play("change")
|
|
await animation_player.animation_finished
|
|
set_scene(scene_id)
|
|
await get_tree().create_timer(0.2).timeout
|
|
animation_player.play_backwards("change")
|
|
await animation_player.animation_finished
|
|
animation_mask.hide()
|
|
pass
|
|
func show_event(event_id:String):
|
|
event_panel.show()
|
|
event_panel.set_event_data(event_id)
|
|
pass
|
|
|
|
|
|
func _on_map_pressed() -> void:
|
|
map.set_map(scene_data["map"])
|
|
map.modulate.a=0
|
|
var t=get_tree().create_tween()
|
|
t.tween_property(map,"modulate:a",1,0.2)
|
|
map.show()
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_head_btn_pressed() -> void:
|
|
%basic_mes.data=Global.get_now_character_data()
|
|
%basic_mes.init_from_data()
|
|
%basic_mes.show()
|
|
pass # Replace with function body.
|
|
|
|
func update_game_currency():
|
|
%jinqian.text=str(Global.get_currency_game(1))
|
|
%shengming.text=str(Global.get_currency_game(0))
|
|
%jingshen.text=str(Global.get_currency_game(2))
|
|
#显示交易
|
|
func show_trade(NPC_id:String):
|
|
%trade.set_data(NPC_id)
|
|
%trade.show()
|
|
|
|
|
|
func _on_save_pressed() -> void:
|
|
%save_and_load.show()
|
|
%save_and_load.fresh()
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_load_pressed() -> void:
|
|
pass # Replace with function body.
|
|
#显示对应id的鉴定事件
|
|
func show_identification(id:String,success_triger:Array=[],fail_triger:Array=[]):
|
|
%identification.show()
|
|
var indetification=Database.get_identifation_data(id)
|
|
%identification.set_data(indetification)
|
|
%identification.judge_success_triger=success_triger
|
|
%identification.judge_fail_trigtr=fail_triger
|
|
pass
|
|
|
|
func show_auction(npc_id_array:Array,item_id_array:Array):
|
|
%auction.show()
|
|
await get_tree().process_frame
|
|
await get_tree().process_frame
|
|
var npc_data_arr:Array=[]
|
|
var item_data_arr:Array=[]
|
|
for i in npc_id_array:
|
|
var npc_data=Global.get_now_game_npc_data(i)
|
|
npc_data_arr.append(npc_data)
|
|
for i in item_id_array:
|
|
var item_data=Database.get_item_data(i)
|
|
item_data_arr.append(item_data)
|
|
%auction.set_npc_arr_and_item_arr(npc_data_arr,item_data_arr)
|
|
|
|
func show_item_level_up():
|
|
|
|
%item_level_up.show()
|
|
%item_level_up.fresh()
|
|
pass
|
|
|
|
func show_warehouse():
|
|
%warehouse.show()
|
|
%warehouse.fresh()
|
|
|
|
func show_make_card():
|
|
%ability_to_cards.show()
|
|
%ability_to_cards.fresh()
|
|
|
|
|
|
pass
|
|
#检测当前是否应该展示初始事件,如果是,则展示事件并记录
|
|
func try_init_event():
|
|
if Global.should_show_init_event():
|
|
var init_event=Global.get_init_event()
|
|
show_event(init_event)
|
|
Global.shown_init_event()
|
|
|
|
#探索度改变触发,用来连接信号,更新UI
|
|
func explore_update(scene_id:String):
|
|
%explore_percent.text=str(Global.get_scene_explore(scene_data["id"]))+"%"
|
|
|
|
|
|
pass
|
|
#刷新互动点条件
|
|
func refresh_scene_touch():
|
|
for i in touch_add_pos.get_children():
|
|
i.judge()
|
|
|
|
pass
|