2024-10-04 18:08:33 +08:00
|
|
|
|
extends Node
|
|
|
|
|
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
|
|
|
|
|
var character_json_path:String="res://json/character.json"
|
|
|
|
|
var character_data:Dictionary
|
|
|
|
|
var map_json_path:String="res://json/map.json"
|
|
|
|
|
var map_data:Dictionary
|
|
|
|
|
|
|
|
|
|
var item_json_path:String="res://json/item.json"
|
|
|
|
|
var item_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var npc_json_path:String="res://json/npc.json"
|
|
|
|
|
var npc_data:Dictionary
|
|
|
|
|
|
|
|
|
|
var word_json_path:String="res://json/word.json"
|
|
|
|
|
var word_data:Dictionary
|
|
|
|
|
|
2024-10-05 18:44:58 +08:00
|
|
|
|
var identifation_json_path:String="res://json/indetification.json"
|
|
|
|
|
var identifation_data:Dictionary
|
|
|
|
|
|
2024-10-04 18:08:33 +08:00
|
|
|
|
#角色修饰数据的存储路径
|
|
|
|
|
var character_embellish_data_path:String="user://emblish.data"
|
|
|
|
|
var character_embellish_data:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#加载角色修饰数据(没有则自动创建文件
|
|
|
|
|
func load_character_emblish_data():
|
|
|
|
|
var f=FileAccess.open(character_embellish_data_path,FileAccess.READ)
|
|
|
|
|
if f!=null:
|
|
|
|
|
var data=f.get_var()
|
|
|
|
|
if data is Dictionary:
|
|
|
|
|
character_embellish_data=data.duplicate()
|
|
|
|
|
f.close()
|
|
|
|
|
else:
|
|
|
|
|
f=FileAccess.open(character_embellish_data_path,FileAccess.WRITE)
|
|
|
|
|
f.store_var(character_embellish_data)
|
|
|
|
|
f.close()
|
|
|
|
|
#存储角色修饰数据
|
|
|
|
|
func save_character_embellish_data():
|
|
|
|
|
var f=FileAccess.open(character_embellish_data_path,FileAccess.WRITE)
|
|
|
|
|
f.store_var(character_embellish_data)
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
#添加角色修饰数据
|
|
|
|
|
func add_character_embellich_data(character_id:String,embellish_name:String,data):
|
|
|
|
|
if character_embellish_data.has(character_id):
|
|
|
|
|
character_embellish_data[character_id][embellish_name]=data
|
|
|
|
|
else:
|
|
|
|
|
character_embellish_data[character_id]={
|
|
|
|
|
embellish_name:data
|
|
|
|
|
}
|
|
|
|
|
save_character_embellish_data()
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
load_texture_data()
|
|
|
|
|
load_script_data()
|
|
|
|
|
load_event_data()
|
|
|
|
|
load_scene_data()
|
|
|
|
|
load_card_data()
|
|
|
|
|
load_character_data()
|
|
|
|
|
load_map_data()
|
|
|
|
|
load_npc_data()
|
|
|
|
|
load_character_emblish_data()
|
|
|
|
|
load_item_data()
|
|
|
|
|
load_word_data()
|
2024-10-05 18:44:58 +08:00
|
|
|
|
load_identifation_data()
|
2024-10-04 18:08:33 +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
|
|
|
|
|
#加载当前角色数据(未被修饰)
|
|
|
|
|
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
|
|
|
|
|
#预处理
|
|
|
|
|
dictionary[i]=CharacterTool.pre_process_character_data(dictionary[i])
|
|
|
|
|
character_data=dictionary
|
|
|
|
|
#加载当前地图字典
|
|
|
|
|
func load_map_data():
|
|
|
|
|
var file=FileAccess.open(map_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
|
|
|
|
|
map_data=dictionary
|
|
|
|
|
#加载当前NPC数据(可能废弃)
|
|
|
|
|
func load_npc_data():
|
|
|
|
|
var file=FileAccess.open(npc_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
|
|
|
|
|
npc_data=dictionary
|
|
|
|
|
#加载当前卡牌数据
|
|
|
|
|
func load_card_data():
|
|
|
|
|
var file=FileAccess.open(card_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
|
|
|
|
|
card_data=dictionary
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
func load_item_data():
|
|
|
|
|
var file=FileAccess.open(item_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
|
|
|
|
|
item_data=dictionary
|
|
|
|
|
#加载词条数据
|
|
|
|
|
func load_word_data():
|
|
|
|
|
var file=FileAccess.open(word_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
|
|
|
|
|
word_data=dictionary
|
2024-10-05 18:44:58 +08:00
|
|
|
|
#加载鉴定时间数据
|
|
|
|
|
func load_identifation_data():
|
|
|
|
|
var file=FileAccess.open(identifation_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
|
|
|
|
|
identifation_data=dictionary
|
|
|
|
|
pass
|
|
|
|
|
|
2024-10-04 18:08:33 +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(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取全部剧本数据,数组
|
|
|
|
|
func get_all_script_data():
|
|
|
|
|
return script_type_divide_data.duplicate()
|
|
|
|
|
#获取对应ID的事件数据
|
|
|
|
|
func get_event_data(id:String):
|
|
|
|
|
if event_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=event_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取对应ID的场景数据
|
|
|
|
|
func get_scene_data(id:String):
|
|
|
|
|
if scene_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=scene_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取对应ID的场景字符串
|
|
|
|
|
func get_scene_name(id:String)->String:
|
|
|
|
|
if scene_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=scene_data[id]
|
|
|
|
|
return dictionary["name"]
|
|
|
|
|
else:
|
|
|
|
|
return "未定义场景"
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
#获取对应ID的角色数据
|
|
|
|
|
func get_character_data(id:String):
|
|
|
|
|
if character_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=character_data[id].duplicate(true)
|
|
|
|
|
#如果有修饰数据,则返回修饰后的数据
|
|
|
|
|
if character_embellish_data.has(id):
|
|
|
|
|
dictionary=CharacterTool.character_embellish(dictionary,character_embellish_data[id])
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取全部角色数据
|
|
|
|
|
func get_all_character()->Dictionary:
|
|
|
|
|
var all_character:Dictionary=character_data.duplicate(true)
|
|
|
|
|
#修饰数据
|
|
|
|
|
for i in all_character.keys():
|
|
|
|
|
if character_embellish_data.has(i):
|
|
|
|
|
all_character[i]=CharacterTool.character_embellish(all_character[i],character_embellish_data[i])
|
|
|
|
|
return all_character
|
|
|
|
|
#获取对应ID的地图数据
|
|
|
|
|
func get_map_data(id:String):
|
|
|
|
|
if map_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=map_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
pass
|
|
|
|
|
#获取NPC数据
|
|
|
|
|
func get_npc_data(id:String):
|
|
|
|
|
if npc_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=npc_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
pass
|
|
|
|
|
#获取NPC名字
|
|
|
|
|
func get_npc_name(id:String):
|
|
|
|
|
if npc_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=npc_data[id]
|
|
|
|
|
if dictionary.has("name"):
|
|
|
|
|
return dictionary["name"]
|
|
|
|
|
else:
|
|
|
|
|
return "未命名"
|
|
|
|
|
else:
|
|
|
|
|
return "未知"
|
|
|
|
|
pass
|
|
|
|
|
#获取对应ID的卡牌数据
|
|
|
|
|
func get_card_data(id:String):
|
|
|
|
|
if card_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=card_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取物品数据
|
|
|
|
|
func get_item_data(id:String):
|
|
|
|
|
if item_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=item_data[id]
|
|
|
|
|
return ItemTool.re_process_item_data(dictionary)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
#获取词条数据
|
|
|
|
|
func get_word_data(id:String):
|
|
|
|
|
if word_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=word_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
2024-10-05 18:44:58 +08:00
|
|
|
|
#获取鉴定事件相关数据
|
|
|
|
|
func get_identifation_data(id:String):
|
|
|
|
|
if identifation_data.has(id):
|
|
|
|
|
var dictionary:Dictionary=identifation_data[id]
|
|
|
|
|
return dictionary.duplicate(true)
|
|
|
|
|
else:
|
|
|
|
|
return null
|
|
|
|
|
pass
|