mirror of
				https://github.com/mightypanders/GMTKJam2021.git
				synced 2025-11-04 11:09:50 +01:00 
			
		
		
		
	begin scoring
This commit is contained in:
		
							
								
								
									
										19
									
								
								Playa.gd
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								Playa.gd
									
									
									
									
									
								
							@@ -7,8 +7,9 @@ export var FRICTION = 50
 | 
				
			|||||||
var velocity = Vector2.ZERO
 | 
					var velocity = Vector2.ZERO
 | 
				
			||||||
var last_in_line
 | 
					var last_in_line
 | 
				
			||||||
var destinationColor = Color.transparent
 | 
					var destinationColor = Color.transparent
 | 
				
			||||||
onready var guestListNode = $GuestList
 | 
					var guestName = 'Car'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					signal scored(value)
 | 
				
			||||||
var guests = []
 | 
					var guests = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _ready():
 | 
					func _ready():
 | 
				
			||||||
@@ -18,7 +19,7 @@ func _ready():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func add_Guest_to_Line(parent,guest):
 | 
					func add_Guest_to_Line(parent,guest):
 | 
				
			||||||
	guests.append(guest)
 | 
						guests.append(guest)
 | 
				
			||||||
 | 
						print('Picked up Guest %s with color %s'%[guest.guestName,guest.destinationColor])
 | 
				
			||||||
	var parentAnchor = parent.get_node("Anchor")
 | 
						var parentAnchor = parent.get_node("Anchor")
 | 
				
			||||||
	parentAnchor.add_child(get_a_springjoint(parent,guest))
 | 
						parentAnchor.add_child(get_a_springjoint(parent,guest))
 | 
				
			||||||
	var pua = guest.get_node("PickUpArea")
 | 
						var pua = guest.get_node("PickUpArea")
 | 
				
			||||||
@@ -29,17 +30,21 @@ func add_Guest_to_Line(parent,guest):
 | 
				
			|||||||
func get_a_springjoint(parent,child):
 | 
					func get_a_springjoint(parent,child):
 | 
				
			||||||
	var springJoint = DampedSpringJoint2D.new()
 | 
						var springJoint = DampedSpringJoint2D.new()
 | 
				
			||||||
	#springJoint.rotation+=get_angle_to(guest.global_position)
 | 
						#springJoint.rotation+=get_angle_to(guest.global_position)
 | 
				
			||||||
	springJoint.length = 50
 | 
						springJoint.length = 5
 | 
				
			||||||
	springJoint.rest_length = 10
 | 
						springJoint.rest_length = 5
 | 
				
			||||||
	springJoint.stiffness = 64
 | 
						springJoint.stiffness = 64
 | 
				
			||||||
	springJoint.damping = 1.0
 | 
						springJoint.damping = 1.0
 | 
				
			||||||
	springJoint.disable_collision =false
 | 
						springJoint.disable_collision =true
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	springJoint.node_a =parent.get_path()
 | 
						springJoint.node_a =parent.get_path()
 | 
				
			||||||
	springJoint.node_b =child.get_path()
 | 
						springJoint.node_b =child.get_path()
 | 
				
			||||||
	springJoint.add_child(child)
 | 
						springJoint.add_child(child)
 | 
				
			||||||
	return springJoint
 | 
						return springJoint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func get_score_from_guest(guest):
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func remove_Guests_from_Line(color):
 | 
					func remove_Guests_from_Line(color):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var colormatches = []
 | 
						var colormatches = []
 | 
				
			||||||
@@ -50,6 +55,8 @@ func remove_Guests_from_Line(color):
 | 
				
			|||||||
				colormatches.append(guests[g])
 | 
									colormatches.append(guests[g])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i in colormatches:
 | 
						for i in colormatches:
 | 
				
			||||||
 | 
							var scoreValue = get_score_from_guest(i)
 | 
				
			||||||
 | 
							emit_signal("scored",scoreValue)
 | 
				
			||||||
		var pos = guests.find(i)
 | 
							var pos = guests.find(i)
 | 
				
			||||||
		i.queue_free()
 | 
							i.queue_free()
 | 
				
			||||||
		guests.remove(pos)
 | 
							guests.remove(pos)
 | 
				
			||||||
@@ -62,7 +69,7 @@ func _on_PickupCheckArea_area_entered(area):
 | 
				
			|||||||
		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
 | 
				
			||||||
	if area.get_parent().is_in_group("Guest"):
 | 
						if area.get_parent().is_in_group("Guest"):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user