You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
661 B
GDScript

extends Node3D
class_name ItemManager
func _ready():
Global.item_mgr = self
SignalManager.level_loading_start.connect(on_level_loading_start)
func on_level_loading_start():
pass
func create_pt(type: Enum.EPtType, value: int, pos: Vector3):
value = randi_range(0.5 * value, 1.5 * value)
var pt_slice: Array[int] = [100, 50, 20, 10, 5, 2, 1]
while value > 0:
for i in pt_slice:
if value < i:
continue
value -= i
_create_pt(type, i, pos)
break
func _create_pt(type: Enum.EPtType, value: int, pos: Vector3):
var pt: PT = ResourceManager.scene_pt.instantiate() as PT
pt.type = type
pt.value = value
add_child(pt)
pt.position = pos