GMTKJam2021/Guest.gd

58 lines
1.3 KiB
GDScript3
Raw Normal View History

2021-06-12 13:39:49 +02:00
extends RigidBody2D
2021-06-12 02:05:15 +02:00
onready var pickUpArea = $PickUpArea
export var guestName = "Dieter"
2021-06-12 13:39:49 +02:00
export var PICKUPTRESHOLD = 80
2021-06-12 02:05:15 +02:00
export var destinationColor = Color.yellow
signal picked_up(color,name)
signal dropped_off_success
signal dropped_off_idle
signal dropped_off_fail
var rng = RandomNumberGenerator.new()
onready var sprite = $Sprite
var colorList = [
Color.yellow,
Color.violet,
Color.red,
Color.turquoise,
Color.orange
]
# Called when the node enters the scene tree for the first time.
func _ready():
2021-06-12 13:39:49 +02:00
#print(get_tree().get_root().get_node("Playa"))
#connect('picked_up',get_tree().get_nodes_in_group("Player")[0], '_on_Guest_picked_up')
2021-06-12 02:05:15 +02:00
rng.randomize()
var n = rng.randi_range(0,4)
2021-06-12 13:39:49 +02:00
#print(n)
2021-06-12 02:05:15 +02:00
destinationColor = colorList[n]
2021-06-12 13:39:49 +02:00
#print(destinationColor)
2021-06-12 02:05:15 +02:00
sprite.modulate = destinationColor
pass # Replace with function body.
func _on_PickUpArea_body_entered(body):
2021-06-12 02:27:58 +02:00
print(body.name)
if body.name == "Playa":
2021-06-12 13:39:49 +02:00
print(body.velocity.length())
if body.velocity.length() <= PICKUPTRESHOLD:
2021-06-12 02:05:15 +02:00
emit_signal("picked_up",destinationColor,guestName)
# start pickup process
# we are being picked up by the player
pass
func _on_PickUpArea_area_entered(area):
if area.name == "DROPOFF":
if area.destinationColor == destinationColor:
emit_signal("dropped_off_success")
else:
emit_signal("dropped_off_fail")
2021-06-12 02:27:58 +02:00