37 lines
804 B
GDScript
37 lines
804 B
GDScript
tool
|
|
extends Sprite
|
|
|
|
class_name GemSprite
|
|
|
|
# 宝石颜色
|
|
enum GemColor { Blue,Red }
|
|
|
|
export(GemColor) var gem_color setget set_gem_color
|
|
|
|
# 上升属性值
|
|
export var up_value : int = 1
|
|
|
|
func _init():
|
|
self.texture = load("res://images/mota.png")
|
|
self.region_enabled = true
|
|
|
|
func set_gem_color(value):
|
|
gem_color = value
|
|
match value:
|
|
GemColor.Blue:
|
|
region_rect = Rect2(128,384,32,32)
|
|
GemColor.Red:
|
|
region_rect = Rect2(96,384,32,32)
|
|
|
|
func _on_Area2D_body_entered(body):
|
|
match gem_color:
|
|
GemColor.Blue:
|
|
GameArchiveManager.player_info.def += up_value
|
|
GameArchiveManager.update_def_view()
|
|
GemColor.Red:
|
|
GameArchiveManager.player_info.atk += up_value
|
|
GameArchiveManager.update_atk_view()
|
|
AffectAudioPlayer.play_item()
|
|
queue_free()
|
|
GameArchiveManager.add_used_item(get_path())
|