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 19:59:12 +02:00
|
|
|
export var PICKUPTRESHOLD = 100
|
2021-06-12 02:05:15 +02:00
|
|
|
export var destinationColor = Color.yellow
|
2021-06-12 21:54:29 +02:00
|
|
|
var pickup_time
|
|
|
|
|
2021-06-12 02:05:15 +02:00
|
|
|
signal picked_up(color,name)
|
|
|
|
signal dropped_off_success
|
|
|
|
signal dropped_off_idle
|
|
|
|
signal dropped_off_fail
|
2021-06-12 21:54:29 +02:00
|
|
|
|
2021-06-12 02:05:15 +02:00
|
|
|
var rng = RandomNumberGenerator.new()
|
|
|
|
onready var sprite = $Sprite
|
2021-06-12 18:59:42 +02:00
|
|
|
onready var exclusionZoneShape = $ExclusionZone/CollisionShape2D
|
2021-06-12 02:05:15 +02:00
|
|
|
|
2021-06-12 23:28:26 +02:00
|
|
|
enum states {
|
|
|
|
waiting,
|
|
|
|
tethered
|
|
|
|
}
|
2021-06-12 02:05:15 +02:00
|
|
|
var colorList = [
|
|
|
|
Color.yellow,
|
|
|
|
Color.violet,
|
|
|
|
Color.red,
|
|
|
|
Color.turquoise,
|
|
|
|
Color.orange
|
|
|
|
]
|
2021-06-12 23:28:26 +02:00
|
|
|
var names = [
|
|
|
|
'Dieter',
|
|
|
|
'Peter',
|
|
|
|
'Gabi',
|
|
|
|
'Ursula',
|
|
|
|
'Manni',
|
|
|
|
'Karl',
|
|
|
|
'Christa',
|
|
|
|
'Britta'
|
|
|
|
]
|
|
|
|
var currentState = states.waiting
|
2021-06-12 02:05:15 +02:00
|
|
|
|
2021-06-12 23:28:26 +02:00
|
|
|
func _physics_process(delta):
|
|
|
|
linear_velocity = linear_velocity.clamped(100)
|
|
|
|
if currentState == states.waiting:
|
|
|
|
linear_velocity.move_toward(Vector2.ZERO,5.0)
|
|
|
|
elif currentState == states.tethered:
|
|
|
|
pass
|
2021-06-12 13:39:49 +02:00
|
|
|
|
|
|
|
|
2021-06-12 23:28:26 +02:00
|
|
|
func _ready():
|
2021-06-12 02:05:15 +02:00
|
|
|
rng.randomize()
|
|
|
|
var n = rng.randi_range(0,4)
|
|
|
|
destinationColor = colorList[n]
|
|
|
|
sprite.modulate = destinationColor
|
2021-06-12 23:28:26 +02:00
|
|
|
var m = rng.randi_range(0,names.size()-1)
|
|
|
|
guestName = names[m]
|
2021-06-12 02:05:15 +02:00
|
|
|
|
|
|
|
func _on_PickUpArea_body_entered(body):
|
2021-06-12 02:27:58 +02:00
|
|
|
print(body.name)
|
|
|
|
if body.name == "Playa":
|
2021-06-12 23:28:26 +02:00
|
|
|
|
|
|
|
|
2021-06-12 21:54:29 +02:00
|
|
|
pickup_time = OS.get_system_time_msecs()
|
2021-06-12 23:28:26 +02:00
|
|
|
emit_signal("picked_up",destinationColor,guestName)
|
2021-06-12 02:05:15 +02:00
|
|
|
# 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
|
|
|
|