diff --git a/.gdignore b/.gdignore deleted file mode 100644 index f895c803..00000000 --- a/.gdignore +++ /dev/null @@ -1 +0,0 @@ -blender/ diff --git a/entities/enemy/blue_enemy.gd b/entities/enemy/blue_enemy.gd index 5d85a2e3..3a2eb2b8 100644 --- a/entities/enemy/blue_enemy.gd +++ b/entities/enemy/blue_enemy.gd @@ -1,7 +1,7 @@ extends Enemy export var patrolling_speed = 9 - +export var chasing_speed = 13 enum { PATROLLING, ALERT, @@ -28,8 +28,8 @@ func _process(delta): if get_parent() is PathFollow: # Reset rotation, otherwise enemy won't be able to chase player. get_parent().rotation = Vector3.ZERO - if is_instance_valid(GameState.Player): - initiliaze(self.transform.origin, GameState.Player.transform.origin, false) + if is_instance_valid(GameState.Player) and not already_squashed: + initiliaze(self.transform.origin, GameState.Player.transform.origin, false, chasing_speed) func _on_VisibilityNotifier_screen_exited(): pass # Prevent "queue_free()" from parent. @@ -38,6 +38,11 @@ func _on_PrismArea_body_entered(_body): if state != CHASING: state = ALERT +func squash(): + # When squashed, always hide exclamation mark. + $ExclamationMark.visible = false + .squash() + func _on_AlertTimer_timeout(): $ExclamationMark.visible = false state = CHASING diff --git a/maps/test_map.gd b/maps/test_map.gd index 0f3b07ba..73fa412a 100644 --- a/maps/test_map.gd +++ b/maps/test_map.gd @@ -28,4 +28,4 @@ func _on_Player_hit(): GameState.UserInterface.retry() func _on_RedButton_pressed(): - $Goweti/Manual/AnimationPlayer.play("move_platforms") + $Goweti/Manual.move_platforms() diff --git a/maps/test_map.tscn b/maps/test_map.tscn index fc4fd659..c87ba9e7 100644 --- a/maps/test_map.tscn +++ b/maps/test_map.tscn @@ -314,9 +314,6 @@ transform = Transform( 0.625493, 1.00824e-08, 0.230657, 0.230657, -2.73412e-08, transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 55.6152, 2.24891, -3.78947 ) direction = 1 -[node name="Goweti" parent="." instance=ExtResource( 18 )] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 60.906, -0.312, -0.581 ) - [node name="PortalPlaceholder" parent="." instance=ExtResource( 21 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0670445, 0.144789, -135.074 ) map_name = "mountain_map" @@ -378,6 +375,9 @@ patrolling_speed = 18 transform = Transform( 1, 0, 0, 0, 0.969876, 0.243598, 0, -0.243598, 0.969876, 0, 15.2, 45.4 ) far = 200.0 +[node name="Goweti" parent="." instance=ExtResource( 18 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 60.906, -0.312, -0.581 ) + [connection signal="hit" from="Player" to="." method="_on_Player_hit"] [connection signal="timeout" from="EnemyTimer" to="." method="_on_EnemyTimer_timeout"] [connection signal="pressed" from="RedButton" to="." method="_on_RedButton_pressed"] diff --git a/models/goweti/Manual.gd b/models/goweti/Manual.gd deleted file mode 100644 index dfd8d7c7..00000000 --- a/models/goweti/Manual.gd +++ /dev/null @@ -1,14 +0,0 @@ -extends Node - -var move_forward := false - -func _on_AnimationPlayer_animation_finished(anim_name: String): - if anim_name == "move_platforms": - $FloatingPlatformTimer.start() - -func _on_FloatingPlatformTimer_timeout(): - if move_forward: - $AnimationPlayer.play("move_platforms") - else: - $AnimationPlayer.play_backwards("move_platforms") - move_forward = !move_forward diff --git a/models/goweti/goweti.blend b/models/goweti/goweti.blend index 65e69381..0d1d6b6f 100644 Binary files a/models/goweti/goweti.blend and b/models/goweti/goweti.blend differ diff --git a/models/goweti/goweti.gd b/models/goweti/goweti.gd new file mode 100644 index 00000000..f40791fc --- /dev/null +++ b/models/goweti/goweti.gd @@ -0,0 +1,23 @@ +extends Node + +# If re-importing from Blender, remember to "Clear inheritance" and make the +# floating platforms of type "KinematicBody". Also, adjust the "move_platforms" +# animation and make "RESET" go to meeting position. + +enum { MOVING_CLOSER, MOVING_AWAY } + +var direction := MOVING_AWAY + +func move_platforms(): + _on_FloatingPlatformTimer_timeout() + +func _on_AnimationPlayer_animation_finished(anim_name: String): + if anim_name == "move_platforms": + $FloatingPlatformTimer.start() + +func _on_FloatingPlatformTimer_timeout(): + if direction == MOVING_CLOSER: + $AnimationPlayer.play("move_platforms") + else: # MOVING_AWAY + $AnimationPlayer.play_backwards("move_platforms") + direction = !direction diff --git a/models/goweti/goweti.glb b/models/goweti/goweti.glb index 87aadddd..30f3163d 100644 Binary files a/models/goweti/goweti.glb and b/models/goweti/goweti.glb differ diff --git a/models/goweti/goweti.tscn b/models/goweti/goweti.tscn index afa557db..51c89f80 100644 --- a/models/goweti/goweti.tscn +++ b/models/goweti/goweti.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=17 format=2] -[ext_resource path="res://models/goweti/Manual.gd" type="Script" id=1] +[ext_resource path="res://models/goweti/goweti.gd" type="Script" id=1] [sub_resource type="SpatialMaterial" id=1] resource_name = "Material" @@ -113,7 +113,7 @@ data = PoolVector3Array( -5.3, 0.25, -6.9702, 5.3, 0.25, 6.9702, 5.3, 0.25, -6.9 [sub_resource type="Animation" id=14] length = 0.001 tracks/0/type = "value" -tracks/0/path = NodePath("FloatingPlatform:translation") +tracks/0/path = NodePath("../FloatingPlatform:translation") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false @@ -122,10 +122,10 @@ tracks/0/keys = { "times": PoolRealArray( 0 ), "transitions": PoolRealArray( 1 ), "update": 0, -"values": [ Vector3( 0, 6.67, -41 ) ] +"values": [ Vector3( 0, 6.67, -32 ) ] } tracks/1/type = "value" -tracks/1/path = NodePath("FloatingPlatform001:translation") +tracks/1/path = NodePath("../FloatingPlatform001:translation") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/imported = false @@ -134,35 +134,34 @@ tracks/1/keys = { "times": PoolRealArray( 0 ), "transitions": PoolRealArray( 1 ), "update": 0, -"values": [ Vector3( 0, 6.67, -56 ) ] +"values": [ Vector3( 0, 6.67, -47 ) ] } [sub_resource type="Animation" id=15] -resource_name = "move_platforms" -length = 3.5 +length = 3.0 tracks/0/type = "value" -tracks/0/path = NodePath("FloatingPlatform:translation") +tracks/0/path = NodePath("../FloatingPlatform:translation") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 3.5 ), +"times": PoolRealArray( 0, 3 ), "transitions": PoolRealArray( 1, 1 ), "update": 0, -"values": [ Vector3( 0, 6.67, -41 ), Vector3( 0, 6.67, -14 ) ] +"values": [ Vector3( 0, 6.67009, -13.991 ), Vector3( 0, 6.67, -32 ) ] } tracks/1/type = "value" -tracks/1/path = NodePath("FloatingPlatform001:translation") +tracks/1/path = NodePath("../FloatingPlatform001:translation") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/imported = false tracks/1/enabled = true tracks/1/keys = { -"times": PoolRealArray( 0, 3.5 ), +"times": PoolRealArray( 0, 3 ), "transitions": PoolRealArray( 1, 1 ), "update": 0, -"values": [ Vector3( 0, 6.67, -56 ), Vector3( 0, 6.67, -83 ) ] +"values": [ Vector3( 0, 6.67009, -66.3179 ), Vector3( 0, 6.67, -47 ) ] } [node name="goweti" type="Spatial"] @@ -188,7 +187,7 @@ material/0 = null shape = SubResource( 6 ) [node name="FloatingPlatform" type="MeshInstance" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.67, -41 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.67, -32 ) mesh = SubResource( 8 ) material/0 = null @@ -208,7 +207,7 @@ material/0 = null shape = SubResource( 11 ) [node name="FloatingPlatform001" type="MeshInstance" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.67, -56 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.67, -47 ) mesh = SubResource( 12 ) material/0 = null @@ -221,7 +220,7 @@ shape = SubResource( 13 ) script = ExtResource( 1 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="Manual"] -root_node = NodePath("../..") +root_node = NodePath("../../BaseCube") autoplay = "RESET" playback_process_mode = 0 anims/RESET = SubResource( 14 )