mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:45:33 +00:00
FSM Test
This commit is contained in:
parent
f1f40a91dd
commit
af46098aca
9 changed files with 414 additions and 145 deletions
122
Resources/Sprites/player.tres
Normal file
122
Resources/Sprites/player.tres
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
[gd_resource type="SpriteFrames" load_steps=15 format=3 uid="uid://bc7mghjx75qip"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ddwhrlrgj6i00" path="res://Sprites/Actors/Cirno.png" id="1_nsg0m"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_6tpxx"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wp7gh"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(16, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ke1tg"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_t8hpb"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(32, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qarhr"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(16, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3cgoj"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(0, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3o5ec"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(32, 32, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_mcevb"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(16, 48, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_6voax"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(0, 48, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_s2loq"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(32, 48, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a8lgq"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(16, 16, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_sv6wb"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(0, 16, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_taqav"]
|
||||||
|
atlas = ExtResource("1_nsg0m")
|
||||||
|
region = Rect2(32, 16, 16, 16)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_6tpxx")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"idle",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_wp7gh")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ke1tg")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_t8hpb")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk_down",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_qarhr")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_3cgoj")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_3o5ec")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk_left",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_mcevb")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_6voax")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_s2loq")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk_right",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_a8lgq")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_sv6wb")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_taqav")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk_up",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
116
Scenes/Maps/PlayerFSMTest.tscn
Normal file
116
Scenes/Maps/PlayerFSMTest.tscn
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
[gd_scene load_steps=19 format=4 uid="uid://dqyfnby0t7gu1"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_c3v4x"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_w1v1g"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="3_b3hxm"]
|
||||||
|
[ext_resource type="Script" uid="uid://mja0rk7n2kln" path="res://Scripts/Resources/MapStartDataResource.cs" id="4_u1i8n"]
|
||||||
|
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="5_6314l"]
|
||||||
|
[ext_resource type="Script" uid="uid://krean0uywtms" path="res://Scripts/TilemapAvoidance.cs" id="6_yyg8m"]
|
||||||
|
[ext_resource type="Script" uid="uid://v2f387aad33k" path="res://Scripts/Components/FSM/ActorStateMachine.cs" id="7_mljl7"]
|
||||||
|
[ext_resource type="SpriteFrames" uid="uid://bcc5mlwwnkvri" path="res://Resources/Sprites/Fairy.tres" id="8_0knpf"]
|
||||||
|
[ext_resource type="Script" uid="uid://cfya7sndh7vy2" path="res://Scenes/CameraController.gd" id="9_dj0ui"]
|
||||||
|
[ext_resource type="SpriteFrames" uid="uid://bc7mghjx75qip" path="res://Resources/Sprites/player.tres" id="9_w1v1g"]
|
||||||
|
[ext_resource type="Script" uid="uid://c5nxsq3tyxcx6" path="res://Scripts/InventoryManager.cs" id="10_qmakk"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dkwi1hu1bixoe" path="res://Scenes/HUD/HUD.tscn" id="11_hmqao"]
|
||||||
|
[ext_resource type="Script" uid="uid://bdshph801ac2i" path="res://Scenes/CameraTarget.gd" id="12_8to53"]
|
||||||
|
[ext_resource type="Script" uid="uid://cnkipcolyj61w" path="res://Scripts/AlarmManager.cs" id="13_8fnge"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b3tyacxxw88lx" path="res://Scenes/Utils/StreamPlayerWithName.tscn" id="14_q7rh4"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_6wo78"]
|
||||||
|
script = ExtResource("4_u1i8n")
|
||||||
|
EggIndex = 0
|
||||||
|
StartingEquipment = []
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_5xgmc"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_b3hxm"]
|
||||||
|
|
||||||
|
[node name="GameScene" type="Node2D"]
|
||||||
|
process_mode = 3
|
||||||
|
script = ExtResource("1_c3v4x")
|
||||||
|
PlayerTemplate = ExtResource("2_w1v1g")
|
||||||
|
SpawnMarkers = Dictionary[int, NodePath]({
|
||||||
|
0: NodePath("PlayerStartPosition")
|
||||||
|
})
|
||||||
|
WeaponTemplate = ExtResource("3_b3hxm")
|
||||||
|
MapStartData = SubResource("Resource_6wo78")
|
||||||
|
|
||||||
|
[node name="Tilemaps" type="Node2D" parent="."]
|
||||||
|
process_mode = 1
|
||||||
|
|
||||||
|
[node name="Floor" type="TileMapLayer" parent="Tilemaps" node_paths=PackedStringArray("_solidLayer")]
|
||||||
|
tile_map_data = PackedByteArray("AAAEABAAAAAEAAIAAAAEABEAAAAEAAIAAAAEABIAAAAEAAIAAAAEABMAAAAEAAIAAAAEABQAAAAEAAIAAAAEABUAAAAEAAIAAAAEABYAAAAEAAIAAAAFABAAAAAEAAIAAAAFABEAAAAEAAIAAAAFABIAAAAEAAIAAAAFABMAAAAEAAIAAAAFABQAAAAEAAIAAAAFABUAAAAEAAIAAAAFABYAAAAEAAIAAAAGABAAAAAEAAIAAAAGABEAAAAEAAIAAAAGABIAAAAEAAIAAAAGABMAAAAEAAIAAAAGABQAAAAEAAIAAAAGABUAAAAEAAIAAAAGABYAAAAEAAIAAAAHABAAAAAEAAIAAAAHABEAAAAEAAIAAAAHABIAAAAEAAIAAAAHABMAAAAEAAIAAAAHABQAAAAEAAIAAAAHABUAAAAEAAIAAAAHABYAAAAEAAIAAAAIABAAAAAEAAIAAAAIABEAAAAEAAIAAAAIABIAAAAEAAIAAAAIABMAAAAEAAIAAAAIABQAAAAEAAIAAAAIABUAAAAEAAIAAAAIABYAAAAEAAIAAAAJABAAAAAEAAIAAAAJABEAAAAEAAIAAAAJABIAAAAEAAIAAAAJABMAAAAEAAIAAAAJABQAAAAEAAIAAAAJABUAAAAEAAIAAAAJABYAAAAEAAIAAAAKABAAAAAEAAIAAAAKABEAAAAEAAIAAAAKABIAAAAEAAIAAAAKABMAAAAEAAIAAAAKABQAAAAEAAIAAAAKABUAAAAEAAIAAAAKABYAAAAEAAIAAAADABAAAAAEAAIAAAADABEAAAAEAAIAAAADABIAAAAEAAIAAAADABMAAAAEAAIAAAADABQAAAAEAAIAAAADABUAAAAEAAIAAAADABYAAAAEAAIAAAADABcAAAAEAAIAAAADABgAAAAEAAIAAAAEABcAAAAEAAIAAAAEABgAAAAEAAIAAAAFABcAAAAEAAIAAAAFABgAAAAEAAIAAAAGABcAAAAEAAIAAAAGABgAAAAEAAIAAAAHABcAAAAEAAIAAAAHABgAAAAEAAIAAAAIABcAAAAEAAIAAAAIABgAAAAEAAIAAAAJABcAAAAEAAIAAAAJABgAAAAEAAIAAAAKABcAAAAEAAIAAAAKABgAAAAEAAIAAAALABAAAAAEAAIAAAALABEAAAAEAAIAAAALABIAAAAEAAIAAAALABMAAAAEAAIAAAALABQAAAAEAAIAAAALABUAAAAEAAIAAAALABYAAAAEAAIAAAALABcAAAAEAAIAAAALABgAAAAEAAIAAAA=")
|
||||||
|
tile_set = ExtResource("5_6314l")
|
||||||
|
script = ExtResource("6_yyg8m")
|
||||||
|
_solidLayer = NodePath("../Solid")
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="Solid" type="TileMapLayer" parent="Tilemaps" groups=["Solid"]]
|
||||||
|
tile_map_data = PackedByteArray("AAACAA0AAAAAAAsAAAADAA0AAAABAAQAAAAEAA0AAAABAAQAAAAFAA0AAAABAAQAAAAGAA0AAAABAAQAAAAHAA0AAAABAAQAAAAIAA0AAAABAAQAAAAJAA0AAAABAAQAAAAKAA0AAAABAAQAAAALAA0AAAABAAQAAAAMAA0AAAABAAsAAAAMAA4AAAAAAAQAAAAMAA8AAAAAAAQAAAAMABAAAAAAAAQAAAAMABEAAAAAAAQAAAAMABMAAAAAAAQAAAAMABIAAAAAAAQAAAAMABQAAAAAAAQAAAAMABUAAAAAAAQAAAAMABYAAAAAAAQAAAAMABcAAAAAAAQAAAAMABgAAAAAAAQAAAAMABkAAAABAAwAAAALABkAAAABAAQAAAAKABkAAAABAAQAAAAJABkAAAABAAQAAAAIABkAAAABAAQAAAAHABkAAAABAAQAAAAGABkAAAABAAQAAAAFABkAAAABAAQAAAAEABkAAAABAAQAAAADABkAAAABAAQAAAACABkAAAAAAAwAAAACABgAAAAAAAQAAAACABYAAAAAAAQAAAACABcAAAAAAAQAAAACABUAAAAAAAQAAAACABQAAAAAAAQAAAACABIAAAAAAAQAAAACABMAAAAAAAQAAAACABEAAAAAAAQAAAACABAAAAAAAAQAAAACAA8AAAAAAAQAAAACAA4AAAAAAAQAAAADAA4AAAABAAEAAAADAA8AAAABAAEAAAAEAA4AAAABAAEAAAAEAA8AAAABAAEAAAAFAA4AAAABAAEAAAAFAA8AAAABAAEAAAAGAA4AAAABAAEAAAAGAA8AAAABAAEAAAAHAA4AAAABAAEAAAAHAA8AAAABAAEAAAAIAA4AAAABAAEAAAAIAA8AAAABAAEAAAAJAA4AAAABAAEAAAAJAA8AAAABAAEAAAAKAA4AAAABAAEAAAAKAA8AAAABAAEAAAALAA4AAAABAAEAAAALAA8AAAABAAEAAAA=")
|
||||||
|
tile_set = ExtResource("5_6314l")
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="Props" type="TileMapLayer" parent="Tilemaps"]
|
||||||
|
tile_set = ExtResource("5_6314l")
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="Actors" type="Node2D" parent="Tilemaps"]
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="FSMEnemy" type="CharacterBody2D" parent="Tilemaps/Actors"]
|
||||||
|
position = Vector2(161.783, 298.229)
|
||||||
|
script = ExtResource("7_mljl7")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tilemaps/Actors/FSMEnemy"]
|
||||||
|
shape = SubResource("CircleShape2D_5xgmc")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Tilemaps/Actors/FSMEnemy"]
|
||||||
|
sprite_frames = ExtResource("8_0knpf")
|
||||||
|
animation = &"down"
|
||||||
|
|
||||||
|
[node name="Idle" type="Node2D" parent="Tilemaps/Actors/FSMEnemy"]
|
||||||
|
|
||||||
|
[node name="FSMPlayer" type="CharacterBody2D" parent="Tilemaps/Actors"]
|
||||||
|
position = Vector2(76, 295)
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D" parent="Tilemaps/Actors/FSMPlayer"]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tilemaps/Actors/FSMPlayer"]
|
||||||
|
shape = SubResource("CircleShape2D_b3hxm")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Tilemaps/Actors/FSMPlayer"]
|
||||||
|
sprite_frames = ExtResource("9_w1v1g")
|
||||||
|
animation = &"idle"
|
||||||
|
|
||||||
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
|
process_mode = 1
|
||||||
|
script = ExtResource("9_dj0ui")
|
||||||
|
pixel_snap = false
|
||||||
|
|
||||||
|
[node name="ReferenceRect" type="ReferenceRect" parent="."]
|
||||||
|
visible = false
|
||||||
|
offset_left = -38.0
|
||||||
|
offset_top = -39.0
|
||||||
|
offset_right = 124.0
|
||||||
|
offset_bottom = 44.0
|
||||||
|
|
||||||
|
[node name="InventoryManager" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("10_qmakk")
|
||||||
|
|
||||||
|
[node name="HUD" parent="." instance=ExtResource("11_hmqao")]
|
||||||
|
|
||||||
|
[node name="CameraTarget" type="Node2D" parent="."]
|
||||||
|
position = Vector2(115, 328)
|
||||||
|
script = ExtResource("12_8to53")
|
||||||
|
|
||||||
|
[node name="PlayerStartPosition" type="Marker2D" parent="."]
|
||||||
|
position = Vector2(111, 305)
|
||||||
|
|
||||||
|
[node name="AlarmManager" type="Node2D" parent="."]
|
||||||
|
process_mode = 1
|
||||||
|
script = ExtResource("13_8fnge")
|
||||||
|
|
||||||
|
[node name="AudioStreamPlayer2D" parent="." instance=ExtResource("14_q7rh4")]
|
||||||
|
process_mode = 3
|
||||||
|
autoplay = true
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=39 format=3 uid="uid://bghghp5ep4w2j"]
|
[gd_scene load_steps=25 format=3 uid="uid://bghghp5ep4w2j"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dqw1gfr3n6rl3" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
[ext_resource type="Script" uid="uid://dqw1gfr3n6rl3" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="3_ul15q"]
|
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="3_ul15q"]
|
||||||
[ext_resource type="PackedScene" uid="uid://biugfbp0yae2s" path="res://Scenes/Particles/DeathParticles.tscn" id="4_1bl4h"]
|
[ext_resource type="PackedScene" uid="uid://biugfbp0yae2s" path="res://Scenes/Particles/DeathParticles.tscn" id="4_1bl4h"]
|
||||||
[ext_resource type="Script" uid="uid://c1ac1yeu0oevo" path="res://addons/smoothing/smoothing_2d.gd" id="4_j4xhu"]
|
[ext_resource type="Script" uid="uid://c1ac1yeu0oevo" path="res://addons/smoothing/smoothing_2d.gd" id="4_j4xhu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ddwhrlrgj6i00" path="res://Sprites/Actors/Cirno.png" id="5_hq878"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cfb3nsay84xdb" path="res://Scenes/Weapons/crosshair.tscn" id="6_l43rf"]
|
[ext_resource type="PackedScene" uid="uid://cfb3nsay84xdb" path="res://Scenes/Weapons/crosshair.tscn" id="6_l43rf"]
|
||||||
[ext_resource type="Shader" uid="uid://0ruey5bjl7mh" path="res://Shaders/Blink.gdshader" id="6_xugve"]
|
[ext_resource type="Shader" uid="uid://0ruey5bjl7mh" path="res://Shaders/Blink.gdshader" id="6_xugve"]
|
||||||
|
[ext_resource type="SpriteFrames" uid="uid://bc7mghjx75qip" path="res://Resources/Sprites/player.tres" id="7_fd4e3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bf37ce6jskdel" path="res://Sprites/SmallHitbox.png" id="7_msn8i"]
|
[ext_resource type="Texture2D" uid="uid://bf37ce6jskdel" path="res://Sprites/SmallHitbox.png" id="7_msn8i"]
|
||||||
[ext_resource type="Script" uid="uid://cem7a1agaqtrt" path="res://Scenes/InteractionController.cs" id="7_uvgjg"]
|
[ext_resource type="Script" uid="uid://cem7a1agaqtrt" path="res://Scenes/InteractionController.cs" id="7_uvgjg"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bwjrdlnysft15" path="res://Sprites/Actors/Focus_Circle.png" id="8_1og8b"]
|
[ext_resource type="Texture2D" uid="uid://bwjrdlnysft15" path="res://Sprites/Actors/Focus_Circle.png" id="8_1og8b"]
|
||||||
|
|
@ -32,125 +32,6 @@ shader_parameter/blink_intensity = 0.0
|
||||||
shader_parameter/teleport_progress = 0.0
|
shader_parameter/teleport_progress = 0.0
|
||||||
shader_parameter/scanline_density = 0.0
|
shader_parameter/scanline_density = 0.0
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6tpxx"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(0, 0, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wp7gh"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(16, 0, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ke1tg"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(0, 0, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t8hpb"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(32, 0, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qarhr"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(16, 32, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3cgoj"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(0, 32, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3o5ec"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(32, 32, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mcevb"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(16, 48, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6voax"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(0, 48, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s2loq"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(32, 48, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a8lgq"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(16, 16, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sv6wb"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(0, 16, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_taqav"]
|
|
||||||
atlas = ExtResource("5_hq878")
|
|
||||||
region = Rect2(32, 16, 16, 16)
|
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_q0rt3"]
|
|
||||||
animations = [{
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_6tpxx")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"idle",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_wp7gh")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_ke1tg")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_t8hpb")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"walk_down",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_qarhr")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_3cgoj")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_3o5ec")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"walk_left",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_mcevb")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_6voax")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_s2loq")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"walk_right",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_a8lgq")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_sv6wb")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_taqav")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"walk_up",
|
|
||||||
"speed": 5.0
|
|
||||||
}]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lsyrf"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_lsyrf"]
|
||||||
atlas = ExtResource("8_1og8b")
|
atlas = ExtResource("8_1og8b")
|
||||||
region = Rect2(0, 0, 32, 32)
|
region = Rect2(0, 0, 32, 32)
|
||||||
|
|
@ -222,7 +103,7 @@ frame = 1
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Smoothing2D" groups=["player_sprite"]]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Smoothing2D" groups=["player_sprite"]]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
material = SubResource("ShaderMaterial_s7co1")
|
material = SubResource("ShaderMaterial_s7co1")
|
||||||
sprite_frames = SubResource("SpriteFrames_q0rt3")
|
sprite_frames = ExtResource("7_fd4e3")
|
||||||
animation = &"walk_left"
|
animation = &"walk_left"
|
||||||
frame = 1
|
frame = 1
|
||||||
frame_progress = 0.47396
|
frame_progress = 0.47396
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using Godot.Collections;
|
||||||
|
|
||||||
namespace Cirno.Scripts.Components.FSM;
|
namespace Cirno.Scripts.Components.FSM;
|
||||||
|
|
||||||
public partial class ActorStateMachine : Node2D
|
public partial class ActorStateMachine : CharacterBody2D
|
||||||
{
|
{
|
||||||
public Dictionary<int, State> States { get; private set; } = new();
|
public Dictionary<int, State> States { get; private set; } = new();
|
||||||
|
|
||||||
|
|
|
||||||
128
Scripts/Components/FSM/Player/Active.cs
Normal file
128
Scripts/Components/FSM/Player/Active.cs
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Components.FSM.Player;
|
||||||
|
|
||||||
|
public partial class Active : PlayerFSMState
|
||||||
|
{
|
||||||
|
private Vector2 _movementDirection { get; set; }
|
||||||
|
private Vector2 _facingDirection { get; set; }
|
||||||
|
|
||||||
|
[Export] public Sprite2D HitboxSprite { get; set; }
|
||||||
|
|
||||||
|
[ExportGroup("Action Names")]
|
||||||
|
[Export] private string _shootActionName = "shoot";
|
||||||
|
[Export] private string _useActionName = "Use";
|
||||||
|
[Export] private string _strafeActionName = "strafe";
|
||||||
|
[Export] private string _nextWeaponActionName = "next_weapon";
|
||||||
|
[Export] private string _previousWeaponActionName = "previous_weapon";
|
||||||
|
|
||||||
|
private bool _isStrafing { get; set; }
|
||||||
|
|
||||||
|
public override void EnterState()
|
||||||
|
{
|
||||||
|
// enable sprite
|
||||||
|
// enable crosshair
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ExitState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PhysicsProcessState(double delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ProcessState(double delta)
|
||||||
|
{
|
||||||
|
SetAnimation();
|
||||||
|
|
||||||
|
_movementDirection = GetInput();
|
||||||
|
_isStrafing = Input.IsActionPressed(_strafeActionName);
|
||||||
|
|
||||||
|
// Toggle visibility of the hitbox sprite based on strafing
|
||||||
|
if (HitboxSprite != null)
|
||||||
|
{
|
||||||
|
HitboxSprite.Visible = _isStrafing;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rightStickInput = GetRightStickInput();
|
||||||
|
|
||||||
|
// Update Facing Direction
|
||||||
|
if (!_isStrafing)
|
||||||
|
{
|
||||||
|
if (rightStickInput.Length() > 0.1f) // If the right stick is moved
|
||||||
|
{
|
||||||
|
_facingDirection = rightStickInput.Normalized();
|
||||||
|
}
|
||||||
|
else if (_movementDirection != Vector2.Zero) // Fall back to movement direction
|
||||||
|
{
|
||||||
|
_facingDirection = _movementDirection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleShoot();
|
||||||
|
// FindInteractable();
|
||||||
|
|
||||||
|
// if (Input.IsActionJustPressed(_nextWeaponActionName))
|
||||||
|
// {
|
||||||
|
// NextWeapon();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (Input.IsActionJustPressed(_previousWeaponActionName))
|
||||||
|
// {
|
||||||
|
// PreviousWeapon();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _crosshair.Position = CalculateCrosshairPosition();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetAnimation()
|
||||||
|
{
|
||||||
|
|
||||||
|
// if (Velocity.X == 0 && Velocity.Y == 0)
|
||||||
|
// {
|
||||||
|
// _animatedSprite.SpeedScale = 0;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _animatedSprite.SpeedScale = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (Velocity.X > 0)
|
||||||
|
// {
|
||||||
|
// _animatedSprite.Play("walk_right");
|
||||||
|
// }
|
||||||
|
// else if (Velocity.X < 0)
|
||||||
|
// {
|
||||||
|
// _animatedSprite.Play("walk_left");
|
||||||
|
// }
|
||||||
|
// else if (Velocity.Y > 0)
|
||||||
|
// {
|
||||||
|
// _animatedSprite.Play("walk_down");
|
||||||
|
// }
|
||||||
|
// else if (Velocity.Y < 0)
|
||||||
|
// {
|
||||||
|
// _animatedSprite.Play("walk_up");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 GetInput()
|
||||||
|
{
|
||||||
|
return Input.GetVector("left", "right", "up", "down");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 GetRightStickInput()
|
||||||
|
{
|
||||||
|
return new Vector2(
|
||||||
|
Input.GetAxis("aim_left", "aim_right"),
|
||||||
|
Input.GetAxis("aim_up", "aim_down")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,18 +5,11 @@ namespace Cirno.Scripts.Components.FSM;
|
||||||
public abstract partial class PlayerFSMState : State
|
public abstract partial class PlayerFSMState : State
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
public PlayerState State { get; private set; }
|
public PlayerState State { get; private set; }
|
||||||
public override int StateId => (int)State;
|
public override int StateId => (int)State;
|
||||||
|
|
||||||
protected void ChangeState(PlayerState newState)
|
protected void ChangeState(PlayerState newState)
|
||||||
{
|
{
|
||||||
_stateMachine.SetState((int)newState);
|
_stateMachine.SetState((int)newState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PlayerState
|
|
||||||
{
|
|
||||||
Idle,
|
|
||||||
Walking,
|
|
||||||
Cutscene
|
|
||||||
}
|
|
||||||
12
Scripts/Components/FSM/PlayerStateMachine.cs
Normal file
12
Scripts/Components/FSM/PlayerStateMachine.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Components.FSM;
|
||||||
|
|
||||||
|
public partial class PlayerStateMachine : ActorStateMachine
|
||||||
|
{
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
base._Ready();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,28 +5,28 @@ namespace Cirno.Scripts.Components.FSM;
|
||||||
|
|
||||||
public abstract partial class State : Node2D
|
public abstract partial class State : Node2D
|
||||||
{
|
{
|
||||||
[Export]
|
// [Export]
|
||||||
public Array<FSMStateModule> Modules { get; private set; } = new();
|
// public Array<FSMStateModule> Modules { get; private set; } = new();
|
||||||
|
|
||||||
public virtual int StateId { get; }
|
public virtual int StateId { get; }
|
||||||
|
|
||||||
protected ActorStateMachine _stateMachine;
|
protected ActorStateMachine _stateMachine;
|
||||||
|
|
||||||
public virtual void Init(ActorStateMachine stateMachine)
|
public virtual void Init(ActorStateMachine stateMachine)
|
||||||
{
|
{
|
||||||
_stateMachine = stateMachine;
|
_stateMachine = stateMachine;
|
||||||
|
|
||||||
foreach (var module in Modules)
|
// foreach (var module in Modules)
|
||||||
{
|
// {
|
||||||
//module.Init()
|
// //module.Init()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void EnterState();
|
public abstract void EnterState();
|
||||||
|
|
||||||
public abstract void ExitState();
|
public abstract void ExitState();
|
||||||
|
|
||||||
public abstract void ProcessState(double delta);
|
public abstract void ProcessState(double delta);
|
||||||
public abstract void PhysicsProcessState(double delta);
|
public abstract void PhysicsProcessState(double delta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +64,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
[Export] private GpuParticles2D _shieldParticles;
|
[Export] private GpuParticles2D _shieldParticles;
|
||||||
public Weapon EquippedWeapon { get; set; }
|
public Weapon EquippedWeapon { get; set; }
|
||||||
|
|
||||||
|
private PlayerState _state;
|
||||||
|
|
||||||
public Array<Weapon> EquippedWeapons { get; set; } = new Array<Weapon>();
|
public Array<Weapon> EquippedWeapons { get; set; } = new Array<Weapon>();
|
||||||
|
|
||||||
public int CurrentWeaponIndex { get; set; } = 0;
|
public int CurrentWeaponIndex { get; set; } = 0;
|
||||||
|
|
@ -124,6 +126,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
// CurrentHealth = MaxHealth;
|
// CurrentHealth = MaxHealth;
|
||||||
// CurrentShield = MaxShield;
|
// CurrentShield = MaxShield;
|
||||||
|
|
||||||
|
_state = PlayerState.Active;
|
||||||
|
|
||||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||||
|
|
||||||
|
|
@ -171,17 +175,22 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case GameState.Menu:
|
case GameState.Menu:
|
||||||
break;
|
|
||||||
case GameState.Paused:
|
case GameState.Paused:
|
||||||
_canMove = false;
|
_canMove = false;
|
||||||
|
_state = PlayerState.Paused;
|
||||||
break;
|
break;
|
||||||
case GameState.Playing:
|
case GameState.Playing:
|
||||||
_canMove = true;
|
_canMove = true;
|
||||||
|
_state = PlayerState.Active;
|
||||||
break;
|
break;
|
||||||
case GameState.Dialogue:
|
case GameState.Dialogue:
|
||||||
_canMove = false;
|
_canMove = false;
|
||||||
|
_state = PlayerState.Paused;
|
||||||
|
break;
|
||||||
|
case GameState.Controlling:
|
||||||
|
_canMove = false;
|
||||||
|
_state = PlayerState.Controlling;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -601,3 +610,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlayerState
|
||||||
|
{
|
||||||
|
Active,
|
||||||
|
Paused,
|
||||||
|
Controlling,
|
||||||
|
Dead,
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue