49 lines
808 B
GDScript
49 lines
808 B
GDScript
class_name BagItem
|
|
#物品数据
|
|
var data:Dictionary={
|
|
|
|
}
|
|
##物品名字
|
|
var item_name:String:
|
|
set(val):
|
|
data["name"]=val
|
|
item_name=val
|
|
get():
|
|
if data.has("name"):
|
|
return str(data["name"])
|
|
else:
|
|
return "无效数据"
|
|
##物品类型
|
|
var item_type:int:
|
|
set(val):
|
|
data["type"]=val
|
|
item_type=val
|
|
get():
|
|
if data.has("type"):
|
|
return int(data["type"])
|
|
else:
|
|
return -1
|
|
##物品介绍
|
|
var item_introduction:String:
|
|
set(val):
|
|
data["introduction"]=val
|
|
item_introduction=val
|
|
get():
|
|
if data.has("introduction"):
|
|
return str(data["introduction"])
|
|
else:
|
|
return "无数据"
|
|
#数量
|
|
var num:int:
|
|
set(val):
|
|
data["num"]=val
|
|
num=val
|
|
get():
|
|
if data.has("num"):
|
|
return int(data["num"])
|
|
else:
|
|
return -1
|
|
|
|
func _init(item_data:Dictionary) -> void:
|
|
self.data=item_data
|