ソースを参照

:truck: Move entities to dedicated scenes

- Brick grid
- Death line
- Ball launcher
DricomDragon 3 年 前
コミット
89479b5889

+ 26 - 0
godot/component/entity/brick/Grid.tscn

@@ -0,0 +1,26 @@
+[gd_scene load_steps=4 format=2]
+
+[ext_resource path="res://component/ui/LifeContainer.gd" type="Script" id=1]
+[ext_resource path="res://component/entity/brick/brick_tileset.tres" type="TileSet" id=2]
+[ext_resource path="res://component/entity/brick/Grid.gd" type="Script" id=3]
+
+[node name="Grid" type="TileMap" groups=[
+"grid",
+]]
+mode = 2
+tile_set = ExtResource( 2 )
+cell_size = Vector2( 40, 20 )
+cell_custom_transform = Transform2D( 40, 0, 0, 20, 0, 0 )
+collision_layer = 4
+collision_mask = 8
+format = 1
+script = ExtResource( 3 )
+
+[node name="LifeContainer" type="Node2D" parent="."]
+script = ExtResource( 1 )
+
+[node name="MoveDown" type="Tween" parent="."]
+__meta__ = {
+"_editor_description_": "Move grid to show the new row"
+}
+[connection signal="tween_all_completed" from="MoveDown" to="." method="_on_MoveDown_tween_all_completed"]

+ 9 - 0
godot/component/entity/death/Death.tscn

@@ -0,0 +1,9 @@
+[gd_scene load_steps=2 format=2]
+
+[ext_resource path="res://component/entity/death/DeadLine.gd" type="Script" id=1]
+
+[node name="DeadLine" type="RayCast2D"]
+position = Vector2( 380, 390 )
+cast_to = Vector2( -360, 0 )
+collision_mask = 4
+script = ExtResource( 1 )

+ 6 - 2
godot/component/entity/launcher/Launcher.gd

@@ -7,6 +7,7 @@ signal is_full
 signal gain_new_bullet
 signal interrupt_wave
 signal move_visor
