Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seat now references a customer, doesn't 'own' a customer #291

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/demo/creature-view-demo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Keys:
[F]: Feed the creature
[D]: Ring the doorbell
[V]: Say something
[P]: Print the current animation details
[1-9,0]: Change the creature's size from 10% to 100%
[Q,W,E]: Switch to the 1st, 2nd or 3rd creature.
brace keys: Change the creature's appearance
Expand All @@ -23,11 +22,11 @@ func _ready() -> void:

func _input(event: InputEvent) -> void:
match Utils.key_scancode(event):
KEY_F: $CreatureView/SceneClip/CreatureSwitcher/Scene.feed()
KEY_D: $CreatureView/SceneClip/CreatureSwitcher/Scene.play_door_chime(0)
KEY_V: $CreatureView.play_goodbye_voice()
KEY_F: _creature().feed()
KEY_D: _creature().play_door_chime(0)
KEY_V: _creature().play_goodbye_voice()
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9:
$CreatureView.set_fatness(FATNESS_KEYS[Utils.key_num(event)])
$CreatureView.get_creature().set_fatness(FATNESS_KEYS[Utils.key_num(event)])
KEY_Q: $CreatureView.set_current_creature_index(0)
KEY_W: $CreatureView.set_current_creature_index(1)
KEY_E: $CreatureView.set_current_creature_index(2)
Expand All @@ -46,6 +45,7 @@ func _input(event: InputEvent) -> void:
_current_color_index = (_current_color_index + 1) % CreatureLoader.DEFINITIONS.size()
Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index])
$CreatureView.summon_creature()
KEY_P:
print($CreatureView/SceneClip/CreatureSwitcher/Scene/Creature/AnimationPlayer.current_animation)
print($CreatureView/SceneClip/CreatureSwitcher/Scene/Creature/AnimationPlayer.is_playing())


func _creature() -> Creature:
return $CreatureView/SceneClip/CreatureSwitcher/Scene.get_creature()
14 changes: 4 additions & 10 deletions src/demo/restaurant-scene-demo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ A demo which shows off the restaurant scene.
Keys:
[F]: Feed the creature
[P]: Print the current animation details
[1-9,0]: Change the creature's size from 10% to 100%
brace keys: Change the creature's appearance
"""
Expand All @@ -20,24 +19,19 @@ func _ready() -> void:

func _input(event: InputEvent) -> void:
match Utils.key_scancode(event):
KEY_F: $RestaurantScene.feed()
KEY_F: $RestaurantScene.get_creature().feed()
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9:
$RestaurantScene.set_fatness(FATNESS_KEYS[Utils.key_num(event)])
$RestaurantScene.get_creature().set_fatness(FATNESS_KEYS[Utils.key_num(event)])
KEY_BRACELEFT:
if _current_color_index == -1:
_current_color_index = 0
else:
_current_color_index += CreatureLoader.DEFINITIONS.size()
_current_color_index = (_current_color_index - 1) % CreatureLoader.DEFINITIONS.size()
Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index])
$RestaurantScene.summon_creature(1)
$RestaurantScene.summon_creature(CreatureLoader.DEFINITIONS[_current_color_index])
KEY_BRACERIGHT:
if _current_color_index == -1:
_current_color_index = 0
else:
_current_color_index = (_current_color_index + 1) % CreatureLoader.DEFINITIONS.size()
Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index])
$RestaurantScene.summon_creature(1)
KEY_P:
print($RestaurantScene/Creature/AnimationPlayer.current_animation)
print($RestaurantScene/Creature/AnimationPlayer.is_playing())
$RestaurantScene.summon_creature(CreatureLoader.DEFINITIONS[_current_color_index])
2 changes: 0 additions & 2 deletions src/main/puzzle/Puzzle.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
[ext_resource path="res://src/main/puzzle/chalkboard.gd" type="Script" id=66]
[ext_resource path="res://src/main/puzzle/start-end-sfx.gd" type="Script" id=67]



[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 4 )

Expand Down
8 changes: 4 additions & 4 deletions src/main/puzzle/puzzle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ Parameters:
'fatness_pct' A percent from [0.0-1.0] of how much fatter the creature should get from this bite of food.
"""
func _feed_creature(fatness_pct: float) -> void:
$CreatureView/SceneClip/CreatureSwitcher/Scene.feed()
$CreatureView.get_creature().feed()

if PuzzleScore.game_active:
var old_fatness: float = $CreatureView.get_fatness()
var old_fatness: float = $CreatureView.get_creature().get_fatness()
var target_fatness := sqrt(1 + PuzzleScore.get_creature_score() / 50.0)
if Scenario.settings.other.tutorial:
# make them a tiny amount fatter, so that they'll change when a new level is started
target_fatness = min(target_fatness, 1.001)
$CreatureView.set_fatness(lerp(old_fatness, target_fatness, fatness_pct))
$CreatureView.get_creature().set_fatness(lerp(old_fatness, target_fatness, fatness_pct))


