2024-10-25 15:41:39 +08:00
|
|
|
|
extends Node
|
2024-11-01 23:23:07 +08:00
|
|
|
|
|
|
|
|
|
var main_scene:MainScene
|
|
|
|
|
|
2024-10-25 15:41:39 +08:00
|
|
|
|
#保存ID对应角色实例的字典
|
|
|
|
|
var unit_instance_dic:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#可交互物品/建筑的类型:Array字典
|
|
|
|
|
var item_type_dic_arr:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#设置对象实例
|
|
|
|
|
func set_unit_instance(id:String,instance:Node):
|
|
|
|
|
if unit_instance_dic.has(id):
|
|
|
|
|
var before_instance=unit_instance_dic[id]
|
|
|
|
|
if is_instance_valid(before_instance):
|
|
|
|
|
before_instance.queue_free()
|
|
|
|
|
unit_instance_dic[id]=instance
|
|
|
|
|
#获取对象实例
|
|
|
|
|
func get_unit_instance(id:String):
|
|
|
|
|
if unit_instance_dic.has(id) and is_instance_valid(unit_instance_dic[id]):
|
2024-10-28 19:24:10 +08:00
|
|
|
|
|
2024-10-25 15:41:39 +08:00
|
|
|
|
return unit_instance_dic[id]
|
|
|
|
|
else:
|
|
|
|
|
return null
|
2024-10-25 17:45:08 +08:00
|
|
|
|
func delete_unit_instance(id:String):
|
|
|
|
|
unit_instance_dic.erase(id)
|
|
|
|
|
|
|
|
|
|
pass
|
2024-10-25 15:41:39 +08:00
|
|
|
|
#单位好感度字典
|
|
|
|
|
var unit_favour_dic:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#获取与对应单位的好感度,如果不存在则根据双方族群自动创建初始好感
|
|
|
|
|
func get_unit_favour(self_id:String,other_id:String):
|
|
|
|
|
|
|
|
|
|
if not unit_favour_dic.has(self_id):
|
|
|
|
|
var favour=Database.get_init_favour(get_unit_instance(self_id).unit_type,get_unit_instance(other_id).unit_type)
|
|
|
|
|
unit_favour_dic[self_id]={other_id:favour}
|
|
|
|
|
return favour
|
|
|
|
|
elif not unit_favour_dic[self_id].has(other_id):
|
|
|
|
|
var favour=Database.get_init_favour(get_unit_instance(self_id).unit_type,get_unit_instance(other_id).unit_type)
|
|
|
|
|
unit_favour_dic[self_id][other_id]=favour
|
|
|
|
|
return favour
|
|
|
|
|
else:
|
|
|
|
|
return unit_favour_dic[self_id][other_id]
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
#设置好感度
|
|
|
|
|
func set_unit_favour(self_id:String,other_id:String,favour:float):
|
|
|
|
|
if not unit_favour_dic.has(self_id):
|
|
|
|
|
unit_favour_dic[self_id]={other_id:favour}
|
|
|
|
|
else:
|
|
|
|
|
unit_favour_dic[self_id][other_id]=favour
|
2024-10-28 19:24:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var now_map_id:String="default"
|
|
|
|
|
var map_dictionary:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#当前地图是否已经初始化
|
|
|
|
|
func is_map_initlized(map_id:String):
|
|
|
|
|
return map_dictionary.has(map_id)
|
|
|
|
|
|
|
|
|
|
func add_unit_id_save_map(unit_data:Dictionary):
|
|
|
|
|
if not unit_data.has("map"):
|
|
|
|
|
return
|
|
|
|
|
var map_id=unit_data["map"]
|
|
|
|
|
if map_id=="default":
|
|
|
|
|
return
|
|
|
|
|
var unit_id=unit_data["unit_id"]
|
|
|
|
|
if map_dictionary.has(map_id):
|
|
|
|
|
map_dictionary[map_id][unit_id]=unit_data
|
|
|
|
|
else:
|
|
|
|
|
map_dictionary[map_id]={
|
|
|
|
|
unit_id:unit_data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#获取地图中的存储角色数据
|
|
|
|
|
func get_map_data(map_id:String):
|
|
|
|
|
return map_dictionary[map_id]
|
2024-10-30 19:54:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var now_player_data:Dictionary={
|
|
|
|
|
|
|
|
|
|
}
|