+signal kace_contact
 
 enum State {
 	READY,
@@ -30,7 +31,6 @@ onready var target = $TargetLine
 onready var visor = $TargetLine/TargetVisor
 onready var source = $Source
 onready var shootDelay = $ShootDelay
-onready var grid = $Grid
 
 onready var current_state = State.WAITING
 
@@ -69,7 +69,7 @@ func shoot():
 		bullet.linear_velocity *= BULLET_SPEED
 		add_child(bullet)
 		bullet.connect("tree_exited", self, "_on_Ball_tree_exited")
-		bullet.connect("kace_contact", grid, "_on_Ball_kace_contact")
+		bullet.connect("kace_contact", self, "_on_Ball_kace_contact")
 		self.connect("interrupt_wave", bullet, "_on_Launcher_interrupt_wave")
 
 
@@ -127,3 +127,7 @@ func _on_Grid_kace_broken():
 
 func _on_DeadLine_game_lost():
 	die()
+
+func _on_Ball_kace_contact(pos: Vector2):
+	emit_signal("kace_contact", pos)
+	

+ 29 - 0
godot/component/entity/launcher/Launcher.tscn

@@ -0,0 +1,29 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://component/entity/launcher/Launcher.gd" type="Script" id=1]
+[ext_resource path="res://component/entity/launcher/visor.png" type="Texture" id=2]
+[ext_resource path="res://component/entity/launcher/TargetLine.gd" type="Script" id=3]
+[ext_resource path="res://component/entity/launcher/launcher.png" type="Texture" id=4]
+
+[node name="Launcher" type="Node2D"]
+script = ExtResource( 1 )
+visor_ratio = 1.6
+
+[node name="TargetLine" type="RayCast2D" parent="."]
+position = Vector2( 200, 400 )
+collision_mask = 6
+script = ExtResource( 3 )
+
+[node name="TargetVisor" type="Sprite" parent="TargetLine"]
+texture = ExtResource( 2 )
+
+[node name="Source" type="Sprite" parent="."]
+position = Vector2( 200, 400 )
+texture = ExtResource( 4 )
+
+[node name="ShootDelay" type="Timer" parent="."]
+wait_time = 0.1
+one_shot = true
+[connection signal="get_firing" from="." to="." method="_on_Launcher_get_firing"]
+[connection signal="move_visor" from="." to="TargetLine" method="_on_Launcher_move_visor"]
+[connection signal="timeout" from="ShootDelay" to="." method="_on_ShootDelay_timeout"]

+ 15 - 63
godot/main.tscn

@@ -1,17 +1,12 @@
-[gd_scene load_steps=14 format=2]
+[gd_scene load_steps=9 format=2]
 
 [ext_resource path="res://component/ui/message_panel/MessagePanel.tscn" type="PackedScene" id=1]
-[ext_resource path="res://component/entity/launcher/TargetLine.gd" type="Script" id=2]
+[ext_resource path="res://component/entity/launcher/Launcher.tscn" type="PackedScene" id=2]
 [ext_resource path="res://component/entity/catcher/Catcher.tscn" type="PackedScene" id=3]
-[ext_resource path="res://component/ui/LifeContainer.gd" type="Script" id=4]
+[ext_resource path="res://component/entity/brick/Grid.tscn" type="PackedScene" id=4]
 [ext_resource path="res://component/ui/UI.gd" type="Script" id=5]
 [ext_resource path="res://component/ui/number_panel/NumberPanel.tscn" type="PackedScene" id=6]
-[ext_resource path="res://component/entity/death/DeadLine.gd" type="Script" id=7]
-[ext_resource path="res://component/entity/launcher/Launcher.gd" type="Script" id=8]
-[ext_resource path="res://component/entity/brick/brick_tileset.tres" type="TileSet" id=9]
-[ext_resource path="res://component/entity/launcher/visor.png" type="Texture" id=10]
-[ext_resource path="res://component/entity/launcher/launcher.png" type="Texture" id=11]
-[ext_resource path="res://component/entity/brick/Grid.gd" type="Script" id=12]
+[ext_resource path="res://component/entity/death/Death.tscn" type="PackedScene" id=7]
 [ext_resource path="res://component/entity/border/Border.tscn" type="PackedScene" id=13]
 
 [node name="Game" type="Node"]
@@ -27,51 +22,11 @@ __meta__ = {
 
 [node name="Catcher" parent="." instance=ExtResource( 3 )]
 
-[node name="Launcher" type="Node2D" parent="."]
-script = ExtResource( 8 )
-visor_ratio = 1.6
+[node name="Launcher" parent="." instance=ExtResource( 2 )]
 
-[node name="Grid" type="TileMap" parent="Launcher" groups=[
-"grid",
-]]
-mode = 2
-tile_set = ExtResource( 9 )
-cell_size = Vector2( 40, 20 )
-cell_custom_transform = Transform2D( 40, 0, 0, 20, 0, 0 )
-collision_layer = 4
-collision_mask = 8
-format = 1
-script = ExtResource( 12 )
+[node name="Grid" parent="." instance=ExtResource( 4 )]
 
-[node name="LifeContainer" type="Node2D" parent="Launcher/Grid"]
-script = ExtResource( 4 )
-
-[node name="MoveDown" type="Tween" parent="Launcher/Grid"]
-__meta__ = {
-"_editor_description_": "Move grid to show the new row"
-}
-
-[node name="TargetLine" type="RayCast2D" parent="Launcher"]
-position = Vector2( 200, 400 )
-collision_mask = 6
-script = ExtResource( 2 )
-
-[node name="TargetVisor" type="Sprite" parent="Launcher/TargetLine"]
-texture = ExtResource( 10 )
-
-[node name="Source" type="Sprite" parent="Launcher"]
-position = Vector2( 200, 400 )
-texture = ExtResource( 11 )
-
-[node name="ShootDelay" type="Timer" parent="Launcher"]
-wait_time = 0.1
-one_shot = true
-
-[node name="DeadLine" type="RayCast2D" parent="Launcher"]
-position = Vector2( 380, 390 )
-cast_to = Vector2( -360, 0 )
-collision_mask = 4
-script = ExtResource( 7 )
+[node name="DeadLine" parent="." instance=ExtResource( 7 )]
 
 [node name="UI" type="Control" parent="."]
 margin_right = 40.0
@@ -104,14 +59,11 @@ title = "Balls"
 [connection signal="ready" from="." to="UI/BallCounter" method="increase_counter"]
 [connection signal="gain_new_bullet" from="Launcher" to="UI/BallCounter" method="increase_counter"]
 [connection signal="get_firing" from="Launcher" to="UI" method="_on_Launcher_get_firing"]
-[connection signal="get_firing" from="Launcher" to="Launcher" method="_on_Launcher_get_firing"]
-[connection signal="is_full" from="Launcher" to="Launcher/Grid" method="_on_Launcher_is_full"]
-[connection signal="move_visor" from="Launcher" to="Launcher/TargetLine" method="_on_Launcher_move_visor"]
-[connection signal="has_moved" from="Launcher/Grid" to="Launcher" method="_on_Grid_has_moved"]
-[connection signal="has_moved" from="Launcher/Grid" to="Launcher/DeadLine" method="_on_Grid_has_moved"]
-[connection signal="kace_broken" from="Launcher/Grid" to="Launcher" method="_on_Grid_kace_broken"]
-[connection signal="kace_damaged" from="Launcher/Grid" to="UI/ScoreCounter" method="increase_counter"]
-[connection signal="tween_all_completed" from="Launcher/Grid/MoveDown" to="Launcher/Grid" method="_on_MoveDown_tween_all_completed"]
-[connection signal="timeout" from="Launcher/ShootDelay" to="Launcher" method="_on_ShootDelay_timeout"]
-[connection signal="game_lost" from="Launcher/DeadLine" to="UI" method="_on_DeadLine_game_lost"]
-[connection signal="game_lost" from="Launcher/DeadLine" to="Launcher" method="_on_DeadLine_game_lost"]
+[connection signal="is_full" from="Launcher" to="Grid" method="_on_Launcher_is_full"]
+[connection signal="kace_contact" from="Launcher" to="Grid" method="_on_Ball_kace_contact"]
+[connection signal="has_moved" from="Grid" to="Launcher" method="_on_Grid_has_moved"]
+[connection signal="has_moved" from="Grid" to="DeadLine" method="_on_Grid_has_moved"]
+[connection signal="kace_broken" from="Grid" to="Launcher" method="_on_Grid_kace_broken"]
+[connection signal="kace_damaged" from="Grid" to="UI/ScoreCounter" method="increase_counter"]
+[connection signal="game_lost" from="DeadLine" to="Launcher" method="_on_DeadLine_game_lost"]
+[connection signal="game_lost" from="DeadLine" to="UI" method="_on_DeadLine_game_lost"]