From 5f95fcf173ca402b4fb4045e58f200ccff6caa20 Mon Sep 17 00:00:00 2001 From: John Ludlow Date: Mon, 26 Aug 2024 23:42:17 +0100 Subject: [PATCH] #16 Udemy 2.5D RPG Player state machine --- .../Player/Kicking/Kicking_000.png.import | 13 +- .../Player/Kicking/Kicking_001.png.import | 13 +- .../Player/Kicking/Kicking_002.png.import | 13 +- .../Player/Kicking/Kicking_003.png.import | 13 +- .../Player/Kicking/Kicking_004.png.import | 13 +- .../Player/Kicking/Kicking_005.png.import | 13 +- .../Player/Kicking/Kicking_006.png.import | 13 +- .../Player/Kicking/Kicking_007.png.import | 13 +- .../Player/Kicking/Kicking_008.png.import | 13 +- .../Player/Kicking/Kicking_009.png.import | 13 +- .../Player/Kicking/Kicking_010.png.import | 13 +- .../Player/Kicking/Kicking_011.png.import | 13 +- .../Player/Sliding/Sliding_000.png.import | 9 +- .../Player/Sliding/Sliding_001.png.import | 9 +- .../Player/Sliding/Sliding_002.png.import | 9 +- .../Player/Sliding/Sliding_003.png.import | 9 +- .../Player/Sliding/Sliding_004.png.import | 9 +- .../Player/Sliding/Sliding_005.png.import | 9 +- Udemy25dRpg/Scenes/Characters/Player.cs | 35 +-- Udemy25dRpg/Scenes/Characters/Player.tscn | 292 ++++++++++++------ .../Scenes/Characters/PlayerDashState.cs | 54 ++++ .../Scenes/Characters/PlayerIdleState.cs | 28 +- .../Scenes/Characters/PlayerKickingState.cs | 15 + .../Scenes/Characters/PlayerMoveState.cs | 41 ++- .../Scenes/Characters/PlayerStateBase.cs | 34 ++ Udemy25dRpg/Scenes/Characters/StateMachine.cs | 6 +- Udemy25dRpg/project.godot | 10 + 27 files changed, 479 insertions(+), 246 deletions(-) create mode 100644 Udemy25dRpg/Scenes/Characters/PlayerDashState.cs create mode 100644 Udemy25dRpg/Scenes/Characters/PlayerKickingState.cs create mode 100644 Udemy25dRpg/Scenes/Characters/PlayerStateBase.cs diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_000.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_000.png.import index b99c57d..2097186 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_000.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_000.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://nl6eh3k7jex4" -path="res://.godot/imported/Kicking_000.png-b2bbb411b80d3c0daee920995fa2b4b9.ctex" +path.s3tc="res://.godot/imported/Kicking_000.png-b2bbb411b80d3c0daee920995fa2b4b9.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_000.png" -dest_files=["res://.godot/imported/Kicking_000.png-b2bbb411b80d3c0daee920995fa2b4b9.ctex"] +dest_files=["res://.godot/imported/Kicking_000.png-b2bbb411b80d3c0daee920995fa2b4b9.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_001.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_001.png.import index 35053e8..81c0a8b 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_001.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_001.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://75egxtvtldom" -path="res://.godot/imported/Kicking_001.png-50391597a9637d0a8d75fabb0ddd4fb3.ctex" +path.s3tc="res://.godot/imported/Kicking_001.png-50391597a9637d0a8d75fabb0ddd4fb3.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_001.png" -dest_files=["res://.godot/imported/Kicking_001.png-50391597a9637d0a8d75fabb0ddd4fb3.ctex"] +dest_files=["res://.godot/imported/Kicking_001.png-50391597a9637d0a8d75fabb0ddd4fb3.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_002.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_002.png.import index 48833ee..5c2acf2 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_002.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_002.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://ca5poo205xpqk" -path="res://.godot/imported/Kicking_002.png-340f07304428a6d8da7fff60577983d4.ctex" +path.s3tc="res://.godot/imported/Kicking_002.png-340f07304428a6d8da7fff60577983d4.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_002.png" -dest_files=["res://.godot/imported/Kicking_002.png-340f07304428a6d8da7fff60577983d4.ctex"] +dest_files=["res://.godot/imported/Kicking_002.png-340f07304428a6d8da7fff60577983d4.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_003.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_003.png.import index fd47843..1890630 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_003.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_003.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dmmdl8av8vnjh" -path="res://.godot/imported/Kicking_003.png-c7ea12548440f710a0bcee9c3bf860d2.ctex" +path.s3tc="res://.godot/imported/Kicking_003.png-c7ea12548440f710a0bcee9c3bf860d2.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_003.png" -dest_files=["res://.godot/imported/Kicking_003.png-c7ea12548440f710a0bcee9c3bf860d2.ctex"] +dest_files=["res://.godot/imported/Kicking_003.png-c7ea12548440f710a0bcee9c3bf860d2.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_004.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_004.png.import index ae3b2b9..9c68ec3 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_004.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_004.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://c0e2lkwh8pug8" -path="res://.godot/imported/Kicking_004.png-75e2005b2f60a3404e80065d0fc85cba.ctex" +path.s3tc="res://.godot/imported/Kicking_004.png-75e2005b2f60a3404e80065d0fc85cba.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_004.png" -dest_files=["res://.godot/imported/Kicking_004.png-75e2005b2f60a3404e80065d0fc85cba.ctex"] +dest_files=["res://.godot/imported/Kicking_004.png-75e2005b2f60a3404e80065d0fc85cba.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_005.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_005.png.import index b538e59..cd6ac75 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_005.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_005.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://iw1x6vq1koq3" -path="res://.godot/imported/Kicking_005.png-ea51966d6e6ca7097b9d3013aaafce2b.ctex" +path.s3tc="res://.godot/imported/Kicking_005.png-ea51966d6e6ca7097b9d3013aaafce2b.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_005.png" -dest_files=["res://.godot/imported/Kicking_005.png-ea51966d6e6ca7097b9d3013aaafce2b.ctex"] +dest_files=["res://.godot/imported/Kicking_005.png-ea51966d6e6ca7097b9d3013aaafce2b.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_006.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_006.png.import index 291de5e..dc64d8d 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_006.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_006.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://ch2kjq2341kk5" -path="res://.godot/imported/Kicking_006.png-59cde9887ad15631ce6d8416ff7afdf6.ctex" +path.s3tc="res://.godot/imported/Kicking_006.png-59cde9887ad15631ce6d8416ff7afdf6.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_006.png" -dest_files=["res://.godot/imported/Kicking_006.png-59cde9887ad15631ce6d8416ff7afdf6.ctex"] +dest_files=["res://.godot/imported/Kicking_006.png-59cde9887ad15631ce6d8416ff7afdf6.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_007.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_007.png.import index 54e5bd9..a7af324 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_007.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_007.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://buk3jem1k5h35" -path="res://.godot/imported/Kicking_007.png-d1f9ca29083ee4250dffd651c6e231e6.ctex" +path.s3tc="res://.godot/imported/Kicking_007.png-d1f9ca29083ee4250dffd651c6e231e6.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_007.png" -dest_files=["res://.godot/imported/Kicking_007.png-d1f9ca29083ee4250dffd651c6e231e6.ctex"] +dest_files=["res://.godot/imported/Kicking_007.png-d1f9ca29083ee4250dffd651c6e231e6.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_008.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_008.png.import index 28f99b0..6a1ac8d 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_008.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_008.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dpfxmgacf2si8" -path="res://.godot/imported/Kicking_008.png-3b2a5e334cebabae5c4191faa0f58fc5.ctex" +path.s3tc="res://.godot/imported/Kicking_008.png-3b2a5e334cebabae5c4191faa0f58fc5.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_008.png" -dest_files=["res://.godot/imported/Kicking_008.png-3b2a5e334cebabae5c4191faa0f58fc5.ctex"] +dest_files=["res://.godot/imported/Kicking_008.png-3b2a5e334cebabae5c4191faa0f58fc5.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_009.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_009.png.import index 08dd6de..400d2e5 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_009.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_009.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://b44c51mgblifd" -path="res://.godot/imported/Kicking_009.png-b1ac29f8af14b20b717532a879482c74.ctex" +path.s3tc="res://.godot/imported/Kicking_009.png-b1ac29f8af14b20b717532a879482c74.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_009.png" -dest_files=["res://.godot/imported/Kicking_009.png-b1ac29f8af14b20b717532a879482c74.ctex"] +dest_files=["res://.godot/imported/Kicking_009.png-b1ac29f8af14b20b717532a879482c74.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_010.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_010.png.import index 345a720..3622581 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_010.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_010.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://d25iiuab77jhw" -path="res://.godot/imported/Kicking_010.png-cbd8085fbb07e25aca01db9a88661bc9.ctex" +path.s3tc="res://.godot/imported/Kicking_010.png-cbd8085fbb07e25aca01db9a88661bc9.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_010.png" -dest_files=["res://.godot/imported/Kicking_010.png-cbd8085fbb07e25aca01db9a88661bc9.ctex"] +dest_files=["res://.godot/imported/Kicking_010.png-cbd8085fbb07e25aca01db9a88661bc9.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_011.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_011.png.import index 9646f6d..fb1e787 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_011.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Kicking/Kicking_011.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dbgjebrr1akou" -path="res://.godot/imported/Kicking_011.png-1c05622133a47699826b27a810899d80.ctex" +path.s3tc="res://.godot/imported/Kicking_011.png-1c05622133a47699826b27a810899d80.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Assets/Sprites/Characters/Player/Kicking/Kicking_011.png" -dest_files=["res://.godot/imported/Kicking_011.png-1c05622133a47699826b27a810899d80.ctex"] +dest_files=["res://.godot/imported/Kicking_011.png-1c05622133a47699826b27a810899d80.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ 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 +detect_3d/compress_to=0 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_000.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_000.png.import index 3edb269..1f47a05 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_000.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_000.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://cfdxw0sp2nvjx" -path.s3tc="res://.godot/imported/Sliding_000.png-3feb80365700fdc5bb956e2043f2270e.s3tc.ctex" +path="res://.godot/imported/Sliding_000.png-3feb80365700fdc5bb956e2043f2270e.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_000.png" -dest_files=["res://.godot/imported/Sliding_000.png-3feb80365700fdc5bb956e2043f2270e.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_000.png-3feb80365700fdc5bb956e2043f2270e.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_001.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_001.png.import index b7a50e1..ab4f878 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_001.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_001.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://cgqfsw1vb5hxj" -path.s3tc="res://.godot/imported/Sliding_001.png-49bc6134449d5271e4053234cd587831.s3tc.ctex" +path="res://.godot/imported/Sliding_001.png-49bc6134449d5271e4053234cd587831.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_001.png" -dest_files=["res://.godot/imported/Sliding_001.png-49bc6134449d5271e4053234cd587831.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_001.png-49bc6134449d5271e4053234cd587831.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_002.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_002.png.import index 5262229..df04427 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_002.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_002.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://ce21e5068dl3o" -path.s3tc="res://.godot/imported/Sliding_002.png-d0ceae490a69a5b0d964c3103a8179a7.s3tc.ctex" +path="res://.godot/imported/Sliding_002.png-d0ceae490a69a5b0d964c3103a8179a7.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_002.png" -dest_files=["res://.godot/imported/Sliding_002.png-d0ceae490a69a5b0d964c3103a8179a7.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_002.png-d0ceae490a69a5b0d964c3103a8179a7.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_003.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_003.png.import index 4ff48c4..7b3adb6 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_003.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_003.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://cuvd240px1abr" -path.s3tc="res://.godot/imported/Sliding_003.png-b0b6373faeccdd26f26e10e49d6396db.s3tc.ctex" +path="res://.godot/imported/Sliding_003.png-b0b6373faeccdd26f26e10e49d6396db.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_003.png" -dest_files=["res://.godot/imported/Sliding_003.png-b0b6373faeccdd26f26e10e49d6396db.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_003.png-b0b6373faeccdd26f26e10e49d6396db.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_004.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_004.png.import index a0439b3..50d92d8 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_004.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_004.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://d2i35uyqiwilh" -path.s3tc="res://.godot/imported/Sliding_004.png-cc89d30902ce1e465a4fc928acbcf609.s3tc.ctex" +path="res://.godot/imported/Sliding_004.png-cc89d30902ce1e465a4fc928acbcf609.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_004.png" -dest_files=["res://.godot/imported/Sliding_004.png-cc89d30902ce1e465a4fc928acbcf609.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_004.png-cc89d30902ce1e465a4fc928acbcf609.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_005.png.import b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_005.png.import index 5efe79b..5f9f550 100644 --- a/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_005.png.import +++ b/Udemy25dRpg/Assets/Sprites/Characters/Player/Sliding/Sliding_005.png.import @@ -3,20 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://bdv4ygt2vid7x" -path.s3tc="res://.godot/imported/Sliding_005.png-c3e0eac8d1977275d967e42adad25212.s3tc.ctex" +path="res://.godot/imported/Sliding_005.png-c3e0eac8d1977275d967e42adad25212.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Assets/Sprites/Characters/Player/Sliding/Sliding_005.png" -dest_files=["res://.godot/imported/Sliding_005.png-c3e0eac8d1977275d967e42adad25212.s3tc.ctex"] +dest_files=["res://.godot/imported/Sliding_005.png-c3e0eac8d1977275d967e42adad25212.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Udemy25dRpg/Scenes/Characters/Player.cs b/Udemy25dRpg/Scenes/Characters/Player.cs index e0363c1..8f717ec 100644 --- a/Udemy25dRpg/Scenes/Characters/Player.cs +++ b/Udemy25dRpg/Scenes/Characters/Player.cs @@ -8,22 +8,24 @@ public enum PlayerInputs { MoveLeft, MoveRight, MoveForward, - MoveBackward + MoveBackward, + Dash, + Kick, } public enum PlayerAnimations { Idle, Move, + Dash, + Kick, } - [Export] + + [Export, ExportGroup("Required Nodes")] public StateMachine StateMachineNode { get; private set; } - [Export, ExportGroup("Required Nodes")] - public AnimationPlayer AnimationPlayerNode {get; private set;} - - [Export, ExportGroup("Required Nodes")] - public Sprite3D SpriteNode {get; private set;} + [Export, ExportGroup("Required Nodes")] + public AnimatedSprite3D AnimatedSprite3DNode {get; private set;} public Vector2 Direction {get; private set;} = Vector2.Zero; @@ -33,17 +35,6 @@ public override void _Ready() StateMachineNode.SwitchState(); } - public override void _PhysicsProcess(double delta) - { - Velocity = new( - Direction.X * 5, - 0, - Direction.Y * 5 - ); - - MoveAndSlide(); - } - public override void _Input(InputEvent @event) { Direction = Input.GetVector( @@ -52,19 +43,17 @@ public override void _Input(InputEvent @event) nameof(PlayerInputs.MoveForward), nameof(PlayerInputs.MoveBackward) ); - - FlipSprite(); } - private void FlipSprite() + public void FlipSprite() { if (Direction.X < 0) { - SpriteNode.FlipH = true; + AnimatedSprite3DNode.FlipH = true; } else if (Direction.X > 0) { - SpriteNode.FlipH = false; + AnimatedSprite3DNode.FlipH = false; } } diff --git a/Udemy25dRpg/Scenes/Characters/Player.tscn b/Udemy25dRpg/Scenes/Characters/Player.tscn index 3d81140..bf5b8b3 100644 --- a/Udemy25dRpg/Scenes/Characters/Player.tscn +++ b/Udemy25dRpg/Scenes/Characters/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=45 format=3 uid="uid://2als0j8j6wxe"] +[gd_scene load_steps=56 format=3 uid="uid://2als0j8j6wxe"] [ext_resource type="Script" path="res://Scenes/Characters/Player.cs" id="1_huxwr"] [ext_resource type="Texture2D" uid="uid://y4hs6pyks4tw" path="res://Assets/Sprites/Characters/Player/Idle Blinking/Idle Blinking_000.png" id="2_2r0yv"] @@ -26,115 +26,229 @@ [ext_resource type="Texture2D" uid="uid://bbh1ybwfopd2l" path="res://Assets/Sprites/Characters/Player/Running/Running_004.png" id="24_mfk1q"] [ext_resource type="Texture2D" uid="uid://lgwqg27pcm7e" path="res://Assets/Sprites/Characters/Player/Running/Running_005.png" id="25_f3408"] [ext_resource type="Texture2D" uid="uid://d1kr8nrpaysjx" path="res://Assets/Sprites/Characters/Player/Running/Running_006.png" id="26_l8clm"] +[ext_resource type="Texture2D" uid="uid://nl6eh3k7jex4" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_000.png" id="26_ou41i"] +[ext_resource type="Texture2D" uid="uid://75egxtvtldom" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_001.png" id="27_4gmpt"] [ext_resource type="Texture2D" uid="uid://b4bjaxiy3c8xu" path="res://Assets/Sprites/Characters/Player/Running/Running_007.png" id="27_upi8d"] [ext_resource type="Texture2D" uid="uid://crc78osoffq5n" path="res://Assets/Sprites/Characters/Player/Running/Running_009.png" id="28_10fk6"] +[ext_resource type="Texture2D" uid="uid://ca5poo205xpqk" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_002.png" id="28_dvjhk"] +[ext_resource type="Texture2D" uid="uid://c8awvf3gbdeoo" path="res://Assets/Sprites/Characters/Player/Running/Running_008.png" id="28_e5uih"] +[ext_resource type="Texture2D" uid="uid://dmmdl8av8vnjh" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_003.png" id="29_i8hfx"] [ext_resource type="Texture2D" uid="uid://c1ul17mmjdtrr" path="res://Assets/Sprites/Characters/Player/Running/Running_010.png" id="29_q8a1u"] [ext_resource type="Texture2D" uid="uid://qllkdhs3ann1" path="res://Assets/Sprites/Characters/Player/Running/Running_011.png" id="30_68kny"] +[ext_resource type="Texture2D" uid="uid://c0e2lkwh8pug8" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_004.png" id="30_qlj7e"] +[ext_resource type="Texture2D" uid="uid://iw1x6vq1koq3" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_005.png" id="31_d7bf5"] [ext_resource type="Texture2D" uid="uid://cfdxw0sp2nvjx" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_000.png" id="31_mg83m"] [ext_resource type="Script" path="res://Scenes/Characters/PlayerIdleState.cs" id="31_w18mu"] +[ext_resource type="Texture2D" uid="uid://ch2kjq2341kk5" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_006.png" id="32_dq8nx"] [ext_resource type="Texture2D" uid="uid://cgqfsw1vb5hxj" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_001.png" id="32_gvagx"] [ext_resource type="Script" path="res://Scenes/Characters/PlayerMoveState.cs" id="32_vc70e"] [ext_resource type="Script" path="res://Scenes/Characters/StateMachine.cs" id="33_8uwin"] [ext_resource type="Texture2D" uid="uid://ce21e5068dl3o" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_002.png" id="33_aoq6e"] +[ext_resource type="Texture2D" uid="uid://buk3jem1k5h35" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_007.png" id="33_uuuus"] [ext_resource type="Texture2D" uid="uid://cuvd240px1abr" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_003.png" id="34_356xb"] +[ext_resource type="Texture2D" uid="uid://dpfxmgacf2si8" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_008.png" id="34_dsv52"] +[ext_resource type="Texture2D" uid="uid://b44c51mgblifd" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_009.png" id="35_6xrls"] [ext_resource type="Texture2D" uid="uid://d2i35uyqiwilh" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_004.png" id="35_43qmd"] +[ext_resource type="Texture2D" uid="uid://d25iiuab77jhw" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_010.png" id="36_06eso"] [ext_resource type="Texture2D" uid="uid://bdv4ygt2vid7x" path="res://Assets/Sprites/Characters/Player/Sliding/Sliding_005.png" id="36_vn2yp"] +[ext_resource type="Texture2D" uid="uid://dbgjebrr1akou" path="res://Assets/Sprites/Characters/Player/Kicking/Kicking_011.png" id="37_flpgl"] +[ext_resource type="Script" path="res://Scenes/Characters/PlayerDashState.cs" id="41_7ie7a"] +[ext_resource type="Script" path="res://Scenes/Characters/PlayerKickingState.cs" id="54_s5rbi"] -[sub_resource type="Animation" id="Animation_yuolr"] -resource_name = "Idle" -loop_mode = 1 -step = 0.0555556 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite3D:texture") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.0555556, 0.111111, 0.166667, 0.222222, 0.277778, 0.333333, 0.388889, 0.444444, 0.5, 0.555556, 0.611111, 0.666667, 0.722222, 0.777778, 0.833333, 0.888889, 0.944444), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [ExtResource("2_2r0yv"), ExtResource("3_5244l"), ExtResource("4_w2fvd"), ExtResource("5_02man"), ExtResource("6_n1o0m"), ExtResource("7_jiwfe"), ExtResource("8_4t3w0"), ExtResource("9_qjern"), ExtResource("10_4du0f"), ExtResource("11_1j7to"), ExtResource("12_t04pj"), ExtResource("13_4o6oj"), ExtResource("14_ajd7b"), ExtResource("15_tjtiv"), ExtResource("16_ct13p"), ExtResource("17_re4aw"), ExtResource("18_jmelb"), ExtResource("19_yuvqx")] -} +[sub_resource type="SpriteFrames" id="SpriteFrames_4gqhn"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("31_mg83m") +}, { +"duration": 1.0, +"texture": ExtResource("32_gvagx") +}, { +"duration": 1.0, +"texture": ExtResource("33_aoq6e") +}, { +"duration": 1.0, +"texture": ExtResource("34_356xb") +}, { +"duration": 1.0, +"texture": ExtResource("35_43qmd") +}, { +"duration": 1.0, +"texture": ExtResource("36_vn2yp") +}], +"loop": true, +"name": &"Dash", +"speed": 6.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_2r0yv") +}, { +"duration": 1.0, +"texture": ExtResource("3_5244l") +}, { +"duration": 1.0, +"texture": ExtResource("4_w2fvd") +}, { +"duration": 1.0, +"texture": ExtResource("5_02man") +}, { +"duration": 1.0, +"texture": ExtResource("6_n1o0m") +}, { +"duration": 1.0, +"texture": ExtResource("7_jiwfe") +}, { +"duration": 1.0, +"texture": ExtResource("8_4t3w0") +}, { +"duration": 1.0, +"texture": ExtResource("9_qjern") +}, { +"duration": 1.0, +"texture": ExtResource("10_4du0f") +}, { +"duration": 1.0, +"texture": ExtResource("11_1j7to") +}, { +"duration": 1.0, +"texture": ExtResource("12_t04pj") +}, { +"duration": 1.0, +"texture": ExtResource("13_4o6oj") +}, { +"duration": 1.0, +"texture": ExtResource("14_ajd7b") +}, { +"duration": 1.0, +"texture": ExtResource("15_tjtiv") +}, { +"duration": 1.0, +"texture": ExtResource("16_ct13p") +}, { +"duration": 1.0, +"texture": ExtResource("17_re4aw") +}, { +"duration": 1.0, +"texture": ExtResource("18_jmelb") +}, { +"duration": 1.0, +"texture": ExtResource("19_yuvqx") +}], +"loop": true, +"name": &"Idle", +"speed": 18.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("26_ou41i") +}, { +"duration": 1.0, +"texture": ExtResource("27_4gmpt") +}, { +"duration": 1.0, +"texture": ExtResource("28_dvjhk") +}, { +"duration": 1.0, +"texture": ExtResource("29_i8hfx") +}, { +"duration": 1.0, +"texture": ExtResource("30_qlj7e") +}, { +"duration": 1.0, +"texture": ExtResource("31_d7bf5") +}, { +"duration": 1.0, +"texture": ExtResource("32_dq8nx") +}, { +"duration": 1.0, +"texture": ExtResource("33_uuuus") +}, { +"duration": 1.0, +"texture": ExtResource("34_dsv52") +}, { +"duration": 1.0, +"texture": ExtResource("35_6xrls") +}, { +"duration": 1.0, +"texture": ExtResource("36_06eso") +}, { +"duration": 1.0, +"texture": ExtResource("37_flpgl") +}], +"loop": false, +"name": &"Kick", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("20_3j4q8") +}, { +"duration": 1.0, +"texture": ExtResource("21_nq7ji") +}, { +"duration": 1.0, +"texture": ExtResource("22_vnyog") +}, { +"duration": 1.0, +"texture": ExtResource("23_x6dpw") +}, { +"duration": 1.0, +"texture": ExtResource("24_mfk1q") +}, { +"duration": 1.0, +"texture": ExtResource("25_f3408") +}, { +"duration": 1.0, +"texture": ExtResource("26_l8clm") +}, { +"duration": 1.0, +"texture": ExtResource("27_upi8d") +}, { +"duration": 1.0, +"texture": ExtResource("28_e5uih") +}, { +"duration": 1.0, +"texture": ExtResource("28_10fk6") +}, { +"duration": 1.0, +"texture": ExtResource("29_q8a1u") +}, { +"duration": 1.0, +"texture": ExtResource("30_68kny") +}], +"loop": true, +"name": &"Move", +"speed": 12.0 +}] -[sub_resource type="Animation" id="Animation_4bcn0"] -resource_name = "Move" -loop_mode = 1 -step = 0.0833333 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite3D:texture") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.0909091, 0.181818, 0.272727, 0.272827, 0.363636, 0.454545, 0.545455, 0.545555, 0.636364, 0.727273, 0.818182, 0.909091), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [ExtResource("20_3j4q8"), ExtResource("21_nq7ji"), ExtResource("22_vnyog"), ExtResource("2_2r0yv"), ExtResource("23_x6dpw"), ExtResource("24_mfk1q"), ExtResource("25_f3408"), ExtResource("2_2r0yv"), ExtResource("26_l8clm"), ExtResource("27_upi8d"), ExtResource("28_10fk6"), ExtResource("29_q8a1u"), ExtResource("30_68kny")] -} - -[sub_resource type="Animation" id="Animation_2bk11"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite3D:texture") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [ExtResource("2_2r0yv")] -} - -[sub_resource type="Animation" id="Animation_hldm5"] -resource_name = "Slide" -step = 0.166667 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite3D:texture") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.166667, 0.333333, 0.5, 0.666667, 0.833333), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), -"update": 1, -"values": [ExtResource("31_mg83m"), ExtResource("32_gvagx"), ExtResource("33_aoq6e"), ExtResource("34_356xb"), ExtResource("35_43qmd"), ExtResource("36_vn2yp")] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_45f0w"] -_data = { -"Idle": SubResource("Animation_yuolr"), -"Move": SubResource("Animation_4bcn0"), -"RESET": SubResource("Animation_2bk11"), -"Slide": SubResource("Animation_hldm5") -} - -[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("StateMachineNode", "AnimationPlayerNode", "SpriteNode")] +[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("StateMachineNode", "AnimatedSprite3DNode")] script = ExtResource("1_huxwr") StateMachineNode = NodePath("StateMachine") -AnimationPlayerNode = NodePath("AnimationPlayer") -SpriteNode = NodePath("") +AnimatedSprite3DNode = NodePath("AnimatedSprite3D") -[node name="Sprite3D" type="Sprite3D" parent="."] -texture_filter = 0 -texture = ExtResource("2_2r0yv") +[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."] +sprite_frames = SubResource("SpriteFrames_4gqhn") +animation = &"Kick" -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] -libraries = { -"": SubResource("AnimationLibrary_45f0w") -} +[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("CurrentState", "PossibleStates")] +script = ExtResource("33_8uwin") +CurrentState = NodePath("IdleState") +PossibleStates = [NodePath("IdleState"), NodePath("MoveState"), NodePath("DashState"), NodePath("KickingState")] -[node name="IdleState" type="Node" parent="."] +[node name="IdleState" type="Node" parent="StateMachine"] script = ExtResource("31_w18mu") -[node name="MoveState" type="Node" parent="."] +[node name="MoveState" type="Node" parent="StateMachine"] script = ExtResource("32_vc70e") -[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("CurrentState", "PossibleStates")] -script = ExtResource("33_8uwin") -CurrentState = NodePath(".") -PossibleStates = [NodePath("../IdleState"), NodePath("../MoveState")] +[node name="DashState" type="Node" parent="StateMachine" node_paths=PackedStringArray("DashTimer")] +script = ExtResource("41_7ie7a") +DashTimer = NodePath("Timer") + +[node name="Timer" type="Timer" parent="StateMachine/DashState"] +wait_time = 0.5 +one_shot = true + +[node name="KickingState" type="Node" parent="StateMachine"] +script = ExtResource("54_s5rbi") diff --git a/Udemy25dRpg/Scenes/Characters/PlayerDashState.cs b/Udemy25dRpg/Scenes/Characters/PlayerDashState.cs new file mode 100644 index 0000000..906ec40 --- /dev/null +++ b/Udemy25dRpg/Scenes/Characters/PlayerDashState.cs @@ -0,0 +1,54 @@ +using Godot; + +namespace Udemy25dRpg.Scenes.Characters; + +public partial class PlayerDashState : PlayerStateBase +{ + [Export] + public Timer DashTimer {get; private set;} + + [Export(PropertyHint.Range, "0, 20, .1")] + public float DashSpeed {get; private set;} = 10f; + + public override void _Ready() + { + base._Ready(); + + DashTimer.Timeout += () => { + _characterNode.StateMachineNode.SwitchState(); + _characterNode.Velocity = Vector3.Zero; + }; + } + + public override void _PhysicsProcess(double delta) + { + _characterNode.MoveAndSlide(); + _characterNode.FlipSprite(); + } + + protected override void EnterState() + { + _characterNode.AnimatedSprite3DNode.Play(nameof(Player.PlayerAnimations.Dash)); + + if (_characterNode.Velocity == Vector3.Zero) + { + _characterNode.Velocity = _characterNode.AnimatedSprite3DNode.FlipH ? Vector3.Left : Vector3.Right; + } + + _characterNode.Velocity = new ( + _characterNode.Direction.X * DashSpeed, + 0, + _characterNode.Direction.Y * DashSpeed + ); + + DashTimer.Start(); + } + + public override void _Input(InputEvent @event) + { + if (Input.IsActionJustReleased(nameof(Player.PlayerInputs.Dash))) + { + _characterNode.StateMachineNode.SwitchState(); + } + } +} diff --git a/Udemy25dRpg/Scenes/Characters/PlayerIdleState.cs b/Udemy25dRpg/Scenes/Characters/PlayerIdleState.cs index 50af756..2f14078 100644 --- a/Udemy25dRpg/Scenes/Characters/PlayerIdleState.cs +++ b/Udemy25dRpg/Scenes/Characters/PlayerIdleState.cs @@ -2,13 +2,15 @@ namespace Udemy25dRpg.Scenes.Characters; -public partial class PlayerIdleState : Node +public partial class PlayerIdleState : PlayerStateBase { - private Player _characterNode; - public override void _Ready() { - _characterNode = GetOwner(); + base._Ready(); + + _characterNode.AnimatedSprite3DNode.AnimationFinished += () => { + _characterNode.StateMachineNode.SwitchState(); + }; } public override void _PhysicsProcess(double delta) @@ -19,18 +21,20 @@ public override void _PhysicsProcess(double delta) } } - public override void _Notification(int what) - { - base._Notification(what); + protected override void EnterState() + { + _characterNode.AnimatedSprite3DNode.Play(nameof(Player.PlayerAnimations.Idle)); + } - if (what == 5001) + public override void _Input(InputEvent @event) + { + if (Input.IsActionJustPressed(nameof(Player.PlayerInputs.Dash))) { - _characterNode.AnimationPlayerNode.Play(nameof(Player.PlayerAnimations.Idle)); - SetPhysicsProcess(true); + _characterNode.StateMachineNode.SwitchState(); } - else if (what == 5002) + else if (Input.IsActionJustPressed(nameof(Player.PlayerInputs.Kick))) { - SetPhysicsProcess(false); + _characterNode.StateMachineNode.SwitchState(); } } } diff --git a/Udemy25dRpg/Scenes/Characters/PlayerKickingState.cs b/Udemy25dRpg/Scenes/Characters/PlayerKickingState.cs new file mode 100644 index 0000000..69fad0e --- /dev/null +++ b/Udemy25dRpg/Scenes/Characters/PlayerKickingState.cs @@ -0,0 +1,15 @@ +namespace Udemy25dRpg.Scenes.Characters; + +public partial class PlayerKickingState : PlayerStateBase +{ + public override void _Ready() + { + base._Ready(); + _characterNode.AnimatedSprite3DNode.AnimationFinished += _characterNode.StateMachineNode.SwitchState; + } + + protected override void EnterState() + { + _characterNode.AnimatedSprite3DNode.Play(nameof(Player.PlayerAnimations.Kick)); + } +} diff --git a/Udemy25dRpg/Scenes/Characters/PlayerMoveState.cs b/Udemy25dRpg/Scenes/Characters/PlayerMoveState.cs index 7bf0acc..dabb9e7 100644 --- a/Udemy25dRpg/Scenes/Characters/PlayerMoveState.cs +++ b/Udemy25dRpg/Scenes/Characters/PlayerMoveState.cs @@ -2,36 +2,43 @@ namespace Udemy25dRpg.Scenes.Characters; -public partial class PlayerMoveState : Node +public partial class PlayerMoveState : PlayerStateBase { - private Player _characterNode; - - public override void _Ready() - { - _characterNode = GetOwner(); - SetPhysicsProcess(false); - } + [Export(PropertyHint.Range, "0, 30, .1")] + public float MoveFactor {get; private set;} = 5f; public override void _PhysicsProcess(double delta) { if (_characterNode.Direction == Vector2.Zero) { _characterNode.StateMachineNode.SwitchState(); - } + return; + } + + _characterNode.Velocity = new( + _characterNode.Direction.X * MoveFactor, + 0, + _characterNode.Direction.Y * MoveFactor + ); + + _characterNode.MoveAndSlide(); + _characterNode.FlipSprite(); } - public override void _Notification(int what) - { - base._Notification(what); + protected override void EnterState() + { + _characterNode.AnimatedSprite3DNode.Play(nameof(Player.PlayerAnimations.Move)); + } - if (what == (int)StateMachine.StateMachineMessages.EnableState) + public override void _Input(InputEvent @event) + { + if (Input.IsActionJustPressed(nameof(Player.PlayerInputs.Dash))) { - _characterNode.AnimationPlayerNode.Play(nameof(Player.PlayerAnimations.Move)); - SetPhysicsProcess(true); + _characterNode.StateMachineNode.SwitchState(); } - else if (what == (int)StateMachine.StateMachineMessages.DisableState) + else if (Input.IsActionJustPressed(nameof(Player.PlayerInputs.Kick))) { - SetPhysicsProcess(false); + _characterNode.StateMachineNode.SwitchState(); } } } diff --git a/Udemy25dRpg/Scenes/Characters/PlayerStateBase.cs b/Udemy25dRpg/Scenes/Characters/PlayerStateBase.cs new file mode 100644 index 0000000..1eb145e --- /dev/null +++ b/Udemy25dRpg/Scenes/Characters/PlayerStateBase.cs @@ -0,0 +1,34 @@ +using Godot; + +namespace Udemy25dRpg.Scenes.Characters; + +public abstract partial class PlayerStateBase : Node +{ + protected Player _characterNode; + + public override void _Ready() + { + _characterNode = GetOwner(); + SetPhysicsProcess(false); + SetProcessInput(false); + } + + public override void _Notification(int what) + { + base._Notification(what); + + if (what == (int)StateMachine.StateMachineMessages.EnableState) + { + EnterState(); + SetPhysicsProcess(true); + SetProcessInput(true); + } + else if (what == (int)StateMachine.StateMachineMessages.DisableState) + { + SetPhysicsProcess(false); + SetProcessInput(false); + } + } + + protected abstract void EnterState(); +} \ No newline at end of file diff --git a/Udemy25dRpg/Scenes/Characters/StateMachine.cs b/Udemy25dRpg/Scenes/Characters/StateMachine.cs index 9bc0759..4e690d3 100644 --- a/Udemy25dRpg/Scenes/Characters/StateMachine.cs +++ b/Udemy25dRpg/Scenes/Characters/StateMachine.cs @@ -11,12 +11,12 @@ public enum StateMachineMessages { } [Export] - public Node CurrentState { get; set; } + public PlayerStateBase CurrentState { get; private set; } [Export] - public Node[] PossibleStates {get; private set;} + public PlayerStateBase[] PossibleStates {get; private set;} - public void SwitchState() where TState : Node + public void SwitchState() where TState : PlayerStateBase { var newState = PossibleStates.OfType().FirstOrDefault(); diff --git a/Udemy25dRpg/project.godot b/Udemy25dRpg/project.godot index 6507fea..393defa 100644 --- a/Udemy25dRpg/project.godot +++ b/Udemy25dRpg/project.godot @@ -41,3 +41,13 @@ MoveRight={ "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":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) ] } +Dash={ +"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":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +Kick={ +"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +}