1
0
mirror of https://gitee.com/freeyz/godot-mota.git synced 2024-12-23 07:59:20 +08:00
godot-mota/scripts/MonsterBook.gd

25 lines
582 B
GDScript3
Raw Normal View History

2020-07-24 14:18:35 +08:00
extends Node
var monster_data : Dictionary
# 根据json文件初始化怪物数据
func _ready():
var file = File.new()
file.open("res://monster.json",File.READ)
var json_result = JSON.parse(file.get_as_text())
if json_result.error != OK:
print(json_result.error_string)
else:
monster_data = json_result.result
file.close()
# 获取所有怪物名称
func get_monsters_name() -> Array:
if monster_data == null:
return []
return monster_data.keys()
# 根据怪物名称获取怪物信息
func get_info_by_name(name:String) -> Dictionary:
return monster_data[name]