add guest
This commit is contained in:
parent
99388bd9ad
commit
85d7b4b7c1
|
@ -0,0 +1,51 @@
|
|||
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
|
||||
|
||||
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):
|
||||
if body.name =="PLAYER":
|
||||
if body.velocity.x >= PICKUPTRESHOLD or 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")
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/placeholder_white.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Guest.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 6.04475
|
||||
height = 3.32129
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 24.5545
|
||||
|
||||
[node name="Guest" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="PickUpArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickUpArea"]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[connection signal="area_entered" from="PickUpArea" to="." method="_on_PickUpArea_area_entered"]
|
||||
[connection signal="body_entered" from="PickUpArea" to="." method="_on_PickUpArea_body_entered"]
|
Loading…
Reference in New Issue