2024-09-19 12:04:52 +08:00
|
|
|
extends Control
|
2024-09-21 11:52:44 +08:00
|
|
|
class_name GameFlow
|
2024-09-19 12:04:52 +08:00
|
|
|
@onready var back: TextureRect = $back
|
|
|
|
@onready var event: HBoxContainer = $bottom_container/event
|
2024-09-20 20:20:14 +08:00
|
|
|
@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
|
2024-09-21 11:52:44 +08:00
|
|
|
@onready var character_name: Label = $hbox/TextureRect2/vbox/HBoxContainer/character_name
|
2024-09-20 20:20:14 +08:00
|
|
|
|
2024-09-19 12:04:52 +08:00
|
|
|
const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn")
|
2024-09-20 20:20:14 +08:00
|
|
|
const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn")
|
2024-09-19 12:04:52 +08:00
|
|
|
var scene_data:Dictionary
|
|
|
|
func _ready() -> void:
|
|
|
|
set_scene("scene_01")
|
2024-09-21 11:52:44 +08:00
|
|
|
Global.now_game_flow=self
|
2024-09-20 20:20:14 +08:00
|
|
|
var character_data=Global.get_now_character_data()
|
|
|
|
character_texture.texture=Global.get_texture(character_data["character"]["skin"][character_data["character"]["skin_now_use"]]["card_face"])
|
2024-09-21 11:52:44 +08:00
|
|
|
character_name.text=character_data["character"]["name"]
|
2024-09-19 12:04:52 +08:00
|
|
|
func set_scene(id:String):
|
|
|
|
scene_data=Global.get_scene_data(id)
|
|
|
|
back.texture=Global.get_texture(scene_data["texture"])
|
|
|
|
for i in event.get_children():
|
|
|
|
i.queue_free()
|
2024-09-20 20:20:14 +08:00
|
|
|
for i in place_add.get_children():
|
|
|
|
i.queue_free()
|
2024-09-19 12:04:52 +08:00
|
|
|
for i in scene_data["quick_event"]:
|
|
|
|
var new_btn=GAME_FLOW_EVENT.instantiate()
|
|
|
|
event.add_child(new_btn)
|
|
|
|
new_btn.set_data(i)
|
2024-09-20 20:20:14 +08:00
|
|
|
new_btn.pressed.connect(event_pressed)
|
|
|
|
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
|
|
|
|
pass
|
|
|
|
|
|
|
|
func place_pressed(data:Dictionary):
|
|
|
|
animation_mask.show()
|
|
|
|
animation_player.play("change")
|
|
|
|
await animation_player.animation_finished
|
|
|
|
set_scene(data["id"])
|
|
|
|
await get_tree().create_timer(0.2).timeout
|
|
|
|
animation_player.play_backwards("change")
|
|
|
|
await animation_player.animation_finished
|
|
|
|
animation_mask.hide()
|
|
|
|
pass
|
|
|
|
func event_pressed(event_data:Dictionary):
|
|
|
|
event_panel.show()
|
|
|
|
event_panel.set_event_data(event_data["event"])
|
2024-09-19 12:04:52 +08:00
|
|
|
pass
|