2024-09-19 12:04:52 +08:00
|
|
|
extends Node
|
|
|
|
#全局数据json的加载
|
|
|
|
var texture_json_path:String="res://json/texture.json"
|
|
|
|
var texture_data:Dictionary
|
|
|
|
var card_json_path:String="res://json/card.json"
|
|
|
|
var card_data:Dictionary
|
|
|
|
var script_json_path:String="res://json/script.json"
|
|
|
|
var script_data:Dictionary
|
|
|
|
var script_type_divide_data:Array=[]
|
|
|
|
var event_json_path:String="res://json/event.json"
|
|
|
|
var event_data:Dictionary
|
|
|
|
var scene_json_path:String="res://json/scene.json"
|
|
|
|
var scene_data:Dictionary
|
2024-09-19 17:56:05 +08:00
|
|
|
var character_json_path:String="res://json/character.json"
|
|
|
|
var character_data:Dictionary
|
|
|
|
var system_config_data:Dictionary={
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var now_game_data:Dictionary={
|
|
|
|
"time":99999
|
|
|
|
}
|
2024-09-19 12:04:52 +08:00
|
|
|
func _ready() -> void:
|
|
|
|
load_texture_data()
|
|
|
|
load_script_data()
|
|
|
|
load_event_data()
|
|
|
|
load_scene_data()
|
2024-09-19 17:56:05 +08:00
|
|
|
load_character_data()
|
2024-09-19 12:04:52 +08:00
|
|
|
func load_texture_data():
|
|
|
|
var file=FileAccess.open(texture_json_path,FileAccess.READ)
|
|
|
|
var str=file.get_as_text()
|
|
|
|
var dictionary:Dictionary=JSON.parse_string(str)
|
|
|
|
for i in dictionary.keys():
|
|
|
|
var texture=load(dictionary[i])
|
|
|
|
if texture is Texture2D:
|
|
|
|
dictionary[i]=texture
|
|
|
|
texture_data=dictionary
|
|
|
|
func load_script_data():
|
|
|
|
var file=FileAccess.open(script_json_path,FileAccess.READ)
|
|
|
|
var str=file.get_as_text()
|
|
|
|
var dictionary:Dictionary=JSON.parse_string(str)
|
|
|
|
script_type_divide_data=[{},{},{},{}]
|
|
|
|
for i in dictionary.keys():
|
|
|
|
dictionary[i]["id"]=i
|
|
|
|
var data=dictionary[i]
|
|
|
|
if data.has("type"):
|
|
|
|
var type:int=int(data["type"])
|
|
|
|
script_type_divide_data[type][i]=data
|
|
|
|
script_data=dictionary
|
|
|
|
func load_event_data():
|
|
|
|
var file=FileAccess.open(event_json_path,FileAccess.READ)
|
|
|
|
var str=file.get_as_text()
|
|
|
|
var dictionary:Dictionary=JSON.parse_string(str)
|
|
|
|
for i in dictionary.keys():
|
|
|
|
dictionary[i]["id"]=i
|
|
|
|
event_data=dictionary
|
|
|
|
func load_scene_data():
|
|
|
|
var file=FileAccess.open(scene_json_path,FileAccess.READ)
|
|
|
|
var str=file.get_as_text()
|
|
|
|
var dictionary:Dictionary=JSON.parse_string(str)
|
|
|
|
for i in dictionary.keys():
|
|
|
|
dictionary[i]["id"]=i
|
|
|
|
scene_data=dictionary
|
|
|
|
pass
|
2024-09-19 17:56:05 +08:00
|
|
|
func load_character_data():
|
|
|
|
var file=FileAccess.open(character_json_path,FileAccess.READ)
|
|
|
|
var str=file.get_as_text()
|
|
|
|
var dictionary:Dictionary=JSON.parse_string(str)
|
|
|
|
for i in dictionary.keys():
|
|
|
|
dictionary[i]["id"]=i
|
|
|
|
character_data=dictionary
|
2024-09-19 12:04:52 +08:00
|
|
|
func get_texture(id:String):
|
|
|
|
if texture_data.has(id):
|
|
|
|
return texture_data[id]
|
|
|
|
else:
|
|
|
|
return null
|
|
|
|
|
|
|
|
func get_script_data(id:String):
|
|
|
|
if script_data.has(id):
|
|
|
|
var dictionary:Dictionary=script_data[id]
|
|
|
|
return dictionary.duplicate()
|
|
|
|
else:
|
|
|
|
return null
|
|
|
|
func get_all_script_data():
|
|
|
|
return script_type_divide_data.duplicate()
|
|
|
|
func get_event_data(id:String):
|
|
|
|
if event_data.has(id):
|
|
|
|
var dictionary:Dictionary=event_data[id]
|
|
|
|
return dictionary.duplicate()
|
|
|
|
else:
|
|
|
|
return null
|
|
|
|
func get_scene_data(id:String):
|
|
|
|
if scene_data.has(id):
|
|
|
|
var dictionary:Dictionary=scene_data[id]
|
|
|
|
return dictionary.duplicate()
|
|
|
|
else:
|
|
|
|
return null
|
2024-09-19 17:56:05 +08:00
|
|
|
func get_character_data(id:String):
|
|
|
|
if character_data.has(id):
|
|
|
|
var dictionary:Dictionary=scene_data[id]
|
|
|
|
return dictionary.duplicate()
|
|
|
|
else:
|
|
|
|
return null
|