Compare commits

...

2 Commits

Author SHA1 Message Date
a8ff492aed Pacxon (#12)
* Add GridMovementAbility and PacXonGridInteractor for grid-based movement; integrate with PlayerController and PacXonLevel

* Add GhostMovementComponent and PacXonTrailComponent; integrate ghost movement and trail features in PacXonLevel

* Update main menu button focus and add new movement abilities; adjust player and ghost initialization in PacXonLevel
2025-09-13 01:52:07 +02:00
aa73e54b3e Add KnockbackComponent and HazardComponent for enhanced enemy interactions; integrate knockback effects in DamageComponent 2025-09-11 05:09:24 +02:00
34 changed files with 912 additions and 53 deletions

View File

@@ -2,6 +2,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACamera2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa2e12a1a67ad701a97608de6be85250e3e353951ecf8058a02c703490c753_003FCamera2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACamera2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa2e12a1a67ad701a97608de6be85250e3e353951ecf8058a02c703490c753_003FCamera2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACanvasItem_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fef7b819b226fab796d1dfe66d415dd7510bcac87675020ddb8f03a828e763_003FCanvasItem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACanvasItem_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fef7b819b226fab796d1dfe66d415dd7510bcac87675020ddb8f03a828e763_003FCanvasItem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACecovym_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Ftmp_003FJetBrainsPerUserTemp_002D1000_002D1_003FSandboxFiles_003FSadijuw_003FCecovym_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACecovym_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Ftmp_003FJetBrainsPerUserTemp_002D1000_002D1_003FSandboxFiles_003FSadijuw_003FCecovym_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACharacterBody2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbba0bbd7a98ee58286e9484fbe86e01afff6232283f6efd3556eb7116453_003FCharacterBody2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACollisionShape2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F2ca9b7334678f5c97c7c2a9fbe4837be71cae11b6a30408dd4791b18f997e4a_003FCollisionShape2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACollisionShape2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F2ca9b7334678f5c97c7c2a9fbe4837be71cae11b6a30408dd4791b18f997e4a_003FCollisionShape2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACSharpInstanceBridge_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94701b444afa4c3d9a7a53ebcaa35fd1583c00_003F14_003F4b4ade3f_003FCSharpInstanceBridge_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACSharpInstanceBridge_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94701b444afa4c3d9a7a53ebcaa35fd1583c00_003F14_003F4b4ade3f_003FCSharpInstanceBridge_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADelegateUtils_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94701b444afa4c3d9a7a53ebcaa35fd1583c00_003F08_003F45f75e10_003FDelegateUtils_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADelegateUtils_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F94701b444afa4c3d9a7a53ebcaa35fd1583c00_003F08_003F45f75e10_003FDelegateUtils_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://bockkmyn8il4c"] [gd_scene load_steps=26 format=3 uid="uid://bockkmyn8il4c"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_hh6y0"] [ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_hh6y0"]
[ext_resource type="Texture2D" uid="uid://duxx56wxmjoxd" path="res://sprites/basic_enemy.png" id="2_laaj3"] [ext_resource type="Texture2D" uid="uid://duxx56wxmjoxd" path="res://sprites/basic_enemy.png" id="2_laaj3"]
@@ -14,6 +14,7 @@
[ext_resource type="AudioStream" uid="uid://b3tsqhr06pbrs" path="res://sfx/enemy_hurt.wav" id="14_ndloc"] [ext_resource type="AudioStream" uid="uid://b3tsqhr06pbrs" path="res://sfx/enemy_hurt.wav" id="14_ndloc"]
[ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="15_cg63s"] [ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="15_cg63s"]
[ext_resource type="PackedScene" uid="uid://dx80ivlvuuew4" path="res://objects/fxs/fire_fx.tscn" id="16_jqaq6"] [ext_resource type="PackedScene" uid="uid://dx80ivlvuuew4" path="res://objects/fxs/fire_fx.tscn" id="16_jqaq6"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="17_ih01d"]
[ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="17_o7qsb"] [ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="17_o7qsb"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_v861c"] [ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_v861c"]
@@ -172,3 +173,7 @@ visible = false
[node name="HitParticles" parent="." instance=ExtResource("18_v861c")] [node name="HitParticles" parent="." instance=ExtResource("18_v861c")]
position = Vector2(0, 1) position = Vector2(0, 1)
process_material = SubResource("ParticleProcessMaterial_pxaaa") process_material = SubResource("ParticleProcessMaterial_pxaaa")
[node name="KnockbackComponent" type="Node" parent="."]
script = ExtResource("17_ih01d")
metadata/_custom_type_script = "uid://cgfynrn68lp12"

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=52 format=3 uid="uid://bqi5s710xb1ju"] [gd_scene load_steps=54 format=3 uid="uid://bqi5s710xb1ju"]
[ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"] [ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"] [ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
@@ -16,12 +16,12 @@
[ext_resource type="PackedScene" uid="uid://chjbi5mgtwhsh" path="res://objects/movement_abilities/wall_jump_ability.tscn" id="7_bnap0"] [ext_resource type="PackedScene" uid="uid://chjbi5mgtwhsh" path="res://objects/movement_abilities/wall_jump_ability.tscn" id="7_bnap0"]
[ext_resource type="Script" uid="uid://ck6kmnbwhsttt" path="res://scripts/components/Movement/OneWayPlatformAbility.cs" id="7_uno3u"] [ext_resource type="Script" uid="uid://ck6kmnbwhsttt" path="res://scripts/components/Movement/OneWayPlatformAbility.cs" id="7_uno3u"]
[ext_resource type="Texture2D" uid="uid://dhkwyv6ayb5qb" path="res://sprites/flying_ship.png" id="8_6lsog"] [ext_resource type="Texture2D" uid="uid://dhkwyv6ayb5qb" path="res://sprites/flying_ship.png" id="8_6lsog"]
[ext_resource type="PackedScene" uid="uid://dre1vit1m4d2n" path="res://objects/movement_abilities/grid_movement_ability.tscn" id="8_xuhvf"]
[ext_resource type="Script" uid="uid://dy78ak8eykw6e" path="res://scripts/components/FlipComponent.cs" id="9_yysbb"] [ext_resource type="Script" uid="uid://dy78ak8eykw6e" path="res://scripts/components/FlipComponent.cs" id="9_yysbb"]
[ext_resource type="Script" uid="uid://mnjg3p0aw1ow" path="res://scripts/components/CanPickUpComponent.cs" id="10_yysbb"] [ext_resource type="Script" uid="uid://mnjg3p0aw1ow" path="res://scripts/components/CanPickUpComponent.cs" id="10_yysbb"]
[ext_resource type="Script" uid="uid://ccqb8kd5m0eh7" path="res://scripts/components/ScoreComponent.cs" id="11_o1ihh"] [ext_resource type="Script" uid="uid://ccqb8kd5m0eh7" path="res://scripts/components/ScoreComponent.cs" id="11_o1ihh"]
[ext_resource type="Script" uid="uid://dgb8bqcri7nsj" path="res://scripts/components/HealthComponent.cs" id="12_ur2y5"] [ext_resource type="Script" uid="uid://dgb8bqcri7nsj" path="res://scripts/components/HealthComponent.cs" id="12_ur2y5"]
[ext_resource type="Script" uid="uid://byw1legrv1ep2" path="res://scripts/components/PlayerDeathComponent.cs" id="13_7til7"] [ext_resource type="Script" uid="uid://byw1legrv1ep2" path="res://scripts/components/PlayerDeathComponent.cs" id="13_7til7"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="14_e5pae"]
[ext_resource type="Script" uid="uid://cecelixl41t3j" path="res://scripts/components/InvulnerabilityComponent.cs" id="15_xuhvf"] [ext_resource type="Script" uid="uid://cecelixl41t3j" path="res://scripts/components/InvulnerabilityComponent.cs" id="15_xuhvf"]
[ext_resource type="Script" uid="uid://dvyd26ricriql" path="res://scripts/components/FlashingComponent.cs" id="16_uno3u"] [ext_resource type="Script" uid="uid://dvyd26ricriql" path="res://scripts/components/FlashingComponent.cs" id="16_uno3u"]
[ext_resource type="Script" uid="uid://dtg6115je7b5s" path="res://scripts/components/StompDamageComponent.cs" id="17_bl1gx"] [ext_resource type="Script" uid="uid://dtg6115je7b5s" path="res://scripts/components/StompDamageComponent.cs" id="17_bl1gx"]
@@ -39,7 +39,9 @@
[ext_resource type="PackedScene" uid="uid://dtem8jgcyoqar" path="res://objects/entities/green_laser.tscn" id="36_oxudy"] [ext_resource type="PackedScene" uid="uid://dtem8jgcyoqar" path="res://objects/entities/green_laser.tscn" id="36_oxudy"]
[ext_resource type="Script" uid="uid://dupnaark1f7gm" path="res://scripts/components/ProgressiveDamageComponent.cs" id="38_dhjci"] [ext_resource type="Script" uid="uid://dupnaark1f7gm" path="res://scripts/components/ProgressiveDamageComponent.cs" id="38_dhjci"]
[ext_resource type="Script" uid="uid://dssa2taiwktis" path="res://scripts/components/Movement/PlayerInputHandler.cs" id="42_e5pae"] [ext_resource type="Script" uid="uid://dssa2taiwktis" path="res://scripts/components/Movement/PlayerInputHandler.cs" id="42_e5pae"]
[ext_resource type="Script" uid="uid://c00siqtssccr6" path="res://scripts/components/PacXonGridInteractor.cs" id="42_xuhvf"]
[ext_resource type="Script" uid="uid://ceoxet1nqws8w" path="res://scripts/components/SpriteTilterComponent.cs" id="43_xuhvf"] [ext_resource type="Script" uid="uid://ceoxet1nqws8w" path="res://scripts/components/SpriteTilterComponent.cs" id="43_xuhvf"]
[ext_resource type="Script" uid="uid://cmk4m7mplqnrm" path="res://scripts/components/PacXonTrailComponent.cs" id="44_uno3u"]
[ext_resource type="Script" uid="uid://b1h8r5irryxcx" path="res://scripts/components/PlayerSfxComponent.cs" id="49_qec3q"] [ext_resource type="Script" uid="uid://b1h8r5irryxcx" path="res://scripts/components/PlayerSfxComponent.cs" id="49_qec3q"]
[ext_resource type="Script" uid="uid://b2aanqykvdnev" path="res://scripts/components/PlayerGraphicsComponent.cs" id="50_dhjci"] [ext_resource type="Script" uid="uid://b2aanqykvdnev" path="res://scripts/components/PlayerGraphicsComponent.cs" id="50_dhjci"]
@@ -98,6 +100,7 @@ GravityScene = ExtResource("4_qec3q")
OneWayPlatformScene = ExtResource("5_dhjci") OneWayPlatformScene = ExtResource("5_dhjci")
SpaceshipMovementScene = ExtResource("6_721q0") SpaceshipMovementScene = ExtResource("6_721q0")
WallJumpScene = ExtResource("7_bnap0") WallJumpScene = ExtResource("7_bnap0")
GridMovementScene = ExtResource("8_xuhvf")
metadata/_custom_type_script = "uid://csel4s0e4g5uf" metadata/_custom_type_script = "uid://csel4s0e4g5uf"
[node name="Movements" type="Node" parent="."] [node name="Movements" type="Node" parent="."]
@@ -182,11 +185,6 @@ script = ExtResource("13_7til7")
DeathSfx = NodePath("../sfx_hurt") DeathSfx = NodePath("../sfx_hurt")
HealthComponent = NodePath("../HealthComponent") HealthComponent = NodePath("../HealthComponent")
[node name="KnockbackComponent" type="Node" parent="." node_paths=PackedStringArray("HealthComponent")]
script = ExtResource("14_e5pae")
KnockbackForce = 1250.0
HealthComponent = NodePath("../HealthComponent")
[node name="InvulnerabilityComponent" type="Node" parent="." node_paths=PackedStringArray("FlashingComponent")] [node name="InvulnerabilityComponent" type="Node" parent="." node_paths=PackedStringArray("FlashingComponent")]
script = ExtResource("15_xuhvf") script = ExtResource("15_xuhvf")
FlashingComponent = NodePath("../FlashingComponent Base") FlashingComponent = NodePath("../FlashingComponent Base")
@@ -302,3 +300,11 @@ script = ExtResource("38_dhjci")
HealthComponent = NodePath("../HealthComponent") HealthComponent = NodePath("../HealthComponent")
Sprite = NodePath("../Graphics/Root/Base") Sprite = NodePath("../Graphics/Root/Base")
metadata/_custom_type_script = "uid://dupnaark1f7gm" metadata/_custom_type_script = "uid://dupnaark1f7gm"
[node name="PacXonGridInteractor" type="Node" parent="."]
script = ExtResource("42_xuhvf")
metadata/_custom_type_script = "uid://c00siqtssccr6"
[node name="PacXonTrailComponent" type="Line2D" parent="."]
script = ExtResource("44_uno3u")
metadata/_custom_type_script = "uid://cmk4m7mplqnrm"

View File

@@ -0,0 +1,41 @@
[gd_scene load_steps=6 format=3 uid="uid://un55bdc2cg2q"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_1nndd"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="2_bljtt"]
[ext_resource type="Script" uid="uid://nhu2xd8611fk" path="res://scripts/components/HazardComponent.cs" id="3_bljtt"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_14ml2"]
size = Vector2(14, 15)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4q8oh"]
size = Vector2(16, 16)
[node name="Cactus" type="StaticBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_14ml2")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_1nndd")
hframes = 12
vframes = 12
frame = 71
[node name="Area2D" type="Area2D" parent="."]
collision_mask = 12
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(-0.5, 0)
shape = SubResource("RectangleShape2D_4q8oh")
debug_color = Color(0.285572, 0.422655, 0.118384, 0.42)
[node name="KnockbackComponent" type="Node" parent="."]
script = ExtResource("2_bljtt")
metadata/_custom_type_script = "uid://cgfynrn68lp12"
[node name="HazardComponent" type="Node2D" parent="." node_paths=PackedStringArray("KnockbackComponent", "HazardArea")]
script = ExtResource("3_bljtt")
KnockbackComponent = NodePath("../KnockbackComponent")
HazardArea = NodePath("../Area2D")
metadata/_custom_type_script = "uid://nhu2xd8611fk"

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=27 format=3 uid="uid://bwdlmualj6xbw"] [gd_scene load_steps=28 format=3 uid="uid://bwdlmualj6xbw"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_ep4yr"] [ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_ep4yr"]
[ext_resource type="Texture2D" uid="uid://cu72810eyk4dx" path="res://sprites/enemy-robot.png" id="2_hjtwe"] [ext_resource type="Texture2D" uid="uid://cu72810eyk4dx" path="res://sprites/enemy-robot.png" id="2_hjtwe"]
@@ -18,6 +18,7 @@
[ext_resource type="PackedScene" uid="uid://dx80ivlvuuew4" path="res://objects/fxs/fire_fx.tscn" id="15_mc6rj"] [ext_resource type="PackedScene" uid="uid://dx80ivlvuuew4" path="res://objects/fxs/fire_fx.tscn" id="15_mc6rj"]
[ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="16_68hnm"] [ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="16_68hnm"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_pxaaa"] [ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_pxaaa"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="19_xku20"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwwji"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_pwwji"]
size = Vector2(25, 31) size = Vector2(25, 31)
@@ -182,3 +183,7 @@ visible = false
[node name="HitParticles" parent="." instance=ExtResource("18_pxaaa")] [node name="HitParticles" parent="." instance=ExtResource("18_pxaaa")]
position = Vector2(0, 1) position = Vector2(0, 1)
process_material = SubResource("ParticleProcessMaterial_pxaaa") process_material = SubResource("ParticleProcessMaterial_pxaaa")
[node name="KnockbackComponent" type="Node" parent="."]
script = ExtResource("19_xku20")
metadata/_custom_type_script = "uid://cgfynrn68lp12"

View File

@@ -0,0 +1,31 @@
[gd_scene load_steps=5 format=3 uid="uid://b3877xt5upsj2"]
[ext_resource type="Texture2D" uid="uid://dpbpjffbdbovp" path="res://sprites/cap.png" id="1_ksysq"]
[ext_resource type="Script" uid="uid://7i20oc4cyabl" path="res://scripts/components/GhostMovementComponent.cs" id="2_0qila"]
[sub_resource type="CircleShape2D" id="CircleShape2D_0xbgb"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ksysq"]
[node name="Ghost" type="CharacterBody2D"]
collision_layer = 8
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_0xbgb")
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(2.98023e-08, 0)
scale = Vector2(0.609375, 0.78125)
texture = ExtResource("1_ksysq")
[node name="GhostMovementComponent" type="Node2D" parent="."]
script = ExtResource("2_0qila")
metadata/_custom_type_script = "uid://7i20oc4cyabl"
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_ksysq")

View File

@@ -53,15 +53,19 @@ ease = 2
[node name="Brick Player" parent="." instance=ExtResource("1_lbnsn")] [node name="Brick Player" parent="." instance=ExtResource("1_lbnsn")]
[node name="HitParticles" parent="Brick Player" index="26"] [node name="HitParticles" parent="Brick Player" index="24"]
process_material = SubResource("ParticleProcessMaterial_lgb3u") process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="WorldEnvironment" parent="." instance=ExtResource("1_hb5r3")] [node name="WorldEnvironment" parent="." instance=ExtResource("1_hb5r3")]
[node name="UI Layer" parent="." instance=ExtResource("2_lbnsn")] [node name="UI Layer" parent="." instance=ExtResource("2_lbnsn")]
[node name="Marketplace" parent="UI Layer" index="3" node_paths=PackedStringArray("SkillUnlockerComponent")] [node name="HUD" parent="UI Layer" index="0" node_paths=PackedStringArray("Health")]
Health = NodePath("../../Brick Player/HealthComponent")
[node name="Marketplace" parent="UI Layer" index="3" node_paths=PackedStringArray("SkillUnlockerComponent", "ComponentsToDisable")]
SkillUnlockerComponent = NodePath("../../Brick Player/SkillUnlockerComponent") SkillUnlockerComponent = NodePath("../../Brick Player/SkillUnlockerComponent")
ComponentsToDisable = [NodePath("../../Brick Player")]
[node name="Global Light" parent="." instance=ExtResource("3_3732a")] [node name="Global Light" parent="." instance=ExtResource("3_3732a")]

View File

@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://dre1vit1m4d2n"]
[ext_resource type="Script" uid="uid://ctm5glmeu502l" path="res://scripts/components/Movement/GridMovementAbility.cs" id="1_xeoy8"]
[node name="GridMovementAbility" type="Node"]
script = ExtResource("1_xeoy8")
metadata/_custom_type_script = "uid://ctm5glmeu502l"

View File

@@ -12,6 +12,8 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
focus_neighbor_bottom = NodePath("PanelContainer/MarginContainer/VBoxContainer/ContinueButton")
focus_next = NodePath("PanelContainer/MarginContainer/VBoxContainer/ContinueButton")
script = ExtResource("1_epxpl") script = ExtResource("1_epxpl")
MainMenuControl = NodePath(".") MainMenuControl = NodePath(".")
NewGameButton = NodePath("PanelContainer/MarginContainer/VBoxContainer/NewGameButton") NewGameButton = NodePath("PanelContainer/MarginContainer/VBoxContainer/NewGameButton")
@@ -54,26 +56,42 @@ size_flags_vertical = 3
[node name="ContinueButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] [node name="ContinueButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
focus_neighbor_bottom = NodePath("../NewGameButton")
focus_next = NodePath("../NewGameButton")
text = "CONTINUE_BUTTON" text = "CONTINUE_BUTTON"
flat = true flat = true
[node name="NewGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] [node name="NewGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
focus_neighbor_top = NodePath("../ContinueButton")
focus_neighbor_bottom = NodePath("../SettingsButton")
focus_next = NodePath("../SettingsButton")
focus_previous = NodePath("../ContinueButton")
text = "NEW_GAME_BUTTON" text = "NEW_GAME_BUTTON"
flat = true flat = true
[node name="SettingsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] [node name="SettingsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
focus_neighbor_top = NodePath("../NewGameButton")
focus_neighbor_bottom = NodePath("../CreditsButton")
focus_next = NodePath("../CreditsButton")
focus_previous = NodePath("../NewGameButton")
text = "SETTINGS_BUTTON" text = "SETTINGS_BUTTON"
flat = true flat = true
[node name="CreditsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] [node name="CreditsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
focus_neighbor_top = NodePath("../SettingsButton")
focus_neighbor_bottom = NodePath("../QuitButton")
focus_next = NodePath("../QuitButton")
focus_previous = NodePath("../SettingsButton")
text = "CREDITS_BUTTON" text = "CREDITS_BUTTON"
flat = true flat = true
[node name="QuitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] [node name="QuitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
focus_neighbor_top = NodePath("../CreditsButton")
focus_previous = NodePath("../CreditsButton")
text = "QUIT_BUTTON" text = "QUIT_BUTTON"
flat = true flat = true

View File

@@ -99,6 +99,12 @@ ui_accept={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
] ]
} }
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
]
}
left={ left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)

View File

@@ -58,7 +58,7 @@ ease = 2
[node name="Brick Player" parent="." instance=ExtResource("1_dnj2y")] [node name="Brick Player" parent="." instance=ExtResource("1_dnj2y")]
z_index = 10 z_index = 10
[node name="HitParticles" parent="Brick Player" index="25"] [node name="HitParticles" parent="Brick Player" index="24"]
process_material = SubResource("ParticleProcessMaterial_lgb3u") process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="WorldEnvironment" parent="." instance=ExtResource("2_1vw1j")] [node name="WorldEnvironment" parent="." instance=ExtResource("2_1vw1j")]

View File

@@ -62,10 +62,10 @@ ease = 2
z_index = 1 z_index = 1
position = Vector2(-203, 9) position = Vector2(-203, 9)
[node name="HitParticles" parent="Brick Player" index="25"] [node name="HitParticles" parent="Brick Player" index="24"]
process_material = SubResource("ParticleProcessMaterial_lgb3u") process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="VisibleOnScreenNotifier2D" parent="Brick Player" index="28"] [node name="VisibleOnScreenNotifier2D" parent="Brick Player" index="27"]
process_mode = 4 process_mode = 4
[node name="WorldEnvironment" parent="." instance=ExtResource("2_ot3dy")] [node name="WorldEnvironment" parent="." instance=ExtResource("2_ot3dy")]

