From 94d8d8a17fc536fcfb85372c52de39b5ea92b825 Mon Sep 17 00:00:00 2001 From: Parth Vaidya Date: Sat, 22 Mar 2025 16:07:40 +0530 Subject: [PATCH 01/10] ICommand and UnitCOmmand added --- Assets/Scripts/Commands.meta | 8 ++ .../Scripts/Commands/Abstract Commands.meta | 8 ++ .../Commands/Abstract Commands/ICommand.cs | 7 ++ .../Abstract Commands/ICommand.cs.meta | 11 ++ .../Abstract Commands/IUnitCommand.cs | 19 +++ .../Abstract Commands/IUnitCommand.cs.meta | 11 ++ Packages/manifest.json | 15 +-- Packages/packages-lock.json | 113 ++++++++++-------- ProjectSettings/ProjectVersion.txt | 4 +- ProjectSettings/boot.config | 0 10 files changed, 140 insertions(+), 56 deletions(-) create mode 100644 Assets/Scripts/Commands.meta create mode 100644 Assets/Scripts/Commands/Abstract Commands.meta create mode 100644 Assets/Scripts/Commands/Abstract Commands/ICommand.cs create mode 100644 Assets/Scripts/Commands/Abstract Commands/ICommand.cs.meta create mode 100644 Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs create mode 100644 Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs.meta delete mode 100644 ProjectSettings/boot.config diff --git a/Assets/Scripts/Commands.meta b/Assets/Scripts/Commands.meta new file mode 100644 index 00000000..da56c75e --- /dev/null +++ b/Assets/Scripts/Commands.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cce1ef398ad5252418bf0eddd457e7b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Abstract Commands.meta b/Assets/Scripts/Commands/Abstract Commands.meta new file mode 100644 index 00000000..2b8ba38f --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bee3ef792d25cbb45b170d11ea513c3c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Abstract Commands/ICommand.cs b/Assets/Scripts/Commands/Abstract Commands/ICommand.cs new file mode 100644 index 00000000..ed8255ca --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands/ICommand.cs @@ -0,0 +1,7 @@ +namespace Command.Commands +{ + public interface ICommand + { + public void Execute(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Abstract Commands/ICommand.cs.meta b/Assets/Scripts/Commands/Abstract Commands/ICommand.cs.meta new file mode 100644 index 00000000..05a1e5aa --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands/ICommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 511a7d2f3d54cab44923631c2bb8a0b1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs new file mode 100644 index 00000000..58bfa664 --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs @@ -0,0 +1,19 @@ +using Command.Player; + +namespace Command.Commands +{ + public abstract class UnitCommand : ICommand + { + public int ActorUnitID; + public int TargetUnitID; + public int ActorPlayerID; + public int TargetPlayerID; + + protected UnitController actorUnit; + protected UnitController targetUnit; + + public abstract void Execute(); + + public abstract bool WillHitTarget(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs.meta b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs.meta new file mode 100644 index 00000000..1e72800e --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7bcd3ec49dc4b374b9341334488055d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 861a650e..caf106aa 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,15 +1,16 @@ { "dependencies": { - "com.unity.collab-proxy": "2.0.1", - "com.unity.feature.2d": "1.0.0", - "com.unity.ide.rider": "3.0.18", - "com.unity.ide.visualstudio": "2.0.17", + "com.unity.ai.navigation": "1.1.5", + "com.unity.collab-proxy": "2.4.4", + "com.unity.feature.2d": "2.0.1", + "com.unity.ide.rider": "3.0.31", + "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", - "com.unity.test-framework": "1.1.31", + "com.unity.test-framework": "1.1.33", "com.unity.textmeshpro": "3.0.6", - "com.unity.timeline": "1.6.4", + "com.unity.timeline": "1.7.6", "com.unity.ugui": "1.0.0", - "com.unity.visualscripting": "1.8.0", + "com.unity.visualscripting": "1.9.4", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 6aaf454c..034b4d2c 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,34 +1,41 @@ { "dependencies": { "com.unity.2d.animation": { - "version": "7.0.9", + "version": "9.1.1", "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.common": "6.0.6", + "com.unity.2d.common": "8.0.2", "com.unity.2d.sprite": "1.0.0", + "com.unity.collections": "1.1.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.uielements": "1.0.0" }, "url": "https://packages.unity.com" }, - "com.unity.2d.common": { - "version": "6.0.6", - "depth": 2, + "com.unity.2d.aseprite": { + "version": "1.1.5", + "depth": 1, "source": "registry", "dependencies": { + "com.unity.2d.common": "6.0.6", "com.unity.2d.sprite": "1.0.0", - "com.unity.mathematics": "1.1.0", - "com.unity.modules.uielements": "1.0.0", - "com.unity.burst": "1.5.1" + "com.unity.mathematics": "1.2.6", + "com.unity.modules.animation": "1.0.0" }, "url": "https://packages.unity.com" }, - "com.unity.2d.path": { - "version": "5.0.2", + "com.unity.2d.common": { + "version": "8.0.3", "depth": 2, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.unity.burst": "1.7.3", + "com.unity.2d.sprite": "1.0.0", + "com.unity.mathematics": "1.1.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.uielements": "1.0.0" + }, "url": "https://packages.unity.com" }, "com.unity.2d.pixel-perfect": { @@ -39,13 +46,13 @@ "url": "https://packages.unity.com" }, "com.unity.2d.psdimporter": { - "version": "6.0.7", + "version": "8.0.5", "depth": 1, "source": "registry", "dependencies": { - "com.unity.2d.animation": "7.0.9", - "com.unity.2d.common": "6.0.6", - "com.unity.2d.sprite": "1.0.0" + "com.unity.2d.common": "8.0.2", + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.animation": "9.1.1" }, "url": "https://packages.unity.com" }, @@ -56,13 +63,12 @@ "dependencies": {} }, "com.unity.2d.spriteshape": { - "version": "7.0.6", + "version": "9.0.4", "depth": 1, "source": "registry", "dependencies": { + "com.unity.2d.common": "8.0.3", "com.unity.mathematics": "1.1.0", - "com.unity.2d.common": "6.0.4", - "com.unity.2d.path": "5.0.2", "com.unity.modules.physics2d": "1.0.0" }, "url": "https://packages.unity.com" @@ -71,36 +77,59 @@ "version": "1.0.0", "depth": 1, "source": "builtin", - "dependencies": {} + "dependencies": { + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.uielements": "1.0.0" + } }, "com.unity.2d.tilemap.extras": { - "version": "2.2.4", + "version": "3.1.2", "depth": 1, "source": "registry", "dependencies": { - "com.unity.modules.tilemap": "1.0.0", - "com.unity.2d.tilemap": "1.0.0", "com.unity.ugui": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" }, "url": "https://packages.unity.com" }, + "com.unity.ai.navigation": { + "version": "1.1.5", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.ai": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.burst": { - "version": "1.6.6", + "version": "1.8.17", "depth": 3, "source": "registry", "dependencies": { - "com.unity.mathematics": "1.2.1" + "com.unity.mathematics": "1.2.1", + "com.unity.modules.jsonserialize": "1.0.0" }, "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "2.0.1", + "version": "2.4.4", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.collections": { + "version": "1.2.4", + "depth": 2, + "source": "registry", + "dependencies": { + "com.unity.burst": "1.6.6", + "com.unity.test-framework": "1.1.31" + }, + "url": "https://packages.unity.com" + }, "com.unity.ext.nunit": { "version": "1.0.6", "depth": 1, @@ -109,21 +138,22 @@ "url": "https://packages.unity.com" }, "com.unity.feature.2d": { - "version": "1.0.0", + "version": "2.0.1", "depth": 0, "source": "builtin", "dependencies": { - "com.unity.2d.animation": "7.0.9", + "com.unity.2d.animation": "9.1.1", "com.unity.2d.pixel-perfect": "5.0.3", - "com.unity.2d.psdimporter": "6.0.7", + "com.unity.2d.psdimporter": "8.0.5", "com.unity.2d.sprite": "1.0.0", - "com.unity.2d.spriteshape": "7.0.6", + "com.unity.2d.spriteshape": "9.0.4", "com.unity.2d.tilemap": "1.0.0", - "com.unity.2d.tilemap.extras": "2.2.4" + "com.unity.2d.tilemap.extras": "3.1.2", + "com.unity.2d.aseprite": "1.1.5" } }, "com.unity.ide.rider": { - "version": "3.0.18", + "version": "3.0.31", "depth": 0, "source": "registry", "dependencies": { @@ -132,7 +162,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.17", + "version": "2.0.22", "depth": 0, "source": "registry", "dependencies": { @@ -155,7 +185,7 @@ "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.31", + "version": "1.1.33", "depth": 0, "source": "registry", "dependencies": { @@ -175,13 +205,13 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.6.4", + "version": "1.7.6", "depth": 0, "source": "registry", "dependencies": { + "com.unity.modules.audio": "1.0.0", "com.unity.modules.director": "1.0.0", "com.unity.modules.animation": "1.0.0", - "com.unity.modules.audio": "1.0.0", "com.unity.modules.particlesystem": "1.0.0" }, "url": "https://packages.unity.com" @@ -196,7 +226,7 @@ } }, "com.unity.visualscripting": { - "version": "1.8.0", + "version": "1.9.4", "depth": 0, "source": "registry", "dependencies": { @@ -337,17 +367,6 @@ "version": "1.0.0", "depth": 0, "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.uielementsnative": "1.0.0" - } - }, - "com.unity.modules.uielementsnative": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", "dependencies": { "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0", diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index bca3d022..29c4eeec 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.21f1 -m_EditorVersionWithRevision: 2021.3.21f1 (1b156197d683) +m_EditorVersion: 2022.3.45f1 +m_EditorVersionWithRevision: 2022.3.45f1 (a13dfa44d684) diff --git a/ProjectSettings/boot.config b/ProjectSettings/boot.config deleted file mode 100644 index e69de29b..00000000 From b79b218bdee21df4cb3dfb7e3f1e02fba3574b34 Mon Sep 17 00:00:00 2001 From: Parth Vaidya Date: Sat, 22 Mar 2025 16:10:34 +0530 Subject: [PATCH 02/10] CommandInvoker added --- Assets/Scripts/Commands/CommandInvoker.cs | 19 +++++++++++++++++++ .../Scripts/Commands/CommandInvoker.cs.meta | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Assets/Scripts/Commands/CommandInvoker.cs create mode 100644 Assets/Scripts/Commands/CommandInvoker.cs.meta diff --git a/Assets/Scripts/Commands/CommandInvoker.cs b/Assets/Scripts/Commands/CommandInvoker.cs new file mode 100644 index 00000000..c93e2fdb --- /dev/null +++ b/Assets/Scripts/Commands/CommandInvoker.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Command.Commands +{ + public class CommandInvoker + { + private Stack commandRegistry = new Stack(); + + public void ProcessCommand(ICommand commandToProcess) + { + ExecuteCommand(commandToProcess); + RegisterCommand(commandToProcess); + } + + public void ExecuteCommand(ICommand commandToExecute) => commandToExecute.Execute(); + + public void RegisterCommand(ICommand commandToRegister) => commandRegistry.Push(commandToRegister); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/CommandInvoker.cs.meta b/Assets/Scripts/Commands/CommandInvoker.cs.meta new file mode 100644 index 00000000..7d4ca6ca --- /dev/null +++ b/Assets/Scripts/Commands/CommandInvoker.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91f9529200f0f2547afad4ee613055d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 7acdc49e1f3e1164c36617ad01219ea91c00cab5 Mon Sep 17 00:00:00 2001 From: Parth Vaidya Date: Sun, 23 Mar 2025 18:44:09 +0530 Subject: [PATCH 03/10] Create Concrete Commands --- Assets/Scripts/Action/ActionService.cs | 22 +++++++++---------- Assets/Scripts/Action/Actions/AttackAction.cs | 14 ++++++------ .../Action/Actions/AttackStanceAction.cs | 6 +++-- .../Action/Actions/BerserkAttackAction.cs | 6 +++-- .../Scripts/Action/Actions/CleanseAction.cs | 6 +++-- Assets/Scripts/Action/Actions/HealAction.cs | 6 +++-- .../Scripts/Action/Actions/MeditateAction.cs | 6 +++-- .../Scripts/Action/Actions/ThirdEyeAction.cs | 6 +++-- Assets/Scripts/Action/IAction.cs | 4 +--- .../Commands/Abstract Commands/CommandData.cs | 15 +++++++++++++ .../Abstract Commands/CommandData.cs.meta} | 2 +- .../Abstract Commands/IUnitCommand.cs | 9 ++++---- .../ActionType.cs => Commands/CommandType.cs} | 7 +++--- Assets/Scripts/Commands/CommandType.cs.meta | 11 ++++++++++ Assets/Scripts/Commands/Concrete Command.meta | 8 +++++++ .../Concrete Command/AttackCommand.cs | 19 ++++++++++++++++ .../Concrete Command/AttackCommand.cs.meta | 11 ++++++++++ .../Commands/Concrete Command/AttackStance.cs | 19 ++++++++++++++++ .../Concrete Command/AttackStance.cs.meta | 11 ++++++++++ .../Concrete Command/BerserkAttackCommand.cs | 20 +++++++++++++++++ .../BerserkAttackCommand.cs.meta | 11 ++++++++++ .../Concrete Command/ClenseCommand.cs | 21 ++++++++++++++++++ .../Concrete Command/ClenseCommand.cs.meta | 11 ++++++++++ .../Commands/Concrete Command/HealCommand.cs | 19 ++++++++++++++++ .../Concrete Command/HealCommand.cs.meta | 11 ++++++++++ .../Concrete Command/MeditateCommand.cs | 19 ++++++++++++++++ .../Concrete Command/MeditateCommand.cs.meta | 11 ++++++++++ .../Concrete Command/ThirdEyeCommand.cs | 19 ++++++++++++++++ .../Concrete Command/ThirdEyeCommand.cs.meta | 11 ++++++++++ Assets/Scripts/Events/EventService.cs | 4 ++-- Assets/Scripts/Input/InputService.cs | 6 ++--- Assets/Scripts/Player/PlayerService.cs | 3 ++- Assets/Scripts/Player/Unit/UnitController.cs | 10 ++++----- .../Player/Unit/UnitScriptableObject.cs | 2 +- .../UI/ActionSelectionUI/ActionButtonView.cs | 4 ++-- .../ActionSelectionUIController.cs | 8 +++---- Assets/Scripts/UI/UIService.cs | 2 +- 37 files changed, 319 insertions(+), 61 deletions(-) create mode 100644 Assets/Scripts/Commands/Abstract Commands/CommandData.cs rename Assets/Scripts/{Action/ActionType.cs.meta => Commands/Abstract Commands/CommandData.cs.meta} (83%) rename Assets/Scripts/{Action/ActionType.cs => Commands/CommandType.cs} (73%) create mode 100644 Assets/Scripts/Commands/CommandType.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/AttackCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/AttackCommand.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/AttackStance.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/AttackStance.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/HealCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/HealCommand.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs.meta create mode 100644 Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs create mode 100644 Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs.meta diff --git a/Assets/Scripts/Action/ActionService.cs b/Assets/Scripts/Action/ActionService.cs index 957c65c0..3e5c2f04 100644 --- a/Assets/Scripts/Action/ActionService.cs +++ b/Assets/Scripts/Action/ActionService.cs @@ -5,23 +5,23 @@ namespace Command.Actions { public class ActionService { - private Dictionary actions; + private Dictionary actions; public ActionService() => CreateActions(); private void CreateActions() { - actions = new Dictionary(); - actions.Add(ActionType.Attack, new AttackAction()); - actions.Add(ActionType.Heal, new HealAction()); - actions.Add(ActionType.AttackStance, new AttackStanceAction()); - actions.Add(ActionType.Cleanse, new CleanseAction()); - actions.Add(ActionType.Meditate, new MeditateAction()); - actions.Add(ActionType.BerserkAttack, new BerserkAttackAction()); - actions.Add(ActionType.ThirdEye, new ThirdEyeAction()); + actions = new Dictionary(); + actions.Add(CommandType.Attack, new AttackAction()); + actions.Add(CommandType.Heal, new HealAction()); + actions.Add(CommandType.AttackStance, new AttackStanceAction()); + actions.Add(CommandType.Cleanse, new CleanseAction()); + actions.Add(CommandType.Meditate, new MeditateAction()); + actions.Add(CommandType.BerserkAttack, new BerserkAttackAction()); + actions.Add(CommandType.ThirdEye, new ThirdEyeAction()); } - public IAction GetActionByType(ActionType type) + public IAction GetActionByType(CommandType type) { if (actions.ContainsKey(type)) return actions[type]; @@ -29,6 +29,6 @@ public IAction GetActionByType(ActionType type) throw new System.Exception($"No Action found for the type {type} in the dictionary"); } - public TargetType GetTargetTypeForAction(ActionType actionType) => actions[actionType].TargetType; + public TargetType GetTargetTypeForAction(CommandType actionType) => actions[actionType].TargetType; } } \ No newline at end of file diff --git a/Assets/Scripts/Action/Actions/AttackAction.cs b/Assets/Scripts/Action/Actions/AttackAction.cs index 75632f04..fe119884 100644 --- a/Assets/Scripts/Action/Actions/AttackAction.cs +++ b/Assets/Scripts/Action/Actions/AttackAction.cs @@ -9,33 +9,33 @@ public class AttackAction : IAction { private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Enemy; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit, bool isSuccessful) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessful; - actorUnit.PlayBattleAnimation(ActionType.Attack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.Attack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } - public void OnActionAnimationCompleted() + public void OnActionAnimationCompleted() { PlayAttackSound(); - if (IsSuccessful()) + if (isSuccessful) targetUnit.TakeDamage(actorUnit.CurrentPower); else GameService.Instance.UIService.ActionMissed(); } - public bool IsSuccessful() => true; - public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition(); private void PlayAttackSound() { - switch(actorUnit.UnitType) + switch (actorUnit.UnitType) { case UnitType.WIZARD: GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.MAGIC_BALL); diff --git a/Assets/Scripts/Action/Actions/AttackStanceAction.cs b/Assets/Scripts/Action/Actions/AttackStanceAction.cs index 9fc46d34..76d5fb4e 100644 --- a/Assets/Scripts/Action/Actions/AttackStanceAction.cs +++ b/Assets/Scripts/Action/Actions/AttackStanceAction.cs @@ -9,14 +9,16 @@ public class AttackStanceAction : IAction { private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; TargetType IAction.TargetType { get => TargetType.Self; } - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit , bool isSuccessful) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessful; - actorUnit.PlayBattleAnimation(ActionType.AttackStance, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.AttackStance, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/Actions/BerserkAttackAction.cs b/Assets/Scripts/Action/Actions/BerserkAttackAction.cs index 42ce5acd..2e672204 100644 --- a/Assets/Scripts/Action/Actions/BerserkAttackAction.cs +++ b/Assets/Scripts/Action/Actions/BerserkAttackAction.cs @@ -10,14 +10,16 @@ public class BerserkAttackAction : IAction private const float hitChance = 0.66f; private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Enemy; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit , bool isSuccessful) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessful; - actorUnit.PlayBattleAnimation(ActionType.BerserkAttack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.BerserkAttack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/Actions/CleanseAction.cs b/Assets/Scripts/Action/Actions/CleanseAction.cs index 469071ea..05ff68fd 100644 --- a/Assets/Scripts/Action/Actions/CleanseAction.cs +++ b/Assets/Scripts/Action/Actions/CleanseAction.cs @@ -10,14 +10,16 @@ public class CleanseAction : IAction private const float hitChance = 0.2f; private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Enemy; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit , bool isSuccessfull) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessfull; - actorUnit.PlayBattleAnimation(ActionType.Cleanse, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.Cleanse, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/Actions/HealAction.cs b/Assets/Scripts/Action/Actions/HealAction.cs index d05b6d47..9d934140 100644 --- a/Assets/Scripts/Action/Actions/HealAction.cs +++ b/Assets/Scripts/Action/Actions/HealAction.cs @@ -9,14 +9,16 @@ public class HealAction : IAction { private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Friendly; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit, bool isSuccessfull) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessfull; - actorUnit.PlayBattleAnimation(ActionType.Heal, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.Heal, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/Actions/MeditateAction.cs b/Assets/Scripts/Action/Actions/MeditateAction.cs index 869e159b..737c213b 100644 --- a/Assets/Scripts/Action/Actions/MeditateAction.cs +++ b/Assets/Scripts/Action/Actions/MeditateAction.cs @@ -9,14 +9,16 @@ public class MeditateAction : IAction { private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Self; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit , bool isSuccessfull) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessfull; - actorUnit.PlayBattleAnimation(ActionType.Meditate, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.Meditate, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/Actions/ThirdEyeAction.cs b/Assets/Scripts/Action/Actions/ThirdEyeAction.cs index 8a24ba01..1ba92fdc 100644 --- a/Assets/Scripts/Action/Actions/ThirdEyeAction.cs +++ b/Assets/Scripts/Action/Actions/ThirdEyeAction.cs @@ -9,14 +9,16 @@ public class ThirdEyeAction : IAction { private UnitController actorUnit; private UnitController targetUnit; + private bool isSuccessful; public TargetType TargetType => TargetType.Self; - public void PerformAction(UnitController actorUnit, UnitController targetUnit) + public void PerformAction(UnitController actorUnit, UnitController targetUnit , bool isSuccessfull) { this.actorUnit = actorUnit; this.targetUnit = targetUnit; + this.isSuccessful = isSuccessfull; - actorUnit.PlayBattleAnimation(ActionType.BerserkAttack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); + actorUnit.PlayBattleAnimation(CommandType.BerserkAttack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted); } public void OnActionAnimationCompleted() diff --git a/Assets/Scripts/Action/IAction.cs b/Assets/Scripts/Action/IAction.cs index 610560d8..a73327e7 100644 --- a/Assets/Scripts/Action/IAction.cs +++ b/Assets/Scripts/Action/IAction.cs @@ -11,9 +11,7 @@ public interface IAction { public TargetType TargetType { get; } - public void PerformAction(UnitController actorUnit, UnitController targetUnit); - - public bool IsSuccessful(); + public void PerformAction(UnitController actorUnit, UnitController targetUnit, bool isSuccessful); public Vector3 CalculateMovePosition(UnitController targetUnit); } diff --git a/Assets/Scripts/Commands/Abstract Commands/CommandData.cs b/Assets/Scripts/Commands/Abstract Commands/CommandData.cs new file mode 100644 index 00000000..b2d4bf57 --- /dev/null +++ b/Assets/Scripts/Commands/Abstract Commands/CommandData.cs @@ -0,0 +1,15 @@ +public struct CommandData +{ + public int ActorUnitID; + public int TargetUnitID; + public int ActorPlayerID; + public int TargetPlayerID; + + public CommandData(int ActorUnitID, int TargetUnitID, int ActorPlayerID, int TargetPlayerID) + { + this.ActorUnitID = ActorUnitID; + this.TargetUnitID = TargetUnitID; + this.ActorPlayerID = ActorPlayerID; + this.TargetPlayerID = TargetPlayerID; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Action/ActionType.cs.meta b/Assets/Scripts/Commands/Abstract Commands/CommandData.cs.meta similarity index 83% rename from Assets/Scripts/Action/ActionType.cs.meta rename to Assets/Scripts/Commands/Abstract Commands/CommandData.cs.meta index 0c25c443..42e80613 100644 --- a/Assets/Scripts/Action/ActionType.cs.meta +++ b/Assets/Scripts/Commands/Abstract Commands/CommandData.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 24ec1f4456a85984898bc624ebcb3f7c +guid: 7a7192f7c17a8c1438498bb68a90a31f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs index 58bfa664..0b30e5e0 100644 --- a/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs +++ b/Assets/Scripts/Commands/Abstract Commands/IUnitCommand.cs @@ -4,10 +4,7 @@ namespace Command.Commands { public abstract class UnitCommand : ICommand { - public int ActorUnitID; - public int TargetUnitID; - public int ActorPlayerID; - public int TargetPlayerID; + public CommandData commandData; protected UnitController actorUnit; protected UnitController targetUnit; @@ -15,5 +12,9 @@ public abstract class UnitCommand : ICommand public abstract void Execute(); public abstract bool WillHitTarget(); + + public void SetActorUnit(UnitController actorUnit) => this.actorUnit = actorUnit; + + public void SetTargetUnit(UnitController targetUnit) => this.targetUnit = targetUnit; } } \ No newline at end of file diff --git a/Assets/Scripts/Action/ActionType.cs b/Assets/Scripts/Commands/CommandType.cs similarity index 73% rename from Assets/Scripts/Action/ActionType.cs rename to Assets/Scripts/Commands/CommandType.cs index f6c14302..f6dd2316 100644 --- a/Assets/Scripts/Action/ActionType.cs +++ b/Assets/Scripts/Commands/CommandType.cs @@ -1,6 +1,6 @@ -namespace Command.Actions -{ - public enum ActionType + + + public enum CommandType { None, Attack, @@ -11,4 +11,3 @@ public enum ActionType BerserkAttack, ThirdEye } -} \ No newline at end of file diff --git a/Assets/Scripts/Commands/CommandType.cs.meta b/Assets/Scripts/Commands/CommandType.cs.meta new file mode 100644 index 00000000..cc0ce4a3 --- /dev/null +++ b/Assets/Scripts/Commands/CommandType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f60400cbc1a69044a275f240dd0a050 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command.meta b/Assets/Scripts/Commands/Concrete Command.meta new file mode 100644 index 00000000..ba0c928c --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dc8b07142943a8044987a666beefdd64 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs b/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs new file mode 100644 index 00000000..4127b4a2 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs @@ -0,0 +1,19 @@ +using Command.Main; + +namespace Command.Commands +{ + public class AttackCommand : UnitCommand + { + private bool willHitTarget; + + public AttackCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override bool WillHitTarget() => true; + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.Attack).PerformAction(actorUnit, targetUnit, willHitTarget); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs.meta new file mode 100644 index 00000000..fbfc2400 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/AttackCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 454de5a0bdbb21644ad3faf3b75e9179 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/AttackStance.cs b/Assets/Scripts/Commands/Concrete Command/AttackStance.cs new file mode 100644 index 00000000..a9225384 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/AttackStance.cs @@ -0,0 +1,19 @@ +using Command.Main; + +namespace Command.Commands +{ + public class AttackStanceCommand : UnitCommand + { + private bool willHitTarget; + + public AttackStanceCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.AttackStance).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/AttackStance.cs.meta b/Assets/Scripts/Commands/Concrete Command/AttackStance.cs.meta new file mode 100644 index 00000000..4aecfa8b --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/AttackStance.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b7e9825b6a84d844b0cf9b24b4f9e07 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs b/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs new file mode 100644 index 00000000..af4a9b92 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs @@ -0,0 +1,20 @@ +using Command.Main; +using UnityEngine; +namespace Command.Commands +{ + public class BerserkAttackCommand : UnitCommand + { + private bool willHitTarget; + private const float hitChance = 0.66f; + + public BerserkAttackCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.BerserkAttack).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => Random.Range(0f, 1f) < hitChance; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs.meta new file mode 100644 index 00000000..c0a9cf82 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/BerserkAttackCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8286922a883e6714e997837d21eccb32 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs b/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs new file mode 100644 index 00000000..4e73a9af --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs @@ -0,0 +1,21 @@ +using Command.Main; +using UnityEngine; + +namespace Command.Commands +{ + public class CleanseCommand : UnitCommand + { + private bool willHitTarget; + private const float hitChance = 0.2f; + + public CleanseCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.Cleanse).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => Random.Range(0f, 1f) < hitChance; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs.meta new file mode 100644 index 00000000..67bde09d --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/ClenseCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca8ab0c4c4d32d141b632413ae9dcd86 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/HealCommand.cs b/Assets/Scripts/Commands/Concrete Command/HealCommand.cs new file mode 100644 index 00000000..c39fee5f --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/HealCommand.cs @@ -0,0 +1,19 @@ +using Command.Main; + +namespace Command.Commands +{ + public class HealCommand : UnitCommand + { + private bool willHitTarget; + + public HealCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.Heal).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/HealCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/HealCommand.cs.meta new file mode 100644 index 00000000..7bf3cbb9 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/HealCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c98c70b0879d4824691e0a2fb89bef55 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs b/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs new file mode 100644 index 00000000..44275dd7 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs @@ -0,0 +1,19 @@ +using Command.Main; + +namespace Command.Commands +{ + public class MeditateCommand : UnitCommand + { + private bool willHitTarget; + + public MeditateCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.Meditate).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs.meta new file mode 100644 index 00000000..368d7eb8 --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/MeditateCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ffb6a8430d3ca064189d9fe2307674ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs b/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs new file mode 100644 index 00000000..86ef07be --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs @@ -0,0 +1,19 @@ +using Command.Main; + +namespace Command.Commands +{ + public class ThirdEyeCommand : UnitCommand + { + private bool willHitTarget; + + public ThirdEyeCommand(CommandData commandData) + { + this.commandData = commandData; + willHitTarget = WillHitTarget(); + } + + public override void Execute() => GameService.Instance.ActionService.GetActionByType(CommandType.ThirdEye).PerformAction(actorUnit, targetUnit, willHitTarget); + + public override bool WillHitTarget() => true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs.meta b/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs.meta new file mode 100644 index 00000000..5801096c --- /dev/null +++ b/Assets/Scripts/Commands/Concrete Command/ThirdEyeCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 27dc6f5f121b4064a97b693cf3d4e6dd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Events/EventService.cs b/Assets/Scripts/Events/EventService.cs index 59b664c2..5c31f24f 100644 --- a/Assets/Scripts/Events/EventService.cs +++ b/Assets/Scripts/Events/EventService.cs @@ -11,12 +11,12 @@ namespace Command.Events public class EventService { public GameEventController OnBattleSelected { get; private set; } - public GameEventController OnActionSelected { get; private set; } + public GameEventController OnActionSelected { get; private set; } public EventService() { OnBattleSelected = new GameEventController(); - OnActionSelected = new GameEventController(); + OnActionSelected = new GameEventController(); } } } \ No newline at end of file diff --git a/Assets/Scripts/Input/InputService.cs b/Assets/Scripts/Input/InputService.cs index de088222..c1a0c318 100644 --- a/Assets/Scripts/Input/InputService.cs +++ b/Assets/Scripts/Input/InputService.cs @@ -9,7 +9,7 @@ public class InputService private MouseInputHandler mouseInputHandler; private InputState currentState; - private ActionType selectedActionType; + private CommandType selectedActionType; private TargetType targetType; public InputService() @@ -29,7 +29,7 @@ public void UpdateInputService() mouseInputHandler.HandleTargetSelection(targetType); } - public void OnActionSelected(ActionType selectedActionType) + public void OnActionSelected(CommandType selectedActionType) { this.selectedActionType = selectedActionType; SetInputState(InputState.SELECTING_TARGET); @@ -43,7 +43,7 @@ private void ShowTargetSelectionUI(TargetType selectedTargetType) GameService.Instance.UIService.ShowTargetOverlay(playerID, selectedTargetType); } - private TargetType SetTargetType(ActionType selectedActionType) => targetType = GameService.Instance.ActionService.GetTargetTypeForAction(selectedActionType); + private TargetType SetTargetType(CommandType selectedActionType) => targetType = GameService.Instance.ActionService.GetTargetTypeForAction(selectedActionType); public void OnTargetSelected(UnitController targetUnit) { diff --git a/Assets/Scripts/Player/PlayerService.cs b/Assets/Scripts/Player/PlayerService.cs index ec1f8bb4..6a8ee69f 100644 --- a/Assets/Scripts/Player/PlayerService.cs +++ b/Assets/Scripts/Player/PlayerService.cs @@ -7,6 +7,7 @@ public class PlayerService { private PlayerController player1; private PlayerController player2; + bool isSuccessful; private int currentTurnNumber; private PlayerController activePlayer; @@ -65,7 +66,7 @@ private void SetActivePlayer() public void OnPlayerTurnCompleted() => StartNextTurn(); - public void PerformAction(ActionType actionSelected, UnitController targetUnit) => GameService.Instance.ActionService.GetActionByType(actionSelected).PerformAction(activePlayer.GetUnitByID(ActiveUnitID), targetUnit); + public void PerformAction(CommandType actionSelected, UnitController targetUnit) => GameService.Instance.ActionService.GetActionByType(actionSelected).PerformAction(activePlayer.GetUnitByID(ActiveUnitID), targetUnit , isSuccessful); public void PlayerDied(PlayerController deadPlayer) { diff --git a/Assets/Scripts/Player/Unit/UnitController.cs b/Assets/Scripts/Player/Unit/UnitController.cs index 863dc14f..edbbea46 100644 --- a/Assets/Scripts/Player/Unit/UnitController.cs +++ b/Assets/Scripts/Player/Unit/UnitController.cs @@ -91,19 +91,19 @@ private void UnitDied() unitView.PlayAnimation(UnitAnimations.DEATH); } - public void PlayBattleAnimation(ActionType actionType, Vector3 battlePosition, Action callback) + public void PlayBattleAnimation(CommandType actionType, Vector3 battlePosition, Action callback) { GameService.Instance.UIService.ResetBattleBackgroundOverlay(); MoveToBattlePosition(battlePosition, callback, true, actionType); } - private void MoveToBattlePosition(Vector3 battlePosition, Action callback = null, bool shouldPlayActionAnimation = true, ActionType actionTypeToExecute = ActionType.None) + private void MoveToBattlePosition(Vector3 battlePosition, Action callback = null, bool shouldPlayActionAnimation = true, CommandType actionTypeToExecute = CommandType.None) { float moveTime = Vector3.Distance(unitView.transform.position, battlePosition) / unitScriptableObject.MovementSpeed; unitView.StartCoroutine(MoveToPositionOverTime(battlePosition, moveTime, callback, shouldPlayActionAnimation, actionTypeToExecute)); } - private IEnumerator MoveToPositionOverTime(Vector3 targetPosition, float time, Action callback, bool shouldPlayActionAnimation, ActionType actionTypeToExecute) + private IEnumerator MoveToPositionOverTime(Vector3 targetPosition, float time, Action callback, bool shouldPlayActionAnimation, CommandType actionTypeToExecute) { float elapsedTime = 0; Vector3 startingPosition = unitView.transform.position; @@ -124,9 +124,9 @@ private IEnumerator MoveToPositionOverTime(Vector3 targetPosition, float time, A callback.Invoke(); } - private void PlayActionAnimation(ActionType actionType) + private void PlayActionAnimation(CommandType actionType) { - if (actionType == ActionType.None) + if (actionType == CommandType.None) return; if (actionType == unitScriptableObject.executableCommands[0]) diff --git a/Assets/Scripts/Player/Unit/UnitScriptableObject.cs b/Assets/Scripts/Player/Unit/UnitScriptableObject.cs index 3c0b6305..00badda8 100644 --- a/Assets/Scripts/Player/Unit/UnitScriptableObject.cs +++ b/Assets/Scripts/Player/Unit/UnitScriptableObject.cs @@ -12,7 +12,7 @@ public class UnitScriptableObject : ScriptableObject public UnitView UnitPrefab; public int MaxHealth; public int Power; - public List executableCommands; + public List executableCommands; public Vector3 EnemyBattlePositionOffset; public float MovementSpeed; } diff --git a/Assets/Scripts/UI/ActionSelectionUI/ActionButtonView.cs b/Assets/Scripts/UI/ActionSelectionUI/ActionButtonView.cs index f3016d06..ad4697a5 100644 --- a/Assets/Scripts/UI/ActionSelectionUI/ActionButtonView.cs +++ b/Assets/Scripts/UI/ActionSelectionUI/ActionButtonView.cs @@ -9,7 +9,7 @@ public class ActionButtonView : MonoBehaviour { [SerializeField] private TextMeshProUGUI buttonText; private ActionSelectionUIController owner; - private ActionType actionType; + private CommandType actionType; private void Start() => GetComponent