Load profile data by color
This commit is contained in:
parent
c2192ffdb5
commit
473ed41338
|
@ -30,6 +30,8 @@ class ProfileData:
|
|||
static func get_profile_data(index) -> ProfileData:
|
||||
var profiles = [
|
||||
ProfileData.new(3, -3, -10, 1, 10, { 0: 1, 1: 0, 2: -0.5 }),
|
||||
ProfileData.new(3, -3, -10, 1, 10, { 0: -0.5, 1: 1, 2: 0 }),
|
||||
ProfileData.new(3, -3, -10, 1, 10, { 0: 0, 1: -0.5, 2: 1 }),
|
||||
]
|
||||
return profiles[index]
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ func _ready():
|
|||
var counter = 0
|
||||
var person = preload("res://scenes/crowd/person.tscn")
|
||||
for seat in $Seats.get_children():
|
||||
seat.add_child(person.instantiate())
|
||||
var person_node = person.instantiate()
|
||||
person_node.color = AudienceMember.get_random_color()
|
||||
seat.add_child(person_node)
|
||||
|
||||
counter += 1
|
||||
if counter == max_persons:
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[node name="Crowd" type="Node2D"]
|
||||
position = Vector2(240, 232)
|
||||
script = ExtResource("1_y7wyj")
|
||||
max_persons = null
|
||||
|
||||
[node name="Tables" type="Node" parent="."]
|
||||
|
||||
|
|
|
@ -45,12 +45,30 @@ const laughter_duration : float = 2. # seconds
|
|||
const laughter_bobs : int = 4
|
||||
var laughter_left : float = 0.
|
||||
|
||||
func _map_color_to_profile_data_index(color):
|
||||
match color:
|
||||
"blue":
|
||||
return 0
|
||||
"green":
|
||||
return 1
|
||||
"red":
|
||||
return 2
|
||||
return 0
|
||||
|
||||
static func get_random_color():
|
||||
var keys = ["blue", "green", "red"]
|
||||
return keys[randi() % keys.size()]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
laughter_left = 0.
|
||||
mood = randf_range(profile.lashout_threshold, profile.happy_threshold)
|
||||
update_expression()
|
||||
|
||||
var profile_index = _map_color_to_profile_data_index(color)
|
||||
var profile_data = AudienceProfile.get_profile_data(profile_index)
|
||||
profile.load_data(profile_data)
|
||||
|
||||
if body_shape == null:
|
||||
set_random_body(color)
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://cl4fax7fbh2g7"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cl4fax7fbh2g7"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/crowd/person.gd" id="1_mx0i8"]
|
||||
[ext_resource type="Script" path="res://scenes/crowd/audience_profile.gd" id="2_bsodr"]
|
||||
|
||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_kbo53"]
|
||||
size = Vector2(20, 30)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5rd5b"]
|
||||
|
||||
[node name="Person" type="Sprite2D" node_paths=PackedStringArray("head", "profile")]
|
||||
texture = SubResource("PlaceholderTexture2D_kbo53")
|
||||
[node name="Person" type="Node2D" node_paths=PackedStringArray("head", "body", "profile")]
|
||||
script = ExtResource("1_mx0i8")
|
||||
head = NodePath("Head")
|
||||
body = NodePath("Body")
|
||||
profile = NodePath("Profile")
|
||||
expression = 1
|
||||
|
||||
[node name="Body" type="Node2D" parent="."]
|
||||
position = Vector2(0, 15)
|
||||
scale = Vector2(0.3, 0.3)
|
||||
|
||||
[node name="Head" type="Node2D" parent="."]
|
||||
position = Vector2(0, -16)
|
||||
scale = Vector2(0.3, 0.3)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue