48 lines
1.5 KiB
GDScript
48 lines
1.5 KiB
GDScript
extends Node
|
||
#保存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]):
|
||
return unit_instance_dic[id]
|
||
else:
|
||
return null
|
||
#单位好感度字典
|
||
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
|