1
0
mirror of https://github.com/mightypanders/GMTKJam2021.git synced 2025-02-24 15:39:55 +01:00
GMTKJam2021/Guest.gd
magnetotail eeda21349e Introduced max number of tries for guest spawning.
Also spawn zone now adjustable by exclusionzone size
2021-06-12 18:59:42 +02:00

55 lines
1.3 KiB
GDScript

extends KinematicBody2D
onready var pickUpArea = $PickUpArea
export var guestName = "Dieter"
export var PICKUPTRESHOLD = 5
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
onready var exclusionZoneShape = $ExclusionZone/CollisionShape2D
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():
rng.randomize()
var n = rng.randi_range(0,4)
print(n)
destinationColor = colorList[n]
print(destinationColor)
sprite.modulate = destinationColor
pass # Replace with function body.
func _on_PickUpArea_body_entered(body):
print(body.name)
if body.name == "Playa":
print(body.velocity)
if body.velocity.x >= PICKUPTRESHOLD and body.velocity.y >= PICKUPTRESHOLD:
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")