View File

@@ -0,0 +1,159 @@
[gd_scene load_steps=18 format=3 uid="uid://bljbcv22gq872"]
[ext_resource type="Script" uid="uid://dx4m2ouyvwkir" path="res://scripts/components/PacXonGridManager.cs" id="1_0g620"]
[ext_resource type="Texture2D" uid="uid://bolouq7v3acmx" path="res://sprites/pacxon_tileset.png" id="1_7fq4x"]
[ext_resource type="Script" uid="uid://b8lu5pdufiy37" path="res://scripts/PacXonLevel.cs" id="2_lbrge"]
[ext_resource type="PackedScene" uid="uid://bqi5s710xb1ju" path="res://objects/entities/brick_player.tscn" id="3_tehv8"]
[ext_resource type="Texture2D" uid="uid://dedn7c7464pg2" path="res://sprites/brick_pacxon.png" id="5_tn615"]
[ext_resource type="PackedScene" uid="uid://b3877xt5upsj2" path="res://objects/entities/ghost.tscn" id="6_8wuxa"]
[ext_resource type="Script" uid="uid://d23haq52m7ulv" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="7_7j16a"]
[ext_resource type="Script" uid="uid://ccfft4b8rwgbo" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="8_2w5m3"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_tn615"]
texture = ExtResource("1_7fq4x")
0:0/0 = 0
1:0/0 = 0
2:0/0 = 0
[sub_resource type="TileSet" id="TileSet_8wuxa"]
sources/0 = SubResource("TileSetAtlasSource_tn615")
[sub_resource type="Gradient" id="Gradient_qb72p"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_lgb3u"]
gradient = SubResource("Gradient_qb72p")
[sub_resource type="Curve" id="Curve_82d6e"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_xoue7"]
curve = SubResource("Curve_82d6e")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_lgb3u"]
resource_local_to_scene = true
lifetime_randomness = 1.0
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 8.0
direction = Vector3(0.1, -0.5, 0)
initial_velocity_min = 200.0
initial_velocity_max = 400.0
gravity = Vector3(0, 80, 0)
damping_min = 400.0
damping_max = 800.0
scale_max = 3.0
scale_curve = SubResource("CurveTexture_xoue7")
color = Color(0.764706, 0.443137, 0, 1)
color_ramp = SubResource("GradientTexture1D_lgb3u")
[sub_resource type="Resource" id="Resource_uptla"]
script = ExtResource("8_2w5m3")
duration = 1.0
transition = 0
ease = 2
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_7j16a"]
[node name="PacXonMiniGame" type="Node2D"]
[node name="PacXonGridManager" type="TileMapLayer" parent="."]
tile_set = SubResource("TileSet_8wuxa")
script = ExtResource("1_0g620")
PlayArea = Rect2i(1, 1, 27, 14)
metadata/_custom_type_script = "uid://dx4m2ouyvwkir"
[node name="PacXonLevel" type="Node" parent="." node_paths=PackedStringArray("Player", "GridManager", "GhostContainer", "PercentageLabel")]
script = ExtResource("2_lbrge")
Player = NodePath("../Brick Player")
GridManager = NodePath("../PacXonGridManager")
GhostContainer = NodePath("../Ghosts")
PercentageLabel = NodePath("../Label")
metadata/_custom_type_script = "uid://b8lu5pdufiy37"
[node name="Brick Player" parent="." instance=ExtResource("3_tehv8")]
position = Vector2(101, 213)
motion_mode = 1
metadata/_edit_group_ = true
[node name="GroundMovementAbility" parent="Brick Player/Movements" index="0"]
process_mode = 4
[node name="GravityAbility" parent="Brick Player/Movements" index="1"]
process_mode = 4
[node name="VariableJumpAbility" parent="Brick Player/Movements" index="2"]
process_mode = 4
[node name="OneWayPlatformAbility" parent="Brick Player/Movements" index="3"]
process_mode = 4
[node name="Base" parent="Brick Player/Graphics/Root" index="0"]
texture = ExtResource("5_tn615")
hframes = 1
[node name="Left Eye" parent="Brick Player/Graphics/Root" index="1"]
visible = false
[node name="Right Eye" parent="Brick Player/Graphics/Root" index="2"]
visible = false
[node name="HitParticles" parent="Brick Player" index="24"]
process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="VisibleOnScreenNotifier2D" parent="Brick Player" index="27"]
position = Vector2(0, -4.76837e-07)
scale = Vector2(0.8, 0.8)
[node name="Ghosts" type="Node2D" parent="."]
[node name="Ghost" parent="Ghosts" instance=ExtResource("6_8wuxa")]
position = Vector2(252, 155)
[node name="Label" type="Label" parent="."]
offset_left = 73.0
offset_right = 121.0
offset_bottom = 8.0
text = "sdsdsd"
[node name="PhantomCamera2D" type="Node2D" parent="."]
position = Vector2(-240, -135)
script = ExtResource("7_7j16a")
snap_to_pixel = true
tween_resource = SubResource("Resource_uptla")
draw_limits = true
limit_target = NodePath("../PacXonGridManager")
metadata/_custom_type_script = "uid://d23haq52m7ulv"
[node name="Word boundary top" type="StaticBody2D" parent="."]
position = Vector2(0, -2)
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Word boundary top"]
shape = SubResource("WorldBoundaryShape2D_7j16a")
[node name="Word boundary bottom" type="StaticBody2D" parent="."]
position = Vector2(0, 272)
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Word boundary bottom"]
shape = SubResource("WorldBoundaryShape2D_7j16a")
[node name="Word boundary left" type="StaticBody2D" parent="."]
position = Vector2(0, 272)
rotation = 1.5708
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Word boundary left"]
shape = SubResource("WorldBoundaryShape2D_7j16a")
[node name="Word boundary right" type="StaticBody2D" parent="."]
position = Vector2(482, 272)
rotation = -1.5708
collision_mask = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Word boundary right"]
shape = SubResource("WorldBoundaryShape2D_7j16a")
[editable path="Brick Player"]

59
scripts/PacXonLevel.cs Normal file
View File

@@ -0,0 +1,59 @@
using System.Linq;
using Godot;
using Mr.BrickAdventures.scripts.components;
namespace Mr.BrickAdventures.scripts;
[GlobalClass]
public partial class PacXonLevel : Node
{
[Export] public PlayerController Player { get; set; }
[Export] public PacXonGridManager GridManager { get; set; }
[Export] public Node GhostContainer { get; set; }
[Export] public Label PercentageLabel { get; set; }
private const float WinPercentage = 0.90f;
public override void _Ready()
{
var ghosts = GhostContainer.GetChildren().OfType<Node2D>().ToList();
Player.ClearMovementAbilities();
Player.SetGridMovement();
foreach (var ghost in ghosts)
{
var movement = ghost.GetNode<GhostMovementComponent>("GhostMovementComponent");
movement?.Initialize(GridManager, Player);
}
var gridMovement = Player.GetNodeOrNull<GridMovementAbility>("Movements/GridMovementAbility");
var gridInteractor = Player.GetNodeOrNull<PacXonGridInteractor>("PacXonGridInteractor");
var trailComponent = Player.GetNodeOrNull<PacXonTrailComponent>("PacXonTrailComponent");
if (gridMovement != null && gridInteractor != null)
{
gridInteractor.Initialize(GridManager, gridMovement, ghosts);
trailComponent?.Initialize(gridInteractor);
}
else
{
GD.PushError("Could not find GridMovementAbility or PacXonGridInteractor on Player.");
}
GridManager.FillPercentageChanged += OnFillPercentageChanged;
OnFillPercentageChanged(GridManager.GetFillPercentage());
var playerMapPos = GridManager.LocalToMap(Player.Position);
Player.GlobalPosition = GridManager.MapToLocal(playerMapPos);
}
private void OnFillPercentageChanged(float percentage)
{
PercentageLabel.Text = $"Fill: {percentage:P0}";
if (percentage >= WinPercentage)
{
GD.Print("YOU WIN!");
GetTree().Paused = true;
}
}
}

View File

@@ -0,0 +1 @@
uid://b8lu5pdufiy37

View File

@@ -12,11 +12,14 @@ public partial class DamageComponent : Node
[Export] public Timer DamageTimer { get; set; } [Export] public Timer DamageTimer { get; set; }
private Node _currentTarget = null; private Node _currentTarget = null;
private KnockbackComponent _knockbackComponent = null;
[Signal] public delegate void EffectInflictedEventHandler(Node2D target, StatusEffectDataResource effect); [Signal] public delegate void EffectInflictedEventHandler(Node2D target, StatusEffectDataResource effect);
public override void _Ready() public override void _Ready()
{ {
_knockbackComponent = Owner.GetNodeOrNull<KnockbackComponent>("KnockbackComponent");
if (Area != null) if (Area != null)
{ {
Area.BodyEntered += OnAreaBodyEntered; Area.BodyEntered += OnAreaBodyEntered;
@@ -93,6 +96,11 @@ public partial class DamageComponent : Node
DealDamage(health); DealDamage(health);
if (_knockbackComponent != null && body is CharacterBody2D characterBody && Owner is Node2D source)
{
_knockbackComponent.ApplyKnockback(characterBody, source);
}
inv?.Activate(); inv?.Activate();
} }

View File

@@ -0,0 +1,69 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class GhostMovementComponent : Node2D
{
[Export] public float MoveSpeed { get; set; } = 0.2f;
[Export] public int GridSize { get; set; } = 16;
private CharacterBody2D _body;
private Timer _moveTimer;
private PacXonGridManager _gridManager;
private HealthComponent _playerHealth;
private Vector2 _direction;
private readonly Vector2[] _directions = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
public override void _Ready()
{
_body = Owner.GetNode<CharacterBody2D>(".");
_moveTimer = new Timer { WaitTime = MoveSpeed, OneShot = false, Autostart = true };
AddChild(_moveTimer);
_moveTimer.Timeout += OnMoveTimerTimeout;
var rng = new RandomNumberGenerator();
_direction = _directions[rng.RandiRange(0, 3)];
}
public void Initialize(PacXonGridManager gridManager, PlayerController player)
{
_gridManager = gridManager;
_playerHealth = player.GetNode<HealthComponent>("HealthComponent");
}
private void OnMoveTimerTimeout()
{
if (_gridManager == null || _body == null) return;
var nextMapPos = _gridManager.LocalToMap(_body.Position + (_direction * GridSize));
var cellState = _gridManager.GetCellState(nextMapPos);
switch (cellState)
{
case CellState.Solid:
PickNewDirection();
break;
case CellState.Trail:
_playerHealth?.DecreaseHealth(9999);
_moveTimer.Stop();
break;
case CellState.Empty:
_body.Position += _direction * GridSize;
break;
}
}
private void PickNewDirection()
{
var rng = new RandomNumberGenerator();
Vector2 newDir;
do
{
newDir = _directions[rng.RandiRange(0, 3)];
} while (newDir == _direction || newDir == -_direction);
_direction = newDir;
}
}

View File

@@ -0,0 +1 @@
uid://7i20oc4cyabl

View File

@@ -0,0 +1,31 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class HazardComponent : Node2D
{
[Export] public KnockbackComponent KnockbackComponent { get; set; }
[Export] public Area2D HazardArea { get; set; }
public override void _Ready()
{
if (KnockbackComponent == null)
{
GD.PrintErr("HazardComponent requires a KnockbackComponent to function properly.");
SetProcess(false);
return;
}
HazardArea.BodyEntered += OnBodyEntered;
}
private void OnBodyEntered(Node2D body)
{
GD.Print($"Node {body.Name} entered hazard area.");
if (body is CharacterBody2D characterBody && Owner is Node2D source)
{
KnockbackComponent.ApplyKnockback(characterBody, source);
}
}
}

View File

@@ -0,0 +1 @@
uid://nhu2xd8611fk

View File

@@ -5,45 +5,33 @@ namespace Mr.BrickAdventures.scripts.components;
[GlobalClass] [GlobalClass]
public partial class KnockbackComponent : Node public partial class KnockbackComponent : Node
{ {
[Export] public CharacterBody2D Body { get; set; } [Export] public float KnockbackForce { get; set; } = 400f;
[Export] public float KnockbackForce { get; set; } = 25f; [Export] public float KnockbackDuration { get; set; } = 0.2f; // Duration in seconds
[Export] public HealthComponent HealthComponent { get; set; }
private bool _knockbackMode = false; /// <summary>
private int _knockbackFrames = 0; /// Applies a knockback force to a target body, pushing it away from a source.
/// </summary>
public override void _Ready() /// <param name="target">The CharacterBody2D to apply the knockback to.</param>
/// <param name="source">The Node2D causing the knockback (e.g., the enemy, the cactus).</param>
public void ApplyKnockback(CharacterBody2D target, Node2D source)
{ {
HealthComponent.HealthChanged += OnHealthChanged; if (target == null || source == null)
}
public override void _Process(double delta)
{ {
if (_knockbackMode) _knockbackFrames++; return;
if (_knockbackFrames <= 1) return;
_knockbackMode = false;
_knockbackFrames = 0;
} }
public override void _PhysicsProcess(double delta) var direction = (target.GlobalPosition - source.GlobalPosition).Normalized();
if (direction == Vector2.Zero)
{ {
if (_knockbackMode) ApplyKnockback((float)delta); direction = Vector2.Up;
} }
private void OnHealthChanged(float delta, float totalHealth) target.Velocity = direction * KnockbackForce;
{
if (totalHealth <= 0f || delta >= 0f) return;
_knockbackMode = true; var tween = CreateTween();
} tween.TweenProperty(target, "velocity", Vector2.Zero, KnockbackDuration)
.SetEase(Tween.EaseType.Out)
private void ApplyKnockback(float delta) .SetTrans(Tween.TransitionType.Quad);
{
var velocity = Body.Velocity.Normalized();
var knockbackDirection = new Vector2(Mathf.Sign(velocity.X), 0.4f);
var knockbackVector = -knockbackDirection * KnockbackForce * delta;
Body.Velocity += knockbackVector;
} }
} }

View File

@@ -0,0 +1,59 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class GridMovementAbility : MovementAbility
{
[Export] public float MoveSpeed { get; set; } = 0.15f; // Time in seconds between moves
[Export] public int GridSize { get; set; } = 16; // Size of one grid cell in pixels
private Vector2 _currentDirection = Vector2.Zero;
private Vector2 _nextDirection = Vector2.Zero;
private Timer _moveTimer;
[Signal]
public delegate void MovedEventHandler(Vector2 newPosition);
public override void Initialize(PlayerController controller)
{
base.Initialize(controller);
_moveTimer = new Timer { WaitTime = MoveSpeed, OneShot = false };
AddChild(_moveTimer);
_moveTimer.Timeout += OnMoveTimerTimeout;
_moveTimer.Start();
}
public override Vector2 ProcessMovement(Vector2 currentVelocity, double delta)
{
GD.Print($"Player position: {_body.Position}, {_body.GlobalPosition}");
var inputDirection = _input.MoveDirection;
var newDirection = Vector2.Zero;
if (Mathf.Abs(inputDirection.Y) > 0.1f)
{
newDirection = new Vector2(0, Mathf.Sign(inputDirection.Y));
}
else if (Mathf.Abs(inputDirection.X) > 0.1f)
{
newDirection = new Vector2(Mathf.Sign(inputDirection.X), 0);
}
if (newDirection != Vector2.Zero && newDirection != -_currentDirection)
{
_nextDirection = newDirection;
}
return Vector2.Zero;
}
private void OnMoveTimerTimeout()
{
_currentDirection = _nextDirection;
if (_currentDirection == Vector2.Zero) return;
_body.Position += _currentDirection * GridSize;
EmitSignal(SignalName.Moved, _body.GlobalPosition);
}
}

View File

@@ -0,0 +1 @@
uid://ctm5glmeu502l

View File

@@ -0,0 +1,91 @@
using System.Collections.Generic;
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class PacXonGridInteractor : Node
{
private enum PlayerGridState { OnSolid, DrawingTrail }
private PacXonGridManager _gridManager;
private HealthComponent _healthComponent;
private GridMovementAbility _gridMovement;
private PlayerGridState _currentState = PlayerGridState.OnSolid;
private readonly List<Vector2I> _currentTrail = [];
private List<Node2D> _ghosts = [];
[Signal] public delegate void TrailStartedEventHandler(Vector2 startPosition);
[Signal] public delegate void TrailExtendedEventHandler(Vector2 newPosition);
[Signal] public delegate void TrailClearedEventHandler();
public override void _Ready()
{
_healthComponent = Owner.GetNodeOrNull<HealthComponent>("HealthComponent");
}
public void Initialize(PacXonGridManager gridManager, GridMovementAbility gridMovement, List<Node2D> ghosts)
{
_gridManager = gridManager;
_gridMovement = gridMovement;
_ghosts = ghosts;
_gridMovement.Moved += OnPlayerMoved;
}
private void OnPlayerMoved(Vector2 newPosition)
{
if (_gridManager == null) return;
var mapCoords = _gridManager.LocalToMap(newPosition);
var destinationState = _gridManager.GetCellState(mapCoords);
if (_currentState == PlayerGridState.DrawingTrail) EmitSignalTrailExtended(newPosition);
if (destinationState == CellState.Trail)
{
EmitSignalTrailCleared();
_healthComponent?.DecreaseHealth(9999);
return;
}
if (_currentState == PlayerGridState.OnSolid)
{
if (destinationState == CellState.Empty)
{
// Moved from solid ground to an empty space, start drawing.
_currentState = PlayerGridState.DrawingTrail;
_currentTrail.Clear();
_currentTrail.Add(mapCoords);
_gridManager.SetCellState(mapCoords, CellState.Trail);
EmitSignalTrailStarted(newPosition);
}
}
else if (_currentState == PlayerGridState.DrawingTrail)
{
if (destinationState == CellState.Empty)
{
// Continue drawing the trail
_currentTrail.Add(mapCoords);
_gridManager.SetCellState(mapCoords, CellState.Trail);
}
else if (destinationState == CellState.Solid)
{
_gridManager.PerformFloodFill(_ghosts);
GD.Print("Fill logic triggered!");
_currentState = PlayerGridState.OnSolid;
SolidifyTrail();
_currentTrail.Clear();
EmitSignalTrailCleared();
}
}
}
private void SolidifyTrail()
{
foreach (var pos in _currentTrail)
{
_gridManager.SetCellState(pos, CellState.Solid);
}
}
}

View File

@@ -0,0 +1 @@
uid://c00siqtssccr6

View File

@@ -0,0 +1,121 @@
using System.Collections.Generic;
using System.Linq;
using Godot;
namespace Mr.BrickAdventures.scripts.components;
public enum CellState
{
Empty = -1,
Solid = 0,
Trail = 1,
Hunted = 2
}
[GlobalClass]
public partial class PacXonGridManager : TileMapLayer
{
[Export] public Rect2I PlayArea { get; set; } = new Rect2I(1, 1, 38, 28);
private int _solidCellCount = 0;
private int _totalPlayableCells = 0;
[Signal] public delegate void FillPercentageChangedEventHandler(float percentage);
public override void _Ready()
{
_totalPlayableCells = PlayArea.Size.X * PlayArea.Size.Y;
InitializeGrid();
}
private void InitializeGrid()
{
Clear();
for (var x = PlayArea.Position.X - 1; x <= PlayArea.End.X + 1; x++)
{
for (var y = PlayArea.Position.Y - 1; y <= PlayArea.End.Y + 1; y++)
{
if (x < PlayArea.Position.X || x > PlayArea.End.X || y < PlayArea.Position.Y || y > PlayArea.End.Y)
{
SetCell(new Vector2I(x, y), (int)CellState.Solid, Vector2I.Zero);
}
}
}
}
public CellState GetCellState(Vector2I mapCoords)
{
var tileId = GetCellSourceId(mapCoords);
return (CellState)tileId;
}
public void SetCellState(Vector2I mapCoords, CellState state)
{
if (GetCellSourceId(mapCoords) != (int)CellState.Solid && state == CellState.Solid) _solidCellCount++;
SetCell(mapCoords, (int)state, Vector2I.Zero);
}
public float GetFillPercentage()
{
return _totalPlayableCells > 0 ? (float)_solidCellCount / _totalPlayableCells : 0;
}
public void PerformFloodFill(List<Node2D> ghosts)
{
var unsafeCells = new HashSet<Vector2I>();
foreach (var ghost in ghosts.Where(IsInstanceValid))
{
var ghostPos = LocalToMap(ghost.Position);
FloodFillScan(ghostPos, unsafeCells);
}
var filledCount = 0;
for (var x = PlayArea.Position.X; x <= PlayArea.End.X; x++)
{
for (var y = PlayArea.Position.Y; y <= PlayArea.End.Y; y++)
{
var currentPos = new Vector2I(x, y);
if (GetCellState(currentPos) == CellState.Empty && !unsafeCells.Contains(currentPos))
{
SetCellState(currentPos, CellState.Solid);
filledCount++;
}
}
}
if (filledCount > 0)
{
EmitSignal(SignalName.FillPercentageChanged, GetFillPercentage());
}
}
private void FloodFillScan(Vector2I startPos, HashSet<Vector2I> visited)
{
if (!PlayArea.HasPoint(startPos) || visited.Contains(startPos)) return;
var q = new Queue<Vector2I>();
q.Enqueue(startPos);
visited.Add(startPos);
while (q.Count > 0)
{
var pos = q.Dequeue();
var neighbors = new[]
{
pos + Vector2I.Up, pos + Vector2I.Down, pos + Vector2I.Left, pos + Vector2I.Right
};
foreach (var neighbor in neighbors)
{
if (PlayArea.HasPoint(neighbor) && !visited.Contains(neighbor) && GetCellState(neighbor) == CellState.Empty)
{
visited.Add(neighbor);
q.Enqueue(neighbor);
}
}
}
}
}

View File

@@ -0,0 +1 @@
uid://dx4m2ouyvwkir

View File

@@ -0,0 +1,67 @@
using System.Collections.Generic;
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class PacXonTrailComponent : Line2D
{
private PacXonGridInteractor _gridInteractor;
private readonly List<Vector2> _trailPoints = [];
public void Initialize(PacXonGridInteractor interactor)
{
_gridInteractor = interactor;
_gridInteractor.TrailStarted += OnTrailStarted;
_gridInteractor.TrailExtended += OnTrailExtended;
_gridInteractor.TrailCleared += OnTrailCleared;
Width = 8;
DefaultColor = new Color("#a6f684");
JointMode = LineJointMode.Round;
BeginCapMode = LineCapMode.Round;
EndCapMode = LineCapMode.Round;
}
public override void _ExitTree()
{
if (_gridInteractor != null)
{
_gridInteractor.TrailStarted -= OnTrailStarted;
_gridInteractor.TrailExtended -= OnTrailExtended;
_gridInteractor.TrailCleared -= OnTrailCleared;
}
}
private void OnTrailStarted(Vector2 startPosition)
{
_trailPoints.Clear();
_trailPoints.Add(ToLocal(startPosition));
_trailPoints.Add(ToLocal(startPosition));
UpdateTrail();
}
private void OnTrailExtended(Vector2 newPosition)
{
if (_trailPoints.Count > 0)
{
_trailPoints[^1] = ToLocal(newPosition);
}
UpdateTrail();
}
private void OnTrailCleared()
{
_trailPoints.Clear();
UpdateTrail();
}
private void UpdateTrail()
{
ClearPoints();
foreach (var point in _trailPoints)
{
AddPoint(point);
}
}
}

View File

@@ -0,0 +1 @@
uid://cmk4m7mplqnrm

View File

@@ -18,6 +18,7 @@ public partial class PlayerController : CharacterBody2D
[Export] public PackedScene OneWayPlatformScene { get; set; } [Export] public PackedScene OneWayPlatformScene { get; set; }
[Export] public PackedScene SpaceshipMovementScene { get; set; } [Export] public PackedScene SpaceshipMovementScene { get; set; }
[Export] public PackedScene WallJumpScene { get; set; } [Export] public PackedScene WallJumpScene { get; set; }
[Export] public PackedScene GridMovementScene { get; set; }
[Signal] public delegate void JumpInitiatedEventHandler(); [Signal] public delegate void JumpInitiatedEventHandler();
[Signal] public delegate void MovementAbilitiesChangedEventHandler(); [Signal] public delegate void MovementAbilitiesChangedEventHandler();
@@ -75,7 +76,7 @@ public partial class PlayerController : CharacterBody2D
_abilities.Add(ability); _abilities.Add(ability);
} }
private void ClearMovementAbilities() public void ClearMovementAbilities()
{ {
foreach (var ability in _abilities) foreach (var ability in _abilities)
{ {
@@ -119,6 +120,13 @@ public partial class PlayerController : CharacterBody2D
EmitSignalMovementAbilitiesChanged(); EmitSignalMovementAbilitiesChanged();
} }
public void SetGridMovement()
{
ClearMovementAbilities();
if (GridMovementScene != null) AddAbility(GridMovementScene.Instantiate<MovementAbility>());
EmitSignalMovementAbilitiesChanged();
}
private async Task ConnectJumpAndGravityAbilities() private async Task ConnectJumpAndGravityAbilities()
{ {
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);

BIN
sprites/brick_pacxon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dedn7c7464pg2"
path="res://.godot/imported/brick_pacxon.png-5ed91e7ecc9f90e9d888bcdf71d54f77.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/brick_pacxon.png"
dest_files=["res://.godot/imported/brick_pacxon.png-5ed91e7ecc9f90e9d888bcdf71d54f77.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
sprites/pacxon_tileset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bolouq7v3acmx"
path="res://.godot/imported/pacxon_tileset.png-d5a671b56c1f3b25f32c1372daae2944.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/pacxon_tileset.png"
dest_files=["res://.godot/imported/pacxon_tileset.png-d5a671b56c1f3b25f32c1372daae2944.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1