diff --git a/Resources/Bullets/Spider_Bomb_Bullet.tres b/Resources/Bullets/Spider_Bomb_Bullet.tres index d1a63012..6a4882df 100644 --- a/Resources/Bullets/Spider_Bomb_Bullet.tres +++ b/Resources/Bullets/Spider_Bomb_Bullet.tres @@ -1,11 +1,13 @@ -[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://dwxn7f1ue0m4s"] +[gd_resource type="Resource" script_class="BulletResource" load_steps=4 format=3 uid="uid://dwxn7f1ue0m4s"] [ext_resource type="PackedScene" uid="uid://64ax2lj77sr1" path="res://Scenes/Weapons/Bullets/spider_bomb_bullet.tscn" id="1_8gj5r"] [ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="1_f2i0g"] +[ext_resource type="PackedScene" uid="uid://1lowv5ce2poq" path="res://Scenes/Weapons/Bullets/Autoclearing_Explosion_Bullet.tscn" id="2_f3yha"] [resource] script = ExtResource("1_f2i0g") BulletScene = ExtResource("1_8gj5r") +DestructionParticlesScene = ExtResource("2_f3yha") BulletSpeed = 40.0 Direction = Vector2(1, 0) BulletDamage = 0.0 diff --git a/Resources/Weapons/Spider_Bomb.tres b/Resources/Weapons/Spider_Bomb.tres index d65ff43b..9198b975 100644 --- a/Resources/Weapons/Spider_Bomb.tres +++ b/Resources/Weapons/Spider_Bomb.tres @@ -1,25 +1,12 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://m7obu15t73df"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://m7obu15t73df"] -[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="1_m8p4s"] +[ext_resource type="Resource" uid="uid://dwxn7f1ue0m4s" path="res://Resources/Bullets/Spider_Bomb_Bullet.tres" id="1_m8p4s"] [ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="1_wdsus"] -[sub_resource type="Resource" id="Resource_hoooo"] -script = ExtResource("1_m8p4s") -BulletSpeed = 100.0 -Direction = Vector2(1, 0) -BulletDamage = 1.0 -LifeTime = 10.0 -DestroyOnCollision = true -Owner = 0 -DamageType = 0 -Controllable = false -TimeModifiers = null -metadata/_custom_type_script = "uid://dslyrfcej3g2n" - [resource] script = ExtResource("1_wdsus") Name = "Spider Bomb" -BulletData = SubResource("Resource_hoooo") +BulletData = ExtResource("1_m8p4s") RateOfFire = 0.4 BulletCapacity = 20 ReloadTime = 1.0 @@ -28,7 +15,7 @@ InfiniteAmmo = true BulletsPerShot = 1 SpreadAngle = 0.0 RandomSpread = 0.0 -ItemKey = "" +ItemKey = "SPIDER_BOMB" AmmoKey = "" _rotationOffset = 0.0 metadata/_custom_type_script = "uid://b6fmrnipv88bk" diff --git a/Scenes/Actors/fsm_player.tscn b/Scenes/Actors/fsm_player.tscn index 44e50ae6..b3a341cf 100644 --- a/Scenes/Actors/fsm_player.tscn +++ b/Scenes/Actors/fsm_player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=42 format=3 uid="uid://c4pr2707hbeph"] +[gd_scene load_steps=43 format=3 uid="uid://c4pr2707hbeph"] [ext_resource type="Script" uid="uid://d2ubk5gucny6s" path="res://Scripts/Components/FSM/PlayerFSMProxy.cs" id="1_g3wua"] [ext_resource type="Script" uid="uid://bw2hakslndaxm" path="res://Scripts/Components/FSM/PlayerStateMachine.cs" id="1_mpmil"] @@ -28,6 +28,7 @@ [ext_resource type="PackedScene" uid="uid://chkpk7erlqajg" path="res://Scenes/Selector.tscn" id="23_5tmtw"] [ext_resource type="AudioStream" uid="uid://myr6n2c1u503" path="res://SFX/581602__samsterbirdies__beep-error.mp3" id="24_5tmtw"] [ext_resource type="Script" uid="uid://cem7a1agaqtrt" path="res://Scenes/InteractionController.cs" id="27_vwjki"] +[ext_resource type="Script" uid="uid://d0bebi2vn171l" path="res://Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs" id="29_m323t"] [sub_resource type="CircleShape2D" id="CircleShape2D_b3hxm"] radius = 5.0 @@ -137,7 +138,7 @@ _inputProvider = NodePath("../../InputProvider") _damageReceiver = NodePath("../../DamageReceiver") _activationProvider = NodePath("../../InteractionProvider") _interactionController = NodePath("../../InteractionController") -_moduleNodes = [NodePath("../../InteractionController")] +_moduleNodes = [NodePath("../../InteractionController"), NodePath("../../ItemUser")] [node name="Cutscene" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("_animationProvider")] script = ExtResource("4_22ff8") @@ -264,6 +265,9 @@ Shield = NodePath("../DamageReceiver/ShieldProvider") [node name="CollisionShape2D2" type="CollisionShape2D" parent="InteractionController"] shape = SubResource("CircleShape2D_g3wua") +[node name="ItemUser" type="Node2D" parent="."] +script = ExtResource("29_m323t") + [connection signal="area_entered" from="DamageReceiver" to="DamageReceiver" method="_on_damage_hitbox_area_entered"] [connection signal="area_entered" from="InteractionProvider" to="InteractionProvider" method="_on_interaction_controller_area_entered"] [connection signal="area_exited" from="InteractionProvider" to="InteractionProvider" method="_on_interaction_controller_area_exited"] diff --git a/Scenes/InteractionController.cs b/Scenes/InteractionController.cs index d958b451..db2705c8 100644 --- a/Scenes/InteractionController.cs +++ b/Scenes/InteractionController.cs @@ -37,6 +37,16 @@ public partial class InteractionController : PlayerArea2DModule { } + public override void EnterState(PlayerState state) + { + + } + + public override void ExitState(PlayerState state) + { + + } + public override void Init(IStateMachine machine) { base.Init(machine); diff --git a/Scenes/Items/SpiderBomb_Pickup.tscn b/Scenes/Items/SpiderBomb_Pickup.tscn index 8e508e87..244ecbe0 100644 --- a/Scenes/Items/SpiderBomb_Pickup.tscn +++ b/Scenes/Items/SpiderBomb_Pickup.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=8 format=3 uid="uid://cvctgw8eo2f7e"] +[gd_scene load_steps=7 format=3 uid="uid://cvctgw8eo2f7e"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_bdsed"] [ext_resource type="Resource" uid="uid://dhbltvgsa3g88" path="res://Resources/Items/Spider_Bomb_Pickup.tres" id="2_bdsed"] -[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_fyf8h"] -[ext_resource type="Texture2D" uid="uid://huo14jdekj6n" path="res://Sprites/Bullets/spiderbomb.png" id="3_bdsed"] +[ext_resource type="Texture2D" uid="uid://r2h77ktff10m" path="res://Sprites/Bullets/Snowball.png" id="3_bdsed"] [sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"] @@ -26,7 +25,7 @@ animations = [{ collision_layer = 4 collision_mask = 2 script = ExtResource("1_bdsed") -LootTable = Array[ExtResource("2_fyf8h")]([ExtResource("2_bdsed")]) +LootTable = [ExtResource("2_bdsed")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") diff --git a/Scenes/Weapons/Bullets/spider_bomb_bullet.tscn b/Scenes/Weapons/Bullets/spider_bomb_bullet.tscn index 9606e2d8..64adcb9d 100644 --- a/Scenes/Weapons/Bullets/spider_bomb_bullet.tscn +++ b/Scenes/Weapons/Bullets/spider_bomb_bullet.tscn @@ -1,34 +1,57 @@ -[gd_scene load_steps=8 format=3 uid="uid://64ax2lj77sr1"] +[gd_scene load_steps=12 format=3 uid="uid://64ax2lj77sr1"] [ext_resource type="Script" uid="uid://dsa4b75hdig8p" path="res://Scripts/Bullet.cs" id="1_nrcj1"] -[ext_resource type="Texture2D" uid="uid://huo14jdekj6n" path="res://Sprites/Bullets/spiderbomb.png" id="2_nrcj1"] +[ext_resource type="Texture2D" uid="uid://r2h77ktff10m" path="res://Sprites/Bullets/Snowball.png" id="2_lhjit"] +[ext_resource type="Texture2D" uid="uid://cf2855sd3hqty" path="res://Sprites/Actors/Aiming_Reticule_Small.png" id="3_lhjit"] [sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"] radius = 2.23607 -[sub_resource type="AtlasTexture" id="AtlasTexture_lhjit"] -atlas = ExtResource("2_nrcj1") +[sub_resource type="AtlasTexture" id="AtlasTexture_ibnjy"] +atlas = ExtResource("2_lhjit") region = Rect2(0, 0, 16, 16) -[sub_resource type="AtlasTexture" id="AtlasTexture_ibnjy"] -atlas = ExtResource("2_nrcj1") +[sub_resource type="AtlasTexture" id="AtlasTexture_w1jch"] +atlas = ExtResource("2_lhjit") region = Rect2(16, 0, 16, 16) -[sub_resource type="AtlasTexture" id="AtlasTexture_w1jch"] -atlas = ExtResource("2_nrcj1") +[sub_resource type="AtlasTexture" id="AtlasTexture_o2e4e"] +atlas = ExtResource("2_lhjit") region = Rect2(32, 0, 16, 16) -[sub_resource type="SpriteFrames" id="SpriteFrames_co0jb"] +[sub_resource type="AtlasTexture" id="AtlasTexture_ea6l6"] +atlas = ExtResource("2_lhjit") +region = Rect2(48, 0, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_f4bqv"] animations = [{ "frames": [{ "duration": 1.0, -"texture": SubResource("AtlasTexture_lhjit") -}, { -"duration": 1.0, "texture": SubResource("AtlasTexture_ibnjy") }, { "duration": 1.0, "texture": SubResource("AtlasTexture_w1jch") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_o2e4e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ea6l6") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="AtlasTexture" id="AtlasTexture_co0jb"] +atlas = ExtResource("3_lhjit") +region = Rect2(0, 0, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_o2e4e"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_co0jb") }], "loop": true, "name": &"default", @@ -48,10 +71,14 @@ shape = SubResource("CircleShape2D_jxptd") [node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -sprite_frames = SubResource("SpriteFrames_co0jb") +sprite_frames = SubResource("SpriteFrames_f4bqv") autoplay = "default" -frame = 1 -frame_progress = 0.375255 +frame = 3 +frame_progress = 0.54531 + +[node name="AnimatedSprite2D2" type="AnimatedSprite2D" parent="."] +position = Vector2(18.545, 0) +sprite_frames = SubResource("SpriteFrames_o2e4e") [connection signal="area_entered" from="." to="." method="_on_area_entered"] [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/Scripts/Components/Actors/RotationCrosshairModule.cs b/Scripts/Components/Actors/RotationCrosshairModule.cs new file mode 100644 index 00000000..3ee93b69 --- /dev/null +++ b/Scripts/Components/Actors/RotationCrosshairModule.cs @@ -0,0 +1,6 @@ +namespace Cirno.Scripts.Components.Actors; + +public class RotationCrosshairModule +{ + +} \ No newline at end of file diff --git a/Scripts/Components/FSM/BaseState.cs b/Scripts/Components/FSM/BaseState.cs index 2b4a24c4..04e7d4a7 100644 --- a/Scripts/Components/FSM/BaseState.cs +++ b/Scripts/Components/FSM/BaseState.cs @@ -27,11 +27,9 @@ public abstract partial class BaseState : Node2D, IState module) - { - _modules.Add(module); - module.Init(_stateMachine); - } + if (node is not IModule module) continue; + _modules.Add(module); + module.Init(_stateMachine); } } @@ -40,9 +38,21 @@ public abstract partial class BaseState : Node2D, IState where TKey : notnull where TType : Node { + public void EnterState(TKey state); + public void ExitState(TKey state); public void Init(IStateMachine machine); public void Process(double delta); public void PhysicsProcess(double delta); diff --git a/Scripts/Components/FSM/ModuleBase.cs b/Scripts/Components/FSM/ModuleBase.cs index e005de67..fc72bc06 100644 --- a/Scripts/Components/FSM/ModuleBase.cs +++ b/Scripts/Components/FSM/ModuleBase.cs @@ -6,6 +6,8 @@ public abstract partial class ModuleBase : Node2D, IModule machine); public abstract void Process(double delta); public abstract void PhysicsProcess(double delta); diff --git a/Scripts/Components/FSM/Player/Active.cs b/Scripts/Components/FSM/Player/Active.cs index 33d3e8b5..2f88ec66 100644 --- a/Scripts/Components/FSM/Player/Active.cs +++ b/Scripts/Components/FSM/Player/Active.cs @@ -79,6 +79,7 @@ public partial class Active : PlayerStateBase public override void EnterState() { + base.EnterState(); // enable sprite // enable crosshair _crosshairProvider.Show(); @@ -90,6 +91,7 @@ public partial class Active : PlayerStateBase public override void ExitState() { + base.ExitState(); _animationProvider.SetAnimation(Vector2.Zero); _crosshairProvider.Hide(); _hitboxSpriteProvider.Hide(); diff --git a/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs b/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs new file mode 100644 index 00000000..85a42f5d --- /dev/null +++ b/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs @@ -0,0 +1,110 @@ +using System; +using Cirno.Scripts.Resources; +using Godot; + +namespace Cirno.Scripts.Components.FSM.Player; + +public partial class PlayerFSMItemUseModule : ModuleBase +{ + public bool Enabled { get; set; } = false; + + public override void EnterState(PlayerState state) + { + GD.Print("EnterState"); + Enabled = true; + } + + public override void ExitState(PlayerState state) + { + GD.Print("exitState"); + Enabled = false; + } + + private IStateMachine _machine; + + public override void Init(IStateMachine machine) + { + InventoryManager.Instance.ItemUsed += this.UseItem; + _machine = machine; + } + + private void UseItem(LootItem item, int totalcount) + { + if (!Enabled) return; + GD.Print("Used spiderbomb in player"); + switch (item.Item) + { + case ItemTypes.KeycardRed: + break; + case ItemTypes.KeycardBlue: + break; + case ItemTypes.KeycardGreen: + break; + case ItemTypes.Ammo: + break; + case ItemTypes.Medkit: + break; + case ItemTypes.FrogBomb: + SpawnSpiderBomb(item); + break; + case ItemTypes.Bomb: + break; + case ItemTypes.Mine: + break; + case ItemTypes.Battery: + break; + case ItemTypes.Weapon: + break; + case ItemTypes.Power: + break; + case ItemTypes.Points: + break; + case ItemTypes.Credits: + break; + case ItemTypes.KeyItem: + break; + } + + } + + private void SpawnSpiderBomb(LootItem item) + { + //var bullet = item.WeaponData.BulletData.BulletScene.Instantiate(); + //bullet.Initialize(item.WeaponData.BulletData.MakeBullet(this.GlobalPosition, 1,0, 0), GameManager.Instance); + + + //InventoryManager.Instance.RemoveItem(item.ItemKey, 1); + // emit projectile + var bullet = this.CreateChildOf(GameManager.Instance.BulletsContainer, item.WeaponData.BulletData.BulletScene, this.GlobalPosition); + + var bulletData = item.WeaponData.MakeBullet(this.GlobalPosition); + + bullet.Initialize(bulletData, GameManager.Instance); + + //bullet.SetDirection(_facingDirection); + bullet.Speed = item.WeaponData.BulletData.BulletSpeed; + + _machine.SetState(PlayerState.Controlling); + + //RequestMovementDisable(true); + // set camera + GameManager.Instance.CameraTargetObject(bullet); + // set event destroy + bullet.OnDestroy += () => + { + GameManager.Instance.CameraTargetPlayer(); + _machine.SetState(PlayerState.Active); + //RequestMovementDisable(false); + }; + } + + public override void Process(double delta) + { + + } + + public override void PhysicsProcess(double delta) + { + + } +} \ No newline at end of file diff --git a/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs.uid b/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs.uid new file mode 100644 index 00000000..bb3f5016 --- /dev/null +++ b/Scripts/Components/FSM/Player/PlayerFSMItemUseModule.cs.uid @@ -0,0 +1 @@ +uid://d0bebi2vn171l diff --git a/Scripts/Components/FSM/PlayerArea2DModule.cs b/Scripts/Components/FSM/PlayerArea2DModule.cs index b4bdf8f1..9abf8554 100644 --- a/Scripts/Components/FSM/PlayerArea2DModule.cs +++ b/Scripts/Components/FSM/PlayerArea2DModule.cs @@ -7,8 +7,11 @@ public abstract partial class PlayerArea2DModule : Area2D, IModule StateMachine { get; private set; } public CharacterBody2D CharacterBody => StateMachine.MainObject; - - + + + public abstract void EnterState(PlayerState state); + public abstract void ExitState(PlayerState state); + public virtual void Init(IStateMachine machine) { StateMachine = machine; diff --git a/Scripts/Components/FSM/TestModule.cs b/Scripts/Components/FSM/TestModule.cs index cc1f5719..05e31b33 100644 --- a/Scripts/Components/FSM/TestModule.cs +++ b/Scripts/Components/FSM/TestModule.cs @@ -4,6 +4,16 @@ namespace Cirno.Scripts.Components.FSM; public partial class TestModule : ModuleBase { + public override void EnterState(PlayerState state) + { + + } + + public override void ExitState(PlayerState state) + { + + } + public override void Init(IStateMachine machine) { GD.Print($"Module Init {Name}"); diff --git a/Sprites/Actors/Aiming_Reticule_Small.aseprite b/Sprites/Actors/Aiming_Reticule_Small.aseprite new file mode 100644 index 00000000..591b179c --- /dev/null +++ b/Sprites/Actors/Aiming_Reticule_Small.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc4508475014305ea5cb517c8c48109b2aadbd6ef5dce35a26f09ffd398081f8 +size 458 diff --git a/Sprites/Actors/Aiming_Reticule_Small.png b/Sprites/Actors/Aiming_Reticule_Small.png new file mode 100644 index 00000000..195ede74 --- /dev/null +++ b/Sprites/Actors/Aiming_Reticule_Small.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ceeccb3f9a532f10082a629d330135c947d96b359e63360c1b874d4cd964add3 +size 106 diff --git a/Sprites/Actors/Aiming_Reticule_Small.png.import b/Sprites/Actors/Aiming_Reticule_Small.png.import new file mode 100644 index 00000000..b7fc53d8 --- /dev/null +++ b/Sprites/Actors/Aiming_Reticule_Small.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cf2855sd3hqty" +path="res://.godot/imported/Aiming_Reticule_Small.png-3a64498ab624b147ab0d0983d029730f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/Actors/Aiming_Reticule_Small.png" +dest_files=["res://.godot/imported/Aiming_Reticule_Small.png-3a64498ab624b147ab0d0983d029730f.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 diff --git a/Sprites/Bullets/Snowball.png b/Sprites/Bullets/Snowball.png new file mode 100644 index 00000000..7e70c6bb --- /dev/null +++ b/Sprites/Bullets/Snowball.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4659a44aafd1337e4ccad50f7f4883cb2f98215f6076fd9a61febae89793e1d +size 324 diff --git a/Sprites/Bullets/Snowball.png.import b/Sprites/Bullets/Snowball.png.import new file mode 100644 index 00000000..fdd9c406 --- /dev/null +++ b/Sprites/Bullets/Snowball.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://r2h77ktff10m" +path="res://.godot/imported/Snowball.png-ecfb9a89abe8b58c77ee9696264e45cf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/Bullets/Snowball.png" +dest_files=["res://.godot/imported/Snowball.png-ecfb9a89abe8b58c77ee9696264e45cf.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