mirror of
https://github.com/mightypanders/GMTKJam2021.git
synced 2025-01-30 21:59:55 +01:00
merge main
This commit is contained in:
commit
16cb77fd37
@ -1,6 +1,7 @@
|
|||||||
|
class_name DropOffPoint
|
||||||
extends Node2D
|
extends Node2D
|
||||||
export var destinationColor = Color.yellow
|
export var destinationColor = Color.yellow
|
||||||
onready var sprite = $Sprite
|
onready var sprite = $Sprite
|
||||||
|
|
||||||
func modulate_color():
|
func modulate_color():
|
||||||
sprite.modulate = destinationColor
|
sprite.modulate = destinationColor
|
||||||
|
19
Guest.gd
19
Guest.gd
@ -45,22 +45,29 @@ var follow_node = null
|
|||||||
var follow_guest = null
|
var follow_guest = null
|
||||||
var follow_pos = global_position
|
var follow_pos = global_position
|
||||||
|
|
||||||
|
func set_state(state):
|
||||||
|
if state == states.delivered:
|
||||||
|
pickUpArea.monitorable = false
|
||||||
|
pickUpArea.monitoring = false
|
||||||
|
collision.disabled = true
|
||||||
|
if state == states.waiting:
|
||||||
|
collision.disabled = false
|
||||||
|
mode = RigidBody2D.MODE_KINEMATIC
|
||||||
|
if state == states.tethered:
|
||||||
|
collision.disabled = false
|
||||||
|
mode = RigidBody2D.MODE_STATIC
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if currentState == states.waiting:
|
if currentState == states.waiting:
|
||||||
linear_velocity.move_toward(Vector2.ZERO,5.0)
|
linear_velocity.move_toward(Vector2.ZERO,5.0)
|
||||||
collision.disabled = false
|
collision.disabled = false
|
||||||
elif currentState == states.tethered:
|
elif currentState == states.tethered:
|
||||||
collision.disabled = true
|
|
||||||
mode = RigidBody2D.MODE_STATIC
|
|
||||||
var rot_dir = get_angle_to(follow_pos)
|
var rot_dir = get_angle_to(follow_pos)
|
||||||
rotation += (rot_dir + deg2rad(90))*0.2
|
rotation += (rot_dir + deg2rad(90))*0.2
|
||||||
var distance = follow_pos.distance_to(global_position)
|
var distance = follow_pos.distance_to(global_position)
|
||||||
global_position = follow_pos
|
global_position = follow_pos
|
||||||
pass
|
pass
|
||||||
elif currentState == states.delivered:
|
|
||||||
pickUpArea.monitorable = false
|
|
||||||
pickUpArea.monitoring = false
|
|
||||||
collision.disabled = true
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if delivered != null and OS.get_system_time_msecs() - delivered > 1000:
|
if delivered != null and OS.get_system_time_msecs() - delivered > 1000:
|
||||||
|
10
Playa.gd
10
Playa.gd
@ -109,10 +109,10 @@ func remove_Guests_from_Line(color):
|
|||||||
func _on_PickupCheckArea_area_entered(area):
|
func _on_PickupCheckArea_area_entered(area):
|
||||||
|
|
||||||
if area.get_parent().is_in_group("DropOffPoint"):
|
if area.get_parent().is_in_group("DropOffPoint"):
|
||||||
print("It's a DOP")
|
#print("It's a DOP")
|
||||||
var dop = area.get_parent()
|
var dop = area.get_parent()
|
||||||
var color = dop.destinationColor
|
var color = dop.destinationColor
|
||||||
print(color)
|
#print(color)
|
||||||
last_in_line = remove_Guests_from_Line(color)
|
last_in_line = remove_Guests_from_Line(color)
|
||||||
#drop all guests after first guest.color == DOP.color, also vanish all guests.color == DOP.color
|
#drop all guests after first guest.color == DOP.color, also vanish all guests.color == DOP.color
|
||||||
pass
|
pass
|
||||||
@ -124,10 +124,10 @@ func _on_PickupCheckArea_area_entered(area):
|
|||||||
#print("We already have you in line")
|
#print("We already have you in line")
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print("Area has parent %s" % area.get_parent())
|
#print("Area has parent %s" % area.get_parent())
|
||||||
print("It's a Guest")
|
#print("It's a Guest")
|
||||||
last_in_line = add_Guest_to_Line(last_in_line,area.get_parent())
|
last_in_line = add_Guest_to_Line(last_in_line,area.get_parent())
|
||||||
print(last_in_line)
|
#print(last_in_line)
|
||||||
|
|
||||||
print(guests)
|
print(guests)
|
||||||
|
|
||||||
|
156
World.gd
156
World.gd
@ -1,78 +1,78 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
onready var streets = $Streets
|
onready var streets = $Streets
|
||||||
onready var used_cells = streets.get_used_cells()
|
onready var used_cells = streets.get_used_cells()
|
||||||
onready var guests = $Guests
|
onready var guests = $Guests
|
||||||
onready var money_label = $GUI/HBoxContainer/HBoxContainer2/Money
|
onready var money_label = $GUI/HBoxContainer/HBoxContainer2/Money
|
||||||
onready var dropOffPointListNode = $DropOffPoints
|
onready var dropOffPointListNode = $DropOffPoints
|
||||||
|
|
||||||
export var player_score = 0
|
export var player_score = 0
|
||||||
|
|
||||||
var Guest = load("res://Guest.tscn")
|
var Guest = load("res://Guest.tscn")
|
||||||
|
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
var spawn_tries = 0
|
var spawn_tries = 0
|
||||||
const MAX_SPAWN_TRIES = 50
|
const MAX_SPAWN_TRIES = 50
|
||||||
|
|
||||||
|
|
||||||
onready var radius_guests = guests.get_child(0).exclusionZoneShape.shape.radius * 2
|
onready var radius_guests = guests.get_child(0).exclusionZoneShape.shape.radius * 2
|
||||||
export var max_guests = 10
|
export var max_guests = 10
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
$GUI2/HBoxContainer/Time/Background/Number.text = String(int($GameTime.time_left))
|
$GUI2/HBoxContainer/Time/Background/Number.text = String(int($GameTime.time_left))
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
dropOffPointListNode.set_colors()
|
dropOffPointListNode.set_colors()
|
||||||
rng.randomize()
|
rng.randomize()
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if Input.is_action_just_pressed("ui_cancel"):
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _on_GuestTimer_timeout():
|
func _on_GuestTimer_timeout():
|
||||||
create_new_guest()
|
create_new_guest()
|
||||||
|
|
||||||
|
|
||||||
func create_new_guest():
|
func create_new_guest():
|
||||||
if guests.get_children().size() >= max_guests:
|
if guests.get_children().size() >= max_guests:
|
||||||
return
|
return
|
||||||
|
|
||||||
var position_found = false;
|
var position_found = false;
|
||||||
var new_guest_position
|
var new_guest_position
|
||||||
|
|
||||||
while !position_found:
|
while !position_found:
|
||||||
if spawn_tries >= MAX_SPAWN_TRIES:
|
if spawn_tries >= MAX_SPAWN_TRIES:
|
||||||
#print("Max spawn tries reached!")
|
#print("Max spawn tries reached!")
|
||||||
return
|
return
|
||||||
position_found = true;
|
position_found = true;
|
||||||
var new_guest_cell = used_cells[rng.randi_range(0, used_cells.size()) -1]
|
var new_guest_cell = used_cells[rng.randi_range(0, used_cells.size()) -1]
|
||||||
new_guest_position = streets.map_to_world(new_guest_cell)
|
new_guest_position = streets.map_to_world(new_guest_cell)
|
||||||
|
|
||||||
for guest in guests.get_children():
|
for guest in guests.get_children():
|
||||||
if (new_guest_position - guest.position).length() < radius_guests:
|
if (new_guest_position - guest.position).length() < radius_guests:
|
||||||
position_found = false
|
position_found = false
|
||||||
spawn_tries+=1
|
spawn_tries+=1
|
||||||
break
|
break
|
||||||
|
|
||||||
var new_guest = Guest.instance()
|
var new_guest = Guest.instance()
|
||||||
new_guest.position = new_guest_position;
|
new_guest.position = new_guest_position;
|
||||||
guests.add_child(new_guest)
|
guests.add_child(new_guest)
|
||||||
spawn_tries = 0
|
spawn_tries = 0
|
||||||
|
|
||||||
|
|
||||||
func _on_Playa_scored(value:int):
|
func _on_Playa_scored(value:int):
|
||||||
spawn_tries = 0
|
spawn_tries = 0
|
||||||
player_score += value
|
player_score += value
|
||||||
money_label.update_text(player_score)
|
money_label.update_text(player_score)
|
||||||
|
|
||||||
|
|
||||||
func _on_GameTime_timeout():
|
func _on_GameTime_timeout():
|
||||||
#get_tree().change_scene("res://GameEnd.tscn")
|
#get_tree().change_scene("res://GameEnd.tscn")
|
||||||
var world = get_tree().root.get_node("World")
|
var world = get_tree().root.get_node("World")
|
||||||
var end_screen_resource = load("res://GameEnd.tscn")
|
var end_screen_resource = load("res://GameEnd.tscn")
|
||||||
var end_screen = end_screen_resource.instance()
|
var end_screen = end_screen_resource.instance()
|
||||||
end_screen.score = player_score
|
end_screen.score = player_score
|
||||||
get_tree().root.add_child(end_screen)
|
get_tree().root.add_child(end_screen)
|
||||||
get_tree().root.remove_child(world)
|
get_tree().root.remove_child(world)
|
||||||
world.queue_free()
|
world.queue_free()
|
||||||
|
@ -1481,7 +1481,7 @@ margin_right = 1331.08
|
|||||||
margin_bottom = 74.3368
|
margin_bottom = 74.3368
|
||||||
|
|
||||||
[node name="GameTime" type="Timer" parent="."]
|
[node name="GameTime" type="Timer" parent="."]
|
||||||
wait_time = 35.853
|
wait_time = 120.0
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="GUI2" parent="." instance=ExtResource( 41 )]
|
[node name="GUI2" parent="." instance=ExtResource( 41 )]
|
||||||
|
@ -8,6 +8,16 @@
|
|||||||
|
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
|
_global_script_classes=[ {
|
||||||
|
"base": "Node2D",
|
||||||
|
"class": "DropOffPoint",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://DropOffPoint.gd"
|
||||||
|
} ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
"DropOffPoint": ""
|
||||||
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="City Bound"
|
config/name="City Bound"
|
||||||
|
Loading…
Reference in New Issue
Block a user