diff --git a/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs b/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs index 32b64ac2..925aa2d1 100644 --- a/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs +++ b/Zennysoft.Game.Ma.Implementation/Audio/state/InGameAudioLogic.Output.cs @@ -15,6 +15,8 @@ public partial class InGameAudioLogic public readonly record struct PlayPlayerAttackWallSound; + public readonly record struct PlayPlayerAttackEnemySound; + public readonly record struct PlayMenuScrollSound; public readonly record struct PlayEquipSound; diff --git a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs index 42ec9bb7..3fad5786 100644 --- a/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs +++ b/Zennysoft.Game.Ma.Implementation/Game/GameRepo.cs @@ -23,6 +23,8 @@ public interface IGameRepo : IDisposable event Action? PlayerAttackedWall; + event Action? PlayerAttackedEnemy; + void Pause(); void Resume(); @@ -43,6 +45,8 @@ public interface IGameRepo : IDisposable public void OnPlayerAttackedWall(); + public void OnPlayerAttackedEnemy(); + public void CloseInventory(); public void GameEnded(); @@ -61,6 +65,7 @@ public class GameRepo : IGameRepo public event Action? RemoveItemFromInventoryEvent; public event Action? PlayerAttack; public event Action? PlayerAttackedWall; + public event Action? PlayerAttackedEnemy; public IAutoProp IsPaused => _isPaused; private readonly AutoProp _isPaused; @@ -97,6 +102,7 @@ public class GameRepo : IGameRepo public void EndDoubleExp() { AnnounceMessageOnMainScreen("Experience points effect wore off."); + DoubleExpTimeEnd?.Invoke(); ExpRate = 1; } @@ -125,6 +131,11 @@ public class GameRepo : IGameRepo PlayerAttackedWall?.Invoke(); } + public void OnPlayerAttackedEnemy() + { + PlayerAttackedEnemy?.Invoke(); + } + public void CloseInventory() { CloseInventoryEvent?.Invoke(); diff --git a/Zennysoft.Game.Ma/src/app/App.cs b/Zennysoft.Game.Ma/src/app/App.cs index 27f13589..2d427618 100644 --- a/Zennysoft.Game.Ma/src/app/App.cs +++ b/Zennysoft.Game.Ma/src/app/App.cs @@ -1,4 +1,4 @@ -using Chickensoft.AutoInject; +using Chickensoft.AutoInject; using Chickensoft.GodotNodeInterfaces; using Chickensoft.Introspection; using Godot; @@ -38,80 +38,80 @@ public partial class App : CanvasLayer, IApp public void Initialize() { - var container = new SimpleInjector.Container(); - container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); - container.Register(Lifestyle.Singleton); - container.Register(Lifestyle.Singleton); - container.Verify(); + var container = new SimpleInjector.Container(); + container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); + container.Register(Lifestyle.Singleton); + container.Register(Lifestyle.Singleton); + container.Verify(); - Instantiator = new Instantiator(GetTree()); + Instantiator = new Instantiator(GetTree()); - AppRepo = container.GetInstance(); - AppLogic = container.GetInstance(); + AppRepo = container.GetInstance(); + AppLogic = container.GetInstance(); - AppLogic.Set(AppRepo); - AppLogic.Set(new AppLogic.Data()); + AppLogic.Set(AppRepo); + AppLogic.Set(new AppLogic.Data()); - Menu.NewGame += OnNewGame; - Menu.LoadGame += OnLoadGame; - Menu.Quit += OnQuit; + Menu.NewGame += OnNewGame; + Menu.LoadGame += OnLoadGame; + Menu.Quit += OnQuit; - AnimationPlayer.AnimationFinished += OnAnimationFinished; + AnimationPlayer.AnimationFinished += OnAnimationFinished; - Input.MouseMode = Input.MouseModeEnum.Visible; - this.Provide(); + Input.MouseMode = Input.MouseModeEnum.Visible; + this.Provide(); } public void OnReady() { - AppBinding = AppLogic.Bind(); + AppBinding = AppLogic.Bind(); - AppBinding - .Handle((in AppLogic.Output.ShowSplashScreen _) => - { - HideMenus(); - BlankScreen.Hide(); - Splash.Show(); - }) - .Handle((in AppLogic.Output.HideSplashScreen _) => - { - BlankScreen.Show(); - FadeToBlack(); - }) - .Handle((in AppLogic.Output.SetupGameScene _) => - { - Game = Instantiator.LoadAndInstantiate(GAME_SCENE_PATH); - GameWindow.AddChildEx(Game); - Instantiator.SceneTree.Paused = false; - }) - .Handle((in AppLogic.Output.ShowMainMenu _) => - { - // Load everything while we're showing a black screen, then fade in. - HideMenus(); - Menu.Show(); + AppBinding + .Handle((in AppLogic.Output.ShowSplashScreen _) => + { + HideMenus(); + BlankScreen.Hide(); + Splash.Show(); + }) + .Handle((in AppLogic.Output.HideSplashScreen _) => + { + BlankScreen.Show(); + FadeToBlack(); + }) + .Handle((in AppLogic.Output.SetupGameScene _) => + { + Game = Instantiator.LoadAndInstantiate(GAME_SCENE_PATH); + GameWindow.AddChildEx(Game); + Instantiator.SceneTree.Paused = false; + }) + .Handle((in AppLogic.Output.ShowMainMenu _) => + { + // Load everything while we're showing a black screen, then fade in. + HideMenus(); + Menu.Show(); - FadeInFromBlack(); - Menu.NewGameButton.GrabFocus(); - }) - .Handle((in AppLogic.Output.FadeToBlack _) => FadeToBlack()) - .Handle((in AppLogic.Output.HideGame _) => FadeToBlack()) - .Handle((in AppLogic.Output.ShowGame _) => - { - HideMenus(); - FadeInFromBlack(); - }) - .Handle((in AppLogic.Output.StartLoadingSaveFile _) => - { - Game.SaveFileLoaded += OnSaveFileLoaded; - Game.LoadExistingGame(); - }) - .Handle((in AppLogic.Output.ExitGame _) => - { - GetTree().Quit(); - }); + FadeInFromBlack(); + Menu.NewGameButton.GrabFocus(); + }) + .Handle((in AppLogic.Output.FadeToBlack _) => FadeToBlack()) + .Handle((in AppLogic.Output.HideGame _) => FadeToBlack()) + .Handle((in AppLogic.Output.ShowGame _) => + { + HideMenus(); + FadeInFromBlack(); + }) + .Handle((in AppLogic.Output.StartLoadingSaveFile _) => + { + Game.SaveFileLoaded += OnSaveFileLoaded; + Game.LoadExistingGame(); + }) + .Handle((in AppLogic.Output.ExitGame _) => + { + GetTree().Quit(); + }); - AppLogic.Start(); + AppLogic.Start(); } public void OnNewGame() => AppLogic.Input(new AppLogic.Input.NewGame()); @@ -122,44 +122,44 @@ public partial class App : CanvasLayer, IApp public void OnSaveFileLoaded() { - Game.SaveFileLoaded -= OnSaveFileLoaded; - AppLogic.Input(new AppLogic.Input.SaveFileLoaded()); + Game.SaveFileLoaded -= OnSaveFileLoaded; + AppLogic.Input(new AppLogic.Input.SaveFileLoaded()); } public void FadeInFromBlack() { - BlankScreen.Show(); - AnimationPlayer.Play("fade_in"); + BlankScreen.Show(); + AnimationPlayer.Play("fade_in"); } public void FadeToBlack() { - BlankScreen.Show(); - AnimationPlayer.Play("fade_out"); + BlankScreen.Show(); + AnimationPlayer.Play("fade_out"); } public void HideMenus() { - Splash.Hide(); - Menu.Hide(); + Splash.Hide(); + Menu.Hide(); } public void OnAnimationFinished(StringName animation) { - if (animation == "fade_in") - { - AppLogic.Input(new AppLogic.Input.FadeInFinished()); - BlankScreen.Hide(); - return; - } + if (animation == "fade_in") + { + AppLogic.Input(new AppLogic.Input.FadeInFinished()); + BlankScreen.Hide(); + return; + } - AppLogic.Input(new AppLogic.Input.FadeOutFinished()); + AppLogic.Input(new AppLogic.Input.FadeOutFinished()); } public void OnExitTree() { - AppLogic.Stop(); - AppBinding.Dispose(); - AppRepo.Dispose(); + AppLogic.Stop(); + AppBinding.Dispose(); + AppRepo.Dispose(); } } diff --git a/Zennysoft.Game.Ma/src/audio/InGameAudio.cs b/Zennysoft.Game.Ma/src/audio/InGameAudio.cs index aa6fb9d5..8db09312 100644 --- a/Zennysoft.Game.Ma/src/audio/InGameAudio.cs +++ b/Zennysoft.Game.Ma/src/audio/InGameAudio.cs @@ -37,6 +37,8 @@ public partial class InGameAudio : Node [Node] public IAudioStreamPlayer PlayerAttackWallSFX { get; set; } = default!; + [Node] public IAudioStreamPlayer PlayerAttackEnemySFX { get; set; } = default!; + [Node] public IAudioStreamPlayer MenuScrollSFX { get; set; } = default!; [Node] public IAudioStreamPlayer EquipSFX { get; set; } = default!; @@ -77,7 +79,8 @@ public partial class InGameAudio : Node .Handle((in InGameAudioLogic.Output.PlayHealingItemSound _) => PlayHealingItemSound()) .Handle((in InGameAudioLogic.Output.PlayTeleportSound _) => PlayTeleportSound()) .Handle((in InGameAudioLogic.Output.PlayPlayerAttackSound _) => { PlayerAttackSFX.Stop(); PlayerAttackSFX.Play(); }) - .Handle((in InGameAudioLogic.Output.PlayPlayerAttackWallSound _) => { PlayerAttackWallSFX.Stop(); PlayerAttackWallSFX.Play(); }); + .Handle((in InGameAudioLogic.Output.PlayPlayerAttackWallSound _) => { PlayerAttackWallSFX.Stop(); PlayerAttackWallSFX.Play(); }) + .Handle((in InGameAudioLogic.Output.PlayPlayerAttackEnemySound _) => { PlayerAttackEnemySFX.Stop(); PlayerAttackEnemySFX.Play(); }); InGameAudioLogic.Start(); } diff --git a/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn b/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn index ae6b0efb..394afc34 100644 --- a/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn +++ b/Zennysoft.Game.Ma/src/audio/InGameAudio.tscn @@ -3,17 +3,17 @@ [ext_resource type="Script" uid="uid://2mnouyn1jcqs" path="res://src/audio/InGameAudio.cs" id="1_gpmcr"] [ext_resource type="AudioStream" uid="uid://dfu0fksb6slhx" path="res://src/audio/music/droney.mp3" id="2_8hfyr"] [ext_resource type="AudioStream" uid="uid://d2jrktp06xsba" path="res://src/audio/music/crossing-the-gate.mp3" id="3_wbmd6"] -[ext_resource type="Script" path="res://src/audio/BGMPlayer.cs" id="3_wtvpb"] +[ext_resource type="Script" uid="uid://d2usinntpmcry" path="res://src/audio/BGMPlayer.cs" id="3_wtvpb"] [ext_resource type="AudioStream" uid="uid://dn2e2hqujlia1" path="res://src/audio/music/tar-winds.mp3" id="4_surnl"] [ext_resource type="AudioStream" uid="uid://t3g04u722f2k" path="res://src/audio/music/useless immune system-1.mp3" id="6_agr3r"] [ext_resource type="AudioStream" uid="uid://cn8cugshq3o8k" path="res://src/audio/sfx/PlayerHitWallSFX.wav" id="7_8vh2f"] -[ext_resource type="AudioStream" uid="uid://dor0in0x2fg48" path="res://src/audio/sfx/TempFFVII/menu-move.ogg" id="7_777nl"] +[ext_resource type="AudioStream" uid="uid://dor0in0x2fg48" path="res://src/audio/sfx/MenuScrollSFX.ogg" id="7_777nl"] [ext_resource type="AudioStream" uid="uid://d1mlduwauechv" path="res://src/audio/sfx/PlayerAttackSFX.wav" id="7_wtvpb"] -[ext_resource type="AudioStream" uid="uid://r1tryiit38i8" path="res://src/audio/sfx/TempFFVII/menu-back.ogg" id="8_1xcgo"] -[ext_resource type="AudioStream" uid="uid://bjj61s8q2gwb8" path="res://src/audio/sfx/TempFFVII/junction.ogg" id="8_kwybb"] -[ext_resource type="AudioStream" uid="uid://myx4s8lmarc2" path="res://src/audio/sfx/TempFFVII/something-earned.ogg" id="10_3lcw5"] -[ext_resource type="AudioStream" uid="uid://dci08kmwsu6k1" path="res://src/audio/sfx/TempFFVII/teleport.ogg" id="11_offhc"] -[ext_resource type="AudioStream" uid="uid://d3sn7c614uj2n" path="res://src/audio/sfx/TempFFVII/sort.ogg" id="12_wprjr"] +[ext_resource type="AudioStream" uid="uid://r1tryiit38i8" path="res://src/audio/sfx/MenuBackSFX.ogg" id="8_1xcgo"] +[ext_resource type="AudioStream" uid="uid://bjj61s8q2gwb8" path="res://src/audio/sfx/EquipSFX.ogg" id="8_kwybb"] +[ext_resource type="AudioStream" uid="uid://myx4s8lmarc2" path="res://src/audio/sfx/HealSFX.ogg" id="10_3lcw5"] +[ext_resource type="AudioStream" uid="uid://dci08kmwsu6k1" path="res://src/audio/sfx/ExitSFX.ogg" id="11_offhc"] +[ext_resource type="AudioStream" uid="uid://d3sn7c614uj2n" path="res://src/audio/sfx/SortSFX.ogg" id="12_wprjr"] [node name="InGameAudio" type="Node"] process_mode = 3 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/junction.ogg b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/junction.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import new file mode 100644 index 00000000..19e16920 --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/EquipSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://bjj61s8q2gwb8" +path="res://.godot/imported/EquipSFX.ogg-6a8dd8843f1eb38662d6d370e4b2f930.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/EquipSFX.ogg" +dest_files=["res://.godot/imported/EquipSFX.ogg-6a8dd8843f1eb38662d6d370e4b2f930.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/teleport.ogg b/Zennysoft.Game.Ma/src/audio/sfx/ExitSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/teleport.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/ExitSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/ExitSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/ExitSFX.ogg.import new file mode 100644 index 00000000..bf97ba35 --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/ExitSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://dci08kmwsu6k1" +path="res://.godot/imported/ExitSFX.ogg-c16c2cdec4e3d13c44aa79cc98a70d7b.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/ExitSFX.ogg" +dest_files=["res://.godot/imported/ExitSFX.ogg-c16c2cdec4e3d13c44aa79cc98a70d7b.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/something-earned.ogg b/Zennysoft.Game.Ma/src/audio/sfx/HealSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/something-earned.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/HealSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/HealSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/HealSFX.ogg.import new file mode 100644 index 00000000..67dc3cf7 --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/HealSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://myx4s8lmarc2" +path="res://.godot/imported/HealSFX.ogg-8e33fc432d3aa613fb5d921400562a51.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/HealSFX.ogg" +dest_files=["res://.godot/imported/HealSFX.ogg-8e33fc432d3aa613fb5d921400562a51.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-back.ogg b/Zennysoft.Game.Ma/src/audio/sfx/MenuBackSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-back.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/MenuBackSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/MenuBackSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/MenuBackSFX.ogg.import new file mode 100644 index 00000000..3a228a4e --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/MenuBackSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://r1tryiit38i8" +path="res://.godot/imported/MenuBackSFX.ogg-940782881d58f1c4c5f95977b5f42009.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/MenuBackSFX.ogg" +dest_files=["res://.godot/imported/MenuBackSFX.ogg-940782881d58f1c4c5f95977b5f42009.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-move.ogg b/Zennysoft.Game.Ma/src/audio/sfx/MenuScrollSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-move.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/MenuScrollSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/MenuScrollSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/MenuScrollSFX.ogg.import new file mode 100644 index 00000000..345edf7e --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/MenuScrollSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://dor0in0x2fg48" +path="res://.godot/imported/MenuScrollSFX.ogg-b1800108be1a856f464e62089f5b0279.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/MenuScrollSFX.ogg" +dest_files=["res://.godot/imported/MenuScrollSFX.ogg-b1800108be1a856f464e62089f5b0279.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/sort.ogg b/Zennysoft.Game.Ma/src/audio/sfx/SortSFX.ogg similarity index 100% rename from Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/sort.ogg rename to Zennysoft.Game.Ma/src/audio/sfx/SortSFX.ogg diff --git a/Zennysoft.Game.Ma/src/audio/sfx/SortSFX.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/SortSFX.ogg.import new file mode 100644 index 00000000..16754a1a --- /dev/null +++ b/Zennysoft.Game.Ma/src/audio/sfx/SortSFX.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://d3sn7c614uj2n" +path="res://.godot/imported/SortSFX.ogg-7f616a0a2af3902cddc2ea22947a5f02.oggvorbisstr" + +[deps] + +source_file="res://src/audio/sfx/SortSFX.ogg" +dest_files=["res://.godot/imported/SortSFX.ogg-7f616a0a2af3902cddc2ea22947a5f02.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/Equip.wav.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/Equip.wav.import deleted file mode 100644 index a139220f..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/Equip.wav.import +++ /dev/null @@ -1,23 +0,0 @@ -[remap] - -importer="wav" -type="AudioStreamWAV" -uid="uid://t28qhjuibv3f" -valid=false - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/Equip.wav" - -[params] - -force/8_bit=false -force/mono=false -force/max_rate=false -force/max_rate_hz=44100 -edit/trim=false -edit/normalize=false -edit/loop_mode=0 -edit/loop_begin=0 -edit/loop_end=-1 -compress/mode=0 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/junction.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/junction.ogg.import deleted file mode 100644 index 5f7076b7..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/junction.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://bjj61s8q2gwb8" -path="res://.godot/imported/junction.ogg-f4350086a08e048d3008edcdc25abf96.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/junction.ogg" -dest_files=["res://.godot/imported/junction.ogg-f4350086a08e048d3008edcdc25abf96.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-back.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-back.ogg.import deleted file mode 100644 index cb391b1d..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-back.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://r1tryiit38i8" -path="res://.godot/imported/menu-back.ogg-3ec385c1a9cfaaa1be4ba85197708f0c.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/menu-back.ogg" -dest_files=["res://.godot/imported/menu-back.ogg-3ec385c1a9cfaaa1be4ba85197708f0c.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-move.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-move.ogg.import deleted file mode 100644 index eb4805b6..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu-move.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://dor0in0x2fg48" -path="res://.godot/imported/menu-move.ogg-d71b0989e00dd1d4488a72c7dde3d41d.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/menu-move.ogg" -dest_files=["res://.godot/imported/menu-move.ogg-d71b0989e00dd1d4488a72c7dde3d41d.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav deleted file mode 100644 index 2505d92d..00000000 Binary files a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav and /dev/null differ diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav.import deleted file mode 100644 index 05cea912..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/menu.wav.import +++ /dev/null @@ -1,24 +0,0 @@ -[remap] - -importer="wav" -type="AudioStreamWAV" -uid="uid://tce7m18vkgao" -path="res://.godot/imported/menu.wav-3931712b8a8483f269018c4a880368b2.sample" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/menu.wav" -dest_files=["res://.godot/imported/menu.wav-3931712b8a8483f269018c4a880368b2.sample"] - -[params] - -force/8_bit=false -force/mono=false -force/max_rate=false -force/max_rate_hz=44100 -edit/trim=false -edit/normalize=false -edit/loop_mode=0 -edit/loop_begin=0 -edit/loop_end=-1 -compress/mode=0 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/something-earned.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/something-earned.ogg.import deleted file mode 100644 index b3cfc1e7..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/something-earned.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://myx4s8lmarc2" -path="res://.godot/imported/something-earned.ogg-150627e4deb45db30e8dd2f98ddcc5a8.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/something-earned.ogg" -dest_files=["res://.godot/imported/something-earned.ogg-150627e4deb45db30e8dd2f98ddcc5a8.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/sort.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/sort.ogg.import deleted file mode 100644 index 8be73551..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/sort.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://d3sn7c614uj2n" -path="res://.godot/imported/sort.ogg-cb2a2c4769c8e6574221a3c313e75bcf.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/sort.ogg" -dest_files=["res://.godot/imported/sort.ogg-cb2a2c4769c8e6574221a3c313e75bcf.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/teleport.ogg.import b/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/teleport.ogg.import deleted file mode 100644 index 34379caf..00000000 --- a/Zennysoft.Game.Ma/src/audio/sfx/TempFFVII/teleport.ogg.import +++ /dev/null @@ -1,19 +0,0 @@ -[remap] - -importer="oggvorbisstr" -type="AudioStreamOggVorbis" -uid="uid://dci08kmwsu6k1" -path="res://.godot/imported/teleport.ogg-9024f7b675b201a391dee183da020b1d.oggvorbisstr" - -[deps] - -source_file="res://src/audio/sfx/TempFFVII/teleport.ogg" -dest_files=["res://.godot/imported/teleport.ogg-9024f7b675b201a391dee183da020b1d.oggvorbisstr"] - -[params] - -loop=false -loop_offset=0 -bpm=0 -beat_count=0 -bar_beats=4 diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs index 48921251..fad0012f 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.cs @@ -20,57 +20,57 @@ public partial class Sproingy : Enemy, IHasPrimaryAttack, ICanPatrol public void OnReady() { - SetPhysicsProcess(true); - ((EnemyModelView2D)_enemyModelView).Hitbox.AreaEntered += Hitbox_AreaEntered; + SetPhysicsProcess(true); + ((EnemyModelView2D)_enemyModelView).Hitbox.AreaEntered += Hitbox_AreaEntered; } public void OnPhysicsProcess(double delta) { - _enemyLogic.Input(new EnemyLogic.Input.PhysicsTick(delta)); + _enemyLogic.Input(new EnemyLogic.Input.PhysicsTick(delta)); - if (_enemyLogic.Value is not EnemyLogic.State.Activated) - return; + if (_enemyLogic.Value is not EnemyLogic.State.Activated) + return; - if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) < 1.5f) - _enemyLogic.Input(new EnemyLogic.Input.StartAttacking()); - if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) > 30f) - _enemyLogic.Input(new EnemyLogic.Input.LostPlayer()); - if (_enemyLogic.Value is EnemyLogic.State.Attacking && GlobalPosition.DistanceTo(_player.CurrentPosition) > 3f) - _enemyLogic.Input(new EnemyLogic.Input.Alerted()); + if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) < 1.5f) + _enemyLogic.Input(new EnemyLogic.Input.StartAttacking()); + if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(_player.CurrentPosition) > 30f) + _enemyLogic.Input(new EnemyLogic.Input.LostPlayer()); + if (_enemyLogic.Value is EnemyLogic.State.Attacking && GlobalPosition.DistanceTo(_player.CurrentPosition) > 3f) + _enemyLogic.Input(new EnemyLogic.Input.Alerted()); - _navigationAgentClient.CalculateVelocity(GlobalPosition, true); + _navigationAgentClient.CalculateVelocity(GlobalPosition, true); - base._PhysicsProcess(delta); + base._PhysicsProcess(delta); } public override void TakeAction() { - PrimaryAttack(); + PrimaryAttack(); } public void PrimaryAttack() { - _enemyModelView.PlayPrimaryAttackAnimation(); + _enemyModelView.PlayPrimaryAttackAnimation(); } public override void SetTarget(Vector3 target) => _navigationAgentClient.SetTarget(target); public void Patrol() { - var rng = new RandomNumberGenerator(); - rng.Randomize(); - var randomizedSpot = new Vector3(rng.RandfRange(-5.0f, 5.0f), 0, rng.RandfRange(-5.0f, 5.0f)); - _enemyLogic.Input(new EnemyLogic.Input.PatrolToRandomSpot(GlobalPosition + randomizedSpot)); - _enemyLogic.Input(new EnemyLogic.Input.StartPatrol()); + var rng = new RandomNumberGenerator(); + rng.Randomize(); + var randomizedSpot = new Vector3(rng.RandfRange(-5.0f, 5.0f), 0, rng.RandfRange(-5.0f, 5.0f)); + _enemyLogic.Input(new EnemyLogic.Input.PatrolToRandomSpot(GlobalPosition + randomizedSpot)); + _enemyLogic.Input(new EnemyLogic.Input.StartPatrol()); } private void Hitbox_AreaEntered(Area3D area) { - var target = area.GetOwner(); - if (target is IPlayer player) - { - var damage = _enemyStatResource.CurrentAttack * PrimaryAttackElementalDamageBonus; - player.TakeDamage(damage, PrimaryAttackElementalType, BattleExtensions.IsCriticalHit(_enemyStatResource.Luck)); - } + var target = area.GetOwner(); + if (target is IPlayer player) + { + var damage = _enemyStatResource.CurrentAttack * PrimaryAttackElementalDamageBonus; + player.TakeDamage(damage, PrimaryAttackElementalType, BattleExtensions.IsCriticalHit(_enemyStatResource.Luck)); + } } -} \ No newline at end of file +} diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn index 9f0346b1..5c0849e8 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/01. sproingy/Sproingy.tscn @@ -27,13 +27,13 @@ metadata/_custom_type_script = ExtResource("2_oln85") radius = 0.106078 height = 1.23076 +[sub_resource type="SphereShape3D" id="SphereShape3D_8vcnq"] +radius = 0.57308 + [sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"] height = 5.0 radius = 1.0 -[sub_resource type="SphereShape3D" id="SphereShape3D_8vcnq"] -radius = 0.57308 - [node name="Sproingy" type="CharacterBody3D"] process_mode = 1 collision_layer = 10 @@ -44,46 +44,54 @@ axis_lock_angular_z = true script = ExtResource("1_xsluo") _enemyStatResource = SubResource("Resource_oln85") -[node name="NavigationAgentClient" parent="." instance=ExtResource("3_ut5m2")] -unique_name_in_owner = true - [node name="CollisionShape" type="CollisionShape3D" parent="."] unique_name_in_owner = true transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) shape = SubResource("CapsuleShape3D_cwfph") -[node name="LineOfSight" type="Area3D" parent="."] +[node name="Navigation" type="Node3D" parent="."] + +[node name="NavigationAgentClient" parent="Navigation" instance=ExtResource("3_ut5m2")] +unique_name_in_owner = true + +[node name="Collision" type="Node3D" parent="."] + +[node name="Collision" type="Area3D" parent="Collision"] +collision_layer = 2048 +collision_mask = 0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision/Collision"] +shape = SubResource("SphereShape3D_8vcnq") + +[node name="LineOfSight" type="Area3D" parent="Collision"] unique_name_in_owner = true transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) collision_layer = 2 collision_mask = 2 -[node name="CollisionShape3D" type="CollisionShape3D" parent="LineOfSight"] +[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision/LineOfSight"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, -2) shape = SubResource("CylinderShape3D_jbgmx") -[node name="PatrolTimer" type="Timer" parent="."] -unique_name_in_owner = true -wait_time = 10.0 -autostart = true - -[node name="AttackTimer" type="Timer" parent="."] -unique_name_in_owner = true -wait_time = 0.8 -autostart = true - -[node name="Raycast" type="RayCast3D" parent="."] +[node name="Raycast" type="RayCast3D" parent="Collision"] unique_name_in_owner = true target_position = Vector3(0, 0, -5) collision_mask = 3 -[node name="EnemyModelView" parent="." instance=ExtResource("4_o3b7p")] +[node name="Visual" type="Node3D" parent="."] + +[node name="EnemyModelView" parent="Visual" instance=ExtResource("4_o3b7p")] unique_name_in_owner = true transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0.0862446, 0) -[node name="Collision" type="Area3D" parent="."] -collision_layer = 2048 -collision_mask = 0 +[node name="Timers" type="Node" parent="."] -[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision"] -shape = SubResource("SphereShape3D_8vcnq") +[node name="PatrolTimer" type="Timer" parent="Timers"] +unique_name_in_owner = true +wait_time = 10.0 +autostart = true + +[node name="AttackTimer" type="Timer" parent="Timers"] +unique_name_in_owner = true +wait_time = 0.8 +autostart = true diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 191e7145..50666fe0 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -106,506 +106,508 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide - { - { 2, 12 }, - { 3, 39 }, - { 4, 87 }, - { 5, 162 }, - { 6, 270 }, - { 7, 417 }, - { 8, 609 } - }; + AnimationPlayer.AnimationFinished += OnAnimationFinished; + _expToNextLevel = new Dictionary + { + { 2, 12 }, + { 3, 39 }, + { 4, 87 }, + { 5, 162 }, + { 6, 270 }, + { 7, 417 }, + { 8, 609 } + }; } public void Setup() { - var container = new SimpleInjector.Container(); - container.Register(Lifestyle.Singleton); - container.Verify(); + var container = new SimpleInjector.Container(); + container.Register(Lifestyle.Singleton); + container.Verify(); - Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration }; - Stats = new PlayerStatController(); - Stats.Init( - new PlayerStats - { - CurrentHP = PlayerStatResource.CurrentHP, - MaximumHP = PlayerStatResource.MaximumHP, - CurrentVT = PlayerStatResource.CurrentVT, - MaximumVT = PlayerStatResource.MaximumVT, - CurrentAttack = PlayerStatResource.CurrentAttack, - BonusAttack = PlayerStatResource.BonusAttack, - MaxAttack = PlayerStatResource.MaxAttack, - CurrentDefense = PlayerStatResource.CurrentDefense, - BonusDefense = PlayerStatResource.BonusDefense, - MaxDefense = PlayerStatResource.MaxDefense, - CurrentExp = PlayerStatResource.CurrentExp, - CurrentLevel = PlayerStatResource.CurrentLevel, - ExpToNextLevel = PlayerStatResource.ExpToNextLevel, - Luck = PlayerStatResource.Luck - }); + Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration }; + Stats = new PlayerStatController(); + Stats.Init( + new PlayerStats + { + CurrentHP = PlayerStatResource.CurrentHP, + MaximumHP = PlayerStatResource.MaximumHP, + CurrentVT = PlayerStatResource.CurrentVT, + MaximumVT = PlayerStatResource.MaximumVT, + CurrentAttack = PlayerStatResource.CurrentAttack, + BonusAttack = PlayerStatResource.BonusAttack, + MaxAttack = PlayerStatResource.MaxAttack, + CurrentDefense = PlayerStatResource.CurrentDefense, + BonusDefense = PlayerStatResource.BonusDefense, + MaxDefense = PlayerStatResource.MaxDefense, + CurrentExp = PlayerStatResource.CurrentExp, + CurrentLevel = PlayerStatResource.CurrentLevel, + ExpToNextLevel = PlayerStatResource.ExpToNextLevel, + Luck = PlayerStatResource.Luck + }); - Inventory = new Inventory(); + Inventory = new Inventory(); - PlayerLogic = container.GetInstance(); - PlayerLogic.Set(this as IPlayer); - PlayerLogic.Set(Settings); - PlayerLogic.Set(Stats); - PlayerLogic.Set(_gameRepo); + PlayerLogic = container.GetInstance(); + PlayerLogic.Set(this as IPlayer); + PlayerLogic.Set(Settings); + PlayerLogic.Set(Stats); + PlayerLogic.Set(_gameRepo); - var defaultWeapon = new Weapon(); - defaultWeapon.Stats = _defaultWeapon; - var defaultArmor = new Armor(); - defaultArmor.Stats = _defaultArmor; - Inventory.TryAdd(defaultWeapon); - Inventory.TryAdd(defaultArmor); + var defaultWeapon = new Weapon(); + defaultWeapon.Stats = _defaultWeapon; + var defaultArmor = new Armor(); + defaultArmor.Stats = _defaultArmor; + Inventory.TryAdd(defaultWeapon); + Inventory.TryAdd(defaultArmor); - EquippedWeapon.Sync += EquippedWeapon_Sync; - EquippedArmor.Sync += EquippedArmor_Sync; - EquippedAccessory.Sync += EquippedAccessory_Sync; - Stats.CurrentHP.Sync += CurrentHP_Sync; - Stats.CurrentExp.Sync += CurrentEXP_Sync; + EquippedWeapon.Sync += EquippedWeapon_Sync; + EquippedArmor.Sync += EquippedArmor_Sync; + EquippedAccessory.Sync += EquippedAccessory_Sync; + Stats.CurrentHP.Sync += CurrentHP_Sync; + Stats.CurrentExp.Sync += CurrentEXP_Sync; - Equip(defaultWeapon); - Equip(defaultArmor); + Equip(defaultWeapon); + Equip(defaultArmor); - HealthTimer.WaitTime = _healthTimerWaitTime; - HealthTimer.Timeout += OnHealthTimerTimeout; - Hitbox.AreaEntered += Hitbox_AreaEntered; - CollisionDetector.AreaEntered += CollisionDetector_AreaEntered; + HealthTimer.WaitTime = _healthTimerWaitTime; + HealthTimer.Timeout += OnHealthTimerTimeout; + Hitbox.AreaEntered += Hitbox_AreaEntered; + CollisionDetector.AreaEntered += CollisionDetector_AreaEntered; } public void OnResolved() { - PlayerChunk = new SaveChunk( - onSave: (chunk) => new PlayerData() - { - PlayerStats = new PlayerStats() - { - CurrentHP = Stats.CurrentHP.Value, - MaximumHP = Stats.MaximumHP.Value, - CurrentVT = Stats.CurrentVT.Value, - MaximumVT = Stats.MaximumVT.Value, - CurrentAttack = Stats.CurrentAttack.Value, - BonusAttack = Stats.BonusAttack.Value, - MaxAttack = Stats.MaxAttack.Value, - CurrentDefense = Stats.CurrentDefense.Value, - BonusDefense = Stats.BonusDefense.Value, - MaxDefense = Stats.MaxDefense.Value, - CurrentExp = Stats.CurrentExp.Value, - CurrentLevel = Stats.CurrentLevel.Value, - ExpToNextLevel = Stats.ExpToNextLevel.Value, - Luck = Stats.Luck.Value - }, - Inventory = Inventory - }, - onLoad: (chunk, data) => - { - Stats.Init(data.PlayerStats); - Inventory = data.Inventory; - } - ); + PlayerChunk = new SaveChunk( + onSave: (chunk) => new PlayerData() + { + PlayerStats = new PlayerStats() + { + CurrentHP = Stats.CurrentHP.Value, + MaximumHP = Stats.MaximumHP.Value, + CurrentVT = Stats.CurrentVT.Value, + MaximumVT = Stats.MaximumVT.Value, + CurrentAttack = Stats.CurrentAttack.Value, + BonusAttack = Stats.BonusAttack.Value, + MaxAttack = Stats.MaxAttack.Value, + CurrentDefense = Stats.CurrentDefense.Value, + BonusDefense = Stats.BonusDefense.Value, + MaxDefense = Stats.MaxDefense.Value, + CurrentExp = Stats.CurrentExp.Value, + CurrentLevel = Stats.CurrentLevel.Value, + ExpToNextLevel = Stats.ExpToNextLevel.Value, + Luck = Stats.Luck.Value + }, + Inventory = Inventory + }, + onLoad: (chunk, data) => + { + Stats.Init(data.PlayerStats); + Inventory = data.Inventory; + } + ); - PlayerBinding = PlayerLogic.Bind(); + PlayerBinding = PlayerLogic.Bind(); - PlayerBinding - .Handle((in PlayerLogic.Output.Animations.Attack output) => - { - if (PlayerIsHittingGeometry()) - { - AnimationPlayer.Play("hit_wall"); - _gameRepo.OnPlayerAttackedWall(); - } - else - { - var attackSpeed = ((Weapon)EquippedWeapon.Value).AttackSpeed; - AnimationPlayer.SetSpeedScale((float)attackSpeed); - AnimationPlayer.Play("attack"); - _gameRepo.OnPlayerAttack(); - } - }) - .Handle((in PlayerLogic.Output.ThrowItem output) => - { - }) - .Handle((in PlayerLogic.Output.Move output) => - { - Move(output.delta); - }); + PlayerBinding + .Handle((in PlayerLogic.Output.Animations.Attack output) => + { + if (PlayerIsHittingGeometry()) + { + AnimationPlayer.Play("hit_wall"); + _gameRepo.OnPlayerAttackedWall(); + } + else + { + var attackSpeed = ((Weapon)EquippedWeapon.Value).AttackSpeed; + AnimationPlayer.SetSpeedScale((float)attackSpeed); + AnimationPlayer.Play("attack"); + _gameRepo.OnPlayerAttack(); + } + }) + .Handle((in PlayerLogic.Output.ThrowItem output) => + { + }) + .Handle((in PlayerLogic.Output.Move output) => + { + Move(output.delta); + }); - GameChunk.AddChunk(PlayerChunk); + GameChunk.AddChunk(PlayerChunk); - PlayerLogic.Start(); - this.Provide(); + PlayerLogic.Start(); + this.Provide(); } public void OnReady() { - SetPhysicsProcess(true); - SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2; + SetPhysicsProcess(true); + SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2; } #endregion public void Attack() { - PlayerLogic.Input(new PlayerLogic.Input.Attack()); + PlayerLogic.Input(new PlayerLogic.Input.Attack()); } public void PlayerPause() { - Game.TogglePause(); + Game.TogglePause(); } public void RaiseHP(int amountToRaise) { - Stats.SetMaximumHP(Stats.MaximumHP.Value + amountToRaise); - Stats.SetCurrentHP(Stats.MaximumHP.Value); - _gameRepo.AnnounceMessageInInventory($"{amountToRaise}MAXHP Up."); + Stats.SetMaximumHP(Stats.MaximumHP.Value + amountToRaise); + Stats.SetCurrentHP(Stats.MaximumHP.Value); + _gameRepo.AnnounceMessageInInventory($"{amountToRaise}MAXHP Up."); } public void HealHP(int amountToRestore) { - Stats.SetCurrentHP(Stats.CurrentHP.Value + amountToRestore); - var raiseString = amountToRestore == 1000 ? "MAX" : $"{amountToRestore}"; - _gameRepo.AnnounceMessageInInventory($"{raiseString}HP Restored."); + Stats.SetCurrentHP(Stats.CurrentHP.Value + amountToRestore); + var raiseString = amountToRestore == 1000 ? "MAX" : $"{amountToRestore}"; + _gameRepo.AnnounceMessageInInventory($"{raiseString}HP Restored."); } public void RaiseVT(int amountToRaise) { - if (Stats.CurrentVT == Stats.MaximumVT) - { - Stats.SetMaximumVT(Stats.MaximumVT.Value + amountToRaise); - Stats.SetCurrentVT(Stats.MaximumVT.Value); - _gameRepo.AnnounceMessageInInventory($"{amountToRaise}MAXVT Up."); - } + if (Stats.CurrentVT == Stats.MaximumVT) + { + Stats.SetMaximumVT(Stats.MaximumVT.Value + amountToRaise); + Stats.SetCurrentVT(Stats.MaximumVT.Value); + _gameRepo.AnnounceMessageInInventory($"{amountToRaise}MAXVT Up."); + } } public void HealVT(int amountToRestore) { - Stats.SetCurrentVT(Stats.CurrentVT.Value + amountToRestore); - var raiseString = amountToRestore == 1000 ? "MAX" : $"{amountToRestore}"; - _gameRepo.AnnounceMessageInInventory($"{raiseString}VT Restored."); + Stats.SetCurrentVT(Stats.CurrentVT.Value + amountToRestore); + var raiseString = amountToRestore == 1000 ? "MAX" : $"{amountToRestore}"; + _gameRepo.AnnounceMessageInInventory($"{raiseString}VT Restored."); } public void ModifyBonusAttack(int amount) { - Stats.SetBonusAttack(Stats.BonusAttack.Value + amount); + Stats.SetBonusAttack(Stats.BonusAttack.Value + amount); } public void ModifyBonusDefense(int amount) { - Stats.SetBonusDefense(Stats.BonusDefense.Value + amount); + Stats.SetBonusDefense(Stats.BonusDefense.Value + amount); } public void ModifyMaximumHP(int amount) { - Stats.SetMaximumHP(Stats.MaximumHP.Value + amount); + Stats.SetMaximumHP(Stats.MaximumHP.Value + amount); } public void ModifyMaximumVT(int amount) { - Stats.SetMaximumVT(Stats.MaximumVT.Value + amount); + Stats.SetMaximumVT(Stats.MaximumVT.Value + amount); } public void ModifyBonusLuck(double amount) { - Stats.SetLuck(Stats.Luck.Value + amount); + Stats.SetLuck(Stats.Luck.Value + amount); } public void Move(float delta) { - var rawInput = GlobalInputVector; - var strafeLeftInput = LeftStrafeInputVector; - var strafeRightInput = RightStrafeInputVector; + var rawInput = GlobalInputVector; + var strafeLeftInput = LeftStrafeInputVector; + var strafeRightInput = RightStrafeInputVector; - var transform = Transform; - transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis; - var moveDirection = new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z).Normalized(); - var velocity = Basis * moveDirection * Settings.MoveSpeed * Settings.Acceleration; - _knockbackStrength = _knockbackStrength * 0.9f; - Transform = Transform with { Basis = transform.Basis }; - Velocity = velocity + (_knockbackDirection * _knockbackStrength); - MoveAndSlide(); + var transform = Transform; + transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis; + var moveDirection = new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z).Normalized(); + var velocity = Basis * moveDirection * Settings.MoveSpeed * Settings.Acceleration; + _knockbackStrength = _knockbackStrength * 0.9f; + Transform = Transform with { Basis = transform.Basis }; + Velocity = velocity + (_knockbackDirection * _knockbackStrength); + MoveAndSlide(); } public void TeleportPlayer(Transform3D newTransform) { - Transform = newTransform; + Transform = newTransform; } public void TakeDamage(double damage, ElementType elementType, bool isCriticalHit = false) { - if (Stats.CurrentHP.Value > 0) - { - damage = CalculateDefenseResistance(damage); - if (isCriticalHit) - damage *= 2; - Stats.SetCurrentHP(Stats.CurrentHP.Value - (int)damage); - } + if (Stats.CurrentHP.Value > 0) + { + damage = CalculateDefenseResistance(damage); + if (isCriticalHit) + damage *= 2; + Stats.SetCurrentHP(Stats.CurrentHP.Value - (int)damage); + } } public void Knockback(float impulse) { - _knockbackStrength = impulse; - _knockbackDirection = GlobalBasis.Z.Normalized(); + _knockbackStrength = impulse; + _knockbackDirection = GlobalBasis.Z.Normalized(); } public void GainExp(double expGained) { - Stats.SetCurrentExp(Stats.CurrentExp.Value + expGained); + Stats.SetCurrentExp(Stats.CurrentExp.Value + expGained); } public void LevelUp() { - var nextLevel = Stats.CurrentLevel.Value + 1; - var expToNextLevel = _expToNextLevel[nextLevel]; - var newCurrentExp = Mathf.Max(Stats.CurrentExp.Value - Stats.ExpToNextLevel.Value, 0); - Stats.SetCurrentLevel(nextLevel); - Stats.SetExpToNextLevel(expToNextLevel); - Stats.SetCurrentExp(newCurrentExp); + var nextLevel = Stats.CurrentLevel.Value + 1; + var expToNextLevel = _expToNextLevel[nextLevel]; + var newCurrentExp = Mathf.Max(Stats.CurrentExp.Value - Stats.ExpToNextLevel.Value, 0); + Stats.SetCurrentLevel(nextLevel); + Stats.SetExpToNextLevel(expToNextLevel); + Stats.SetCurrentExp(newCurrentExp); } public void Die() => PlayerLogic.Input(new PlayerLogic.Input.Die()); public override void _UnhandledInput(InputEvent @event) { - if (@event.IsActionPressed(GameInputs.Pause)) - PlayerPause(); + if (@event.IsActionPressed(GameInputs.Pause)) + PlayerPause(); - if (@event.IsActionPressed(GameInputs.Attack)) - Attack(); + if (@event.IsActionPressed(GameInputs.Attack)) + Attack(); } public void OnPhysicsProcess(double delta) { - PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta)); - PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform)); + PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta)); + PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform)); } public void Equip(EquipableItem equipable) { - if (equipable is Weapon weapon) - { - Unequip(_equippedWeapon.Value); - weapon.IsEquipped = true; - _equippedWeapon.OnNext(weapon); - } - else if (equipable is Armor armor) - { - Unequip(_equippedArmor.Value); - armor.IsEquipped = true; - _equippedArmor.OnNext(armor); - } - else if (equipable is Accessory accessory) - { - Unequip(_equippedAccessory.Value); - accessory.IsEquipped = true; - _equippedAccessory.OnNext(accessory); - } - else - throw new NotImplementedException("Item type is not supported."); + if (equipable is Weapon weapon) + { + Unequip(_equippedWeapon.Value); + weapon.IsEquipped = true; + _equippedWeapon.OnNext(weapon); + } + else if (equipable is Armor armor) + { + Unequip(_equippedArmor.Value); + armor.IsEquipped = true; + _equippedArmor.OnNext(armor); + } + else if (equipable is Accessory accessory) + { + Unequip(_equippedAccessory.Value); + accessory.IsEquipped = true; + _equippedAccessory.OnNext(accessory); + } + else + throw new NotImplementedException("Item type is not supported."); } public void Unequip(EquipableItem equipable) { - if (equipable is Weapon weapon) - { - weapon.IsEquipped = false; - ModifyBonusAttack(-weapon.Damage); - _equippedWeapon.OnNext(new Weapon()); - } - else if (equipable is Armor armor) - { - armor.IsEquipped = false; - ModifyBonusDefense(-armor.Defense); - _equippedArmor.OnNext(new Armor()); - } - else if (equipable is Accessory accessory) - { - accessory.IsEquipped = false; - ModifyMaximumHP(-accessory.MaxHPUp); - ModifyMaximumVT(-accessory.MaxVTUp); - ModifyBonusAttack(-accessory.ATKUp); - ModifyBonusDefense(-accessory.DEFUp); - ModifyBonusLuck(-accessory.LuckUp); - _equippedAccessory.OnNext(new Accessory()); - } - else - throw new NotImplementedException("Item type is not supported."); + if (equipable is Weapon weapon) + { + weapon.IsEquipped = false; + ModifyBonusAttack(-weapon.Damage); + _equippedWeapon.OnNext(new Weapon()); + } + else if (equipable is Armor armor) + { + armor.IsEquipped = false; + ModifyBonusDefense(-armor.Defense); + _equippedArmor.OnNext(new Armor()); + } + else if (equipable is Accessory accessory) + { + accessory.IsEquipped = false; + ModifyMaximumHP(-accessory.MaxHPUp); + ModifyMaximumVT(-accessory.MaxVTUp); + ModifyBonusAttack(-accessory.ATKUp); + ModifyBonusDefense(-accessory.DEFUp); + ModifyBonusLuck(-accessory.LuckUp); + _equippedAccessory.OnNext(new Accessory()); + } + else + throw new NotImplementedException("Item type is not supported."); - if (equipable.ItemTag == ItemTag.BreaksOnChange) - Inventory.Remove(equipable); + if (equipable.ItemTag == ItemTag.BreaksOnChange) + Inventory.Remove(equipable); } private static Vector3 GlobalInputVector { - get - { - var rawInput = Input.GetVector(GameInputs.MoveLeft, GameInputs.MoveRight, GameInputs.MoveUp, GameInputs.MoveDown); - var input = new Vector3 - { - X = rawInput.X, - Z = rawInput.Y - }; - return input with { Y = 0f }; - } + get + { + var rawInput = Input.GetVector(GameInputs.MoveLeft, GameInputs.MoveRight, GameInputs.MoveUp, GameInputs.MoveDown); + var input = new Vector3 + { + X = rawInput.X, + Z = rawInput.Y + }; + return input with { Y = 0f }; + } } private static float LeftStrafeInputVector { - get - { - return Input.GetActionStrength(GameInputs.StrafeLeft); - } + get + { + return Input.GetActionStrength(GameInputs.StrafeLeft); + } } private static float RightStrafeInputVector { - get - { - return Input.GetActionStrength(GameInputs.StrafeRight); - } + get + { + return Input.GetActionStrength(GameInputs.StrafeRight); + } } private void ThrowItem() { - var itemScene = GD.Load("res://src/items/throwable/ThrowableItem.tscn"); - var throwItem = itemScene.Instantiate(); - GetTree().Root.AddChildEx(throwItem); - throwItem.GlobalPosition = CurrentPosition + new Vector3(0, 3.5f, 0); - throwItem.GlobalRotation = GlobalRotation; + var itemScene = GD.Load("res://src/items/throwable/ThrowableItem.tscn"); + var throwItem = itemScene.Instantiate(); + GetTree().Root.AddChildEx(throwItem); + throwItem.GlobalPosition = CurrentPosition + new Vector3(0, 3.5f, 0); + throwItem.GlobalRotation = GlobalRotation; } private void OnAnimationFinished(StringName animation) { - PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished()); + PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished()); } private void OnExitTree() { - PlayerLogic.Stop(); - PlayerBinding.Dispose(); - AnimationPlayer.AnimationFinished -= OnAnimationFinished; + PlayerLogic.Stop(); + PlayerBinding.Dispose(); + AnimationPlayer.AnimationFinished -= OnAnimationFinished; } private void OnPlayerPositionUpdated(Vector3 globalPosition) => GlobalPosition = globalPosition; private void OnHealthTimerTimeout() { - if (Stats.CurrentHP.Value <= 0) - return; + if (Stats.CurrentHP.Value <= 0) + return; - if (Stats.CurrentVT.Value > 0) - { - if (((Accessory)EquippedAccessory.Value).AccessoryTag == AccessoryTag.HalfVTConsumption) - { - reduceOnTick = !reduceOnTick; - } - Stats.SetCurrentHP(Stats.CurrentHP.Value + 1); - if (reduceOnTick) - Stats.SetCurrentVT(Stats.CurrentVT.Value - 1); - } - else - Stats.SetCurrentHP(Stats.CurrentHP.Value - 1); + if (Stats.CurrentVT.Value > 0) + { + if (((Accessory)EquippedAccessory.Value).AccessoryTag == AccessoryTag.HalfVTConsumption) + { + reduceOnTick = !reduceOnTick; + } + Stats.SetCurrentHP(Stats.CurrentHP.Value + 1); + if (reduceOnTick) + Stats.SetCurrentVT(Stats.CurrentVT.Value - 1); + } + else + Stats.SetCurrentHP(Stats.CurrentHP.Value - 1); } private void EquippedWeapon_Sync(EquipableItem obj) { - ModifyBonusAttack(((Weapon)obj).Damage); + ModifyBonusAttack(((Weapon)obj).Damage); } private void EquippedArmor_Sync(EquipableItem obj) { - ModifyBonusDefense(((Armor)obj).Defense); + ModifyBonusDefense(((Armor)obj).Defense); } private void EquippedAccessory_Sync(EquipableItem accessory) { - ModifyMaximumHP(((Accessory)accessory).MaxHPUp); - ModifyMaximumVT(((Accessory)accessory).MaxVTUp); - ModifyBonusAttack(((Accessory)accessory).ATKUp); - ModifyBonusDefense(((Accessory)accessory).DEFUp); - ModifyBonusLuck(((Accessory)accessory).LuckUp); + ModifyMaximumHP(((Accessory)accessory).MaxHPUp); + ModifyMaximumVT(((Accessory)accessory).MaxVTUp); + ModifyBonusAttack(((Accessory)accessory).ATKUp); + ModifyBonusDefense(((Accessory)accessory).DEFUp); + ModifyBonusLuck(((Accessory)accessory).LuckUp); } private void CurrentHP_Sync(int newHealth) { - if (newHealth <= 0) - Die(); + if (newHealth <= 0) + Die(); } private void CurrentEXP_Sync(double newExp) { - if (Stats.CurrentExp.Value >= Stats.ExpToNextLevel.Value) - LevelUp(); + if (Stats.CurrentExp.Value >= Stats.ExpToNextLevel.Value) + LevelUp(); } private double CalculateDefenseResistance(double incomingDamage) { - return Mathf.Max(incomingDamage - Stats.CurrentDefense.Value - Stats.BonusDefense.Value, 0.0); + return Mathf.Max(incomingDamage - Stats.CurrentDefense.Value - Stats.BonusDefense.Value, 0.0); } private void Hitbox_AreaEntered(Area3D area) { - var target = area.GetOwner(); - if (target is IEnemy enemy) - HitEnemy(enemy); + var target = area.GetOwner(); + if (target is IEnemy enemy) + HitEnemy(enemy); } private void HitEnemy(IEnemy enemy) { - var attackValue = Stats.CurrentAttack.Value + Stats.BonusAttack.Value; - var ignoreElementalResistance = ((Weapon)EquippedWeapon.Value).WeaponTag == WeaponTag.IgnoreAffinity; - var isCriticalHit = BattleExtensions.IsCriticalHit(Stats.Luck.Value); - var element = ((Weapon)EquippedWeapon.Value).WeaponElement; + var attackValue = Stats.CurrentAttack.Value + Stats.BonusAttack.Value; + var ignoreElementalResistance = ((Weapon)EquippedWeapon.Value).WeaponTag == WeaponTag.IgnoreAffinity; + var isCriticalHit = BattleExtensions.IsCriticalHit(Stats.Luck.Value); + var element = ((Weapon)EquippedWeapon.Value).WeaponElement; - enemy.TakeDamage( - attackValue * ((Weapon)EquippedWeapon.Value).ElementalDamageBonus, - element, - isCriticalHit, - false, - ignoreElementalResistance); + enemy.TakeDamage( + attackValue * ((Weapon)EquippedWeapon.Value).ElementalDamageBonus, + element, + isCriticalHit, + false, + ignoreElementalResistance); - if (((Weapon)EquippedWeapon.Value).WeaponTag == WeaponTag.Knockback) - enemy.Knockback(0.3f, -CurrentBasis.Z.Normalized()); + if (((Weapon)EquippedWeapon.Value).WeaponTag == WeaponTag.Knockback) + enemy.Knockback(0.3f, -CurrentBasis.Z.Normalized()); + + _gameRepo.OnPlayerAttackedEnemy(); } private void CollisionDetector_AreaEntered(Area3D area) { - if (area.GetParent() is InventoryItem inventoryItem) - { - var isAdded = Inventory.TryAdd(inventoryItem); - if (isAdded) - { - _gameRepo.AnnounceMessageOnMainScreen($"{inventoryItem.ItemName} picked up."); - inventoryItem.QueueFree(); - } - else - _gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}."); - } - if (area.GetParent() is DroppedItem droppedItem) - { - var isAdded = Inventory.TryAdd(droppedItem.Item); - if (isAdded) - { - _gameRepo.AnnounceMessageOnMainScreen($"{droppedItem.Item.ItemName} picked up."); - droppedItem.QueueFree(); - } - else - _gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {droppedItem.Item.ItemName}."); - } + if (area.GetParent() is InventoryItem inventoryItem) + { + var isAdded = Inventory.TryAdd(inventoryItem); + if (isAdded) + { + _gameRepo.AnnounceMessageOnMainScreen($"{inventoryItem.ItemName} picked up."); + inventoryItem.QueueFree(); + } + else + _gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}."); + } + if (area.GetParent() is DroppedItem droppedItem) + { + var isAdded = Inventory.TryAdd(droppedItem.Item); + if (isAdded) + { + _gameRepo.AnnounceMessageOnMainScreen($"{droppedItem.Item.ItemName} picked up."); + droppedItem.QueueFree(); + } + else + _gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {droppedItem.Item.ItemName}."); + } } private bool PlayerIsHittingGeometry() { - var collisions = WallCheck.GetCollidingBodies(); - return collisions.Count > 0; + var collisions = WallCheck.GetCollidingBodies(); + return collisions.Count > 0; } private void WallCheck_BodyEntered(Node body) { - PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished()); - GD.Print("Hit wall"); - AnimationPlayer.Stop(); + PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished()); + GD.Print("Hit wall"); + AnimationPlayer.Stop(); } }