func _on_Hud_start_button_pressed() -> void:
Expand All @@ -86,7 +86,7 @@ func _on_Playfield_line_cleared(y: int, total_lines: int, remaining_lines: int,

if creature_talks:
yield(get_tree().create_timer(0.5), "timeout")
$CreatureView/SceneClip/CreatureSwitcher/Scene.play_combo_voice()
$CreatureView.get_creature().play_combo_voice()


"""
Expand Down
2 changes: 1 addition & 1 deletion src/main/puzzle/results-hud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ func _on_PuzzleScore_after_game_ended() -> void:


func _on_ResultsLabel_text_shown(new_text: String) -> void:
if new_text.begins_with("Creature #"):
if new_text.begins_with("Customer #"):
var amount := int(StringUtils.substring_after_last(new_text, "¥").replace(",", ""))
$MoneyLabel.set_shown_money($MoneyLabel.shown_money + amount)
1 change: 0 additions & 1 deletion src/main/ui/chat/ChatChoices.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[ext_resource path="res://assets/main/ui/chat/choice-choose.wav" type="AudioStream" id=5]
[ext_resource path="res://src/main/ui/chat/ChatChoiceButton.tscn" type="PackedScene" id=6]


[node name="ChatChoices" type="GridContainer"]
anchor_left = 1.0
anchor_top = 1.0
Expand Down
2 changes: 1 addition & 1 deletion src/main/world/restaurant/CreatureView.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ range_item_cull_mask = 2
[node name="CreatureSwitcher" type="Node2D" parent="SceneClip"]

[node name="Scene" parent="SceneClip/CreatureSwitcher" instance=ExtResource( 3 )]
position = Vector2( -89.8811, -77.6484 )
position = Vector2( -89.8812, -104.904 )

[node name="CreatureSwitchTween" type="Tween" parent="SceneClip/CreatureSwitcher"]

Expand Down
30 changes: 20 additions & 10 deletions src/main/world/restaurant/RestaurantScene.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]

[ext_resource path="res://src/main/world/restaurant/Creature.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/main/world/restaurant/Seat.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/main/world/restaurant/wall-metal.png" type="Texture" id=5]
[ext_resource path="res://assets/main/world/restaurant/wall-metal-shadow.png" type="Texture" id=7]
Expand Down Expand Up @@ -145,19 +146,28 @@ z_index = 10
texture = ExtResource( 12 )
offset = Vector2( 0, -550 )

[node name="Creature1" parent="." instance=ExtResource( 1 )]
visible = false
position = Vector2( 381.228, 435.763 )
z_index = 20

[node name="Seat1" parent="." instance=ExtResource( 2 )]
z_index = 10

[node name="Creature2" parent="." instance=ExtResource( 1 )]
visible = false
position = Vector2( 1381.23, 435.763 )
z_index = 20

[node name="Seat2" parent="." instance=ExtResource( 2 )]
position = Vector2( 1380, 585 )
z_index = 10

[node name="Creature3" parent="." instance=ExtResource( 1 )]
visible = false
position = Vector2( 2381.23, 435.763 )
z_index = 20

[node name="Seat3" parent="." instance=ExtResource( 2 )]
position = Vector2( 2380, 585 )
z_index = 10

[editable path="Seat1"]

[editable path="Seat2"]

[editable path="Seat3"]
[connection signal="food_eaten" from="Creature1" to="." method="_on_Creature_food_eaten"]
[connection signal="food_eaten" from="Creature2" to="." method="_on_Creature_food_eaten"]
[connection signal="food_eaten" from="Creature3" to="." method="_on_Creature_food_eaten"]
11 changes: 3 additions & 8 deletions src/main/world/restaurant/Seat.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://src/main/world/restaurant/Creature.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/main/world/shadow-oval-0.png" type="Texture" id=3]
[ext_resource path="res://assets/main/world/restaurant/wood-table.png" type="Texture" id=8]
[ext_resource path="res://src/main/world/outline.shader" type="Shader" id=9]
Expand All @@ -18,8 +17,9 @@ shader = ExtResource( 9 )
shader_param/width = 2.5
shader_param/black = Color( 0.423529, 0.262745, 0.192157, 1 )

[node name="Seat" type="Node2D"]
[node name="Seat1" type="Node2D"]
position = Vector2( 380, 585 )
z_index = 10
script = ExtResource( 30 )

[node name="Stool0L" type="Sprite" parent="."]
Expand All @@ -36,9 +36,6 @@ scale = Vector2( 0.15, 0.15 )
z_index = -10
texture = ExtResource( 3 )

[node name="Creature" parent="." instance=ExtResource( 1 )]
position = Vector2( 1.228, -149.237 )

[node name="WoodTable0" type="Sprite" parent="."]
light_mask = 2
material = SubResource( 1 )
Expand Down Expand Up @@ -69,5 +66,3 @@ light_mask = 2
scale = Vector2( 0.15, 0.15 )
z_index = -15
texture = ExtResource( 3 )
[connection signal="creature_arrived" from="Creature" to="." method="_on_Creature_creature_arrived"]
[connection signal="creature_left" from="Creature" to="." method="_on_Creature_creature_left"]
7 changes: 7 additions & 0 deletions src/main/world/restaurant/creature-loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const DEFINITIONS := [
{"line_rgb": "41281e", "body_rgb": "0b45a6", "eye_rgb": "fad541 ffffff", "horn_rgb": "282828"} # dark blue
]

"""
Returns a random creature definition.
"""
static func random_def() -> Dictionary:
return DEFINITIONS[randi() % DEFINITIONS.size()]


"""
Loads all the appropriate resources and property definitions for a creature. The resulting textures are stored back in
the 'creature_def' parameter which is passed in.
Expand Down
38 changes: 9 additions & 29 deletions src/main/world/restaurant/creature-view.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ func _ready() -> void:
PuzzleScore.connect("combo_ended", self, "_on_PuzzleScore_combo_ended")


"""
Increases/decreases the camera and creature's fatness, playing an animation which gradually applies the change.
func _physics_process(delta: float) -> void:
if $FatPlayer.get_fatness() != get_creature().get_fatness():
$FatPlayer.set_fatness(get_creature().get_fatness())

Parameters:
'fatness': How fat the creature should be; 5.0 = 5x normal size
"""
func set_fatness(fatness: float, creature_index: int = -1) -> void:
$SceneClip/CreatureSwitcher/Scene.set_fatness(fatness, creature_index)
if creature_index == -1 or creature_index == $SceneClip/CreatureSwitcher/Scene.current_creature_index:
$FatPlayer.set_fatness(fatness)

func get_creature(creature_index: int = -1) -> Creature:
return $SceneClip/CreatureSwitcher/Scene.get_creature(creature_index)


"""
Expand All @@ -32,20 +29,12 @@ properties.
func summon_creature(creature_index: int = -1) -> void:
var creature_def: Dictionary
if Global.creature_queue.empty():
creature_def = CreatureLoader.DEFINITIONS[randi() % CreatureLoader.DEFINITIONS.size()]
creature_def = CreatureLoader.random_def()
else:
creature_def = Global.creature_queue.pop_front()
$SceneClip/CreatureSwitcher/Scene.summon_creature(creature_def, creature_index)


"""
Returns the camera's 'fatness' -- when fatness is 1.0 the camera is zoomed in, and when the fatness is at 10.0 it's
zoomed out so that the creature is in frame.
"""
func get_fatness() -> float:
return $FatPlayer.get_fatness()


"""
Pans the camera to a new creature. This also changes which creature will be fed.
"""
Expand All @@ -55,17 +44,9 @@ func set_current_creature_index(current_creature_index: int) -> void:
$SceneClip/CreatureSwitcher, "position:x",
$SceneClip/CreatureSwitcher.position.x, -1000 * current_creature_index, PAN_DURATION_SECONDS,
Tween.TRANS_SINE, Tween.EASE_IN_OUT)
$FatPlayer.set_fatness($SceneClip/CreatureSwitcher/Scene.get_fatness(current_creature_index))
$SceneClip/CreatureSwitcher/CreatureSwitchTween.start()


"""
Plays a 'check please!' voice sample, for when a creature is ready to leave
"""
func play_goodbye_voice() -> void:
$SceneClip/CreatureSwitcher/Scene.play_goodbye_voice()


"""
Scroll to a new creature and replace the old creature.
"""
Expand All @@ -74,19 +55,18 @@ func scroll_to_new_creature() -> void:
var new_creature_index: int = (creature_index + randi() % 2 + 1) % 3
set_current_creature_index(new_creature_index)
yield(get_tree().create_timer(0.5), "timeout")
set_fatness(1, creature_index)
summon_creature(creature_index)


"""
If they ended the previous game while serving a creature, we scroll to a new one
"""
func _on_PuzzleScore_game_prepared() -> void:
if get_fatness() > 1:
if get_creature().get_fatness() > 1:
scroll_to_new_creature()


func _on_PuzzleScore_combo_ended() -> void:
if PuzzleScore.game_active and not Scenario.settings.other.tutorial:
play_goodbye_voice()
get_creature().play_goodbye_voice()
scroll_to_new_creature()
24 changes: 24 additions & 0 deletions src/main/world/restaurant/creature.gd
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,30 @@ func _process(delta: float) -> void:
$Sprites/Neck0/Neck1.position.y = -100


"""
Returns the creature's fatness, a float which determines how fat the creature
should be; 5.0 = 5x normal size
Parameters:
'creature_index': (Optional) The creature to ask about. Defaults to the current creature.
"""
func get_fatness() -> float:
return $FatPlayer.get_fatness()


"""
Increases/decreases the creature's fatness, a float which determines how fat
the creature should be; 5.0 = 5x normal size
Parameters:
'fatness_percent': Controls how fat the creature should be; 5.0 = 5x normal size
'creature_index': (Optional) The creature to be altered. Defaults to the current creature.
"""
func set_fatness(fatness: float) -> void:
$FatPlayer.set_fatness(fatness)


func set_head_bob_mode(new_head_bob_mode: int) -> void:
head_bob_mode = new_head_bob_mode
# Some head bob animations like 'shudder' offset the x position; reset it back to the center
Expand Down
Loading