tweaked vending machine and added on off to boombox
This commit is contained in:
@@ -9,7 +9,7 @@ var ammo_current = [0,0]
|
||||
var ammo_reserve = [0,0]
|
||||
var guns_dict = {}
|
||||
var current_gun_index
|
||||
var money = 0
|
||||
var money = 250
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
28
scripts/boombox.gd
Normal file
28
scripts/boombox.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var broken_object : Resource
|
||||
@onready var music = $Music/AudioStreamPlayer3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func interact():
|
||||
if music.is_playing():
|
||||
music.stop()
|
||||
else:
|
||||
music.play()
|
||||
|
||||
func breaking(current_velocity):
|
||||
var spawn_broken = broken_object.instantiate()
|
||||
spawn_broken.position = global_position
|
||||
spawn_broken.transform.basis = global_transform.basis
|
||||
spawn_broken.rotation = rotation
|
||||
|
||||
get_tree().get_root().add_child(spawn_broken)
|
||||
queue_free()
|
||||
@@ -17,14 +17,16 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
if active == false:
|
||||
while item_price > 0:
|
||||
item_price = lerp(int(item_price),int(0),delta * .01)
|
||||
label_3d.text = "$" + str(item_price)
|
||||
|
||||
func interact():
|
||||
if active == true:
|
||||
if level_control.money >= item_price:
|
||||
level_control.money -= item_price
|
||||
anim_player.play("vend")
|
||||
#label_3d.text = str(lerp(item_price,0,delta))
|
||||
else:
|
||||
pass #add "too poor" text here
|
||||
|
||||
@@ -32,6 +34,6 @@ func vend():
|
||||
var item_vend = item.instantiate()
|
||||
item_vend.position = vend_ray.global_position
|
||||
item_vend.transform.basis = vend_ray.global_transform.basis
|
||||
item_vend.linear_velocity += vend_ray.global_transform.basis * Vector3(0,0,10)
|
||||
item_vend.linear_velocity += vend_ray.global_transform.basis * Vector3(0,0,3)
|
||||
active = false
|
||||
get_parent().add_child(item_vend)
|
||||
|
||||
Reference in New Issue
Block a user