Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
deb63d2
Created Abstract Commands and Command Invoker
mridul-outscal Jul 11, 2023
c99e2c4
Implemented Commands for encapsulating Attack & Heal Actions and used…
mridul-outscal Jul 11, 2023
b6f3aee
Merge branch 'dev/Command_Pattern_Setup' into dev/Comman_Pattern_Solu…
mridul-outscal Oct 19, 2023
059f074
Merge branch 'dev/Using_Commands_Setup' into merge_test
mridul-outscal Oct 23, 2023
3035e64
All things are fixed.
mridul-outscal Oct 23, 2023
7ca19db
updated hit chance for berserk attack
mridul-outscal Oct 23, 2023
4678637
implemented undo functionality
mridul-outscal Oct 23, 2023
800671d
updated abstract command -> now using command data struct
mridul-outscal Oct 25, 2023
96036f3
Merge branch 'Undo-Setup' into mergeTest
mridul-outscal Oct 26, 2023
549aa7a
fixed bugs
mridul-outscal Oct 26, 2023
a89f076
Updated function names
mridul-outscal Oct 26, 2023
a89097c
Merge branch 'Command-Pattern-Setup' into Command-Pattern-Solution
mridul-outscal Oct 30, 2023
b38b615
Merge branch 'Using-Commands-Setup' into Using-Commands-Solution
mridul-outscal Oct 30, 2023
7a16128
fixed all issues
mridul-outscal Oct 30, 2023
1119b86
Merge branch 'Undo-Setup' into Undo-Solution
mridul-outscal Oct 30, 2023
5e72548
fixed all issues
mridul-outscal Oct 30, 2023
5141fb2
Update gitignore
Roopesh16 Mar 29, 2024
f943024
.
Roopesh16 Mar 29, 2024
c90a520
Add replay state
Roopesh16 Mar 29, 2024
70e5307
Add replay service
Roopesh16 Mar 29, 2024
56f396e
Init replay service
Roopesh16 Mar 29, 2024
a8b2d90
Add event on replay btn click
Roopesh16 Mar 29, 2024
807e4d5
Add replay button ui
Roopesh16 Mar 29, 2024
cb6bfa8
on replay btn click call
Roopesh16 Mar 29, 2024
e5587cc
On replay btn click replay battle
Roopesh16 Mar 29, 2024
9e68569
Set replay command stack
Roopesh16 Mar 29, 2024
9dcf47a
Hid battle end ui
Roopesh16 Mar 29, 2024
e022427
Add 1 sec wait
Roopesh16 Mar 29, 2024
16990d6
enable replay btn
Roopesh16 Mar 29, 2024
3276d63
Add a second wait to play
Roopesh16 Mar 30, 2024
d101363
At battle end, set replay stack
Roopesh16 Mar 30, 2024
f083f2b
Set replay comand public
Roopesh16 Mar 30, 2024
e16e28c
Add a new battle
Roopesh16 Mar 31, 2024
edf0be9
Update battle 3 image
Roopesh16 Mar 31, 2024
e29aba6
Add 3rd action
Roopesh16 Mar 31, 2024
b9c1ae4
Add missing so
Roopesh16 Mar 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ crashlytics-build.properties
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
.idea/.idea.AGD_CommandPattern/.idea
*.meta
*.zip
2 changes: 1 addition & 1 deletion Assets/Resources/Battle/Battle 3.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ MonoBehaviour:
m_Name: Battle 3
m_EditorClassIdentifier:
BattleID: 3
BattleBackgroundImage: {fileID: 1144033053, guid: 53ddd195ebcffd74cba8e68bd465b5b3, type: 3}
BattleBackgroundImage: {fileID: 1039436393, guid: 53ddd195ebcffd74cba8e68bd465b5b3, type: 3}
Player1Data: {fileID: 11400000, guid: 54c708d0404a70248a7953a3b2b83d35, type: 2}
Player2Data: {fileID: 11400000, guid: 373f3a8c5b7afe145ba9ec6ed8c88612, type: 2}
18 changes: 18 additions & 0 deletions Assets/Resources/Battle/Battle 4.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 15700b09dee7b504c8b8f273851c4fcf, type: 3}
m_Name: Battle 4
m_EditorClassIdentifier:
BattleID: 4
BattleBackgroundImage: {fileID: -717732176, guid: 53ddd195ebcffd74cba8e68bd465b5b3, type: 3}
Player1Data: {fileID: 11400000, guid: 996fcce034046194db9c6bd9601b7408, type: 2}
Player2Data: {fileID: 11400000, guid: d0205d5e036b8bc4fa73d5c5df43022b, type: 2}
25 changes: 25 additions & 0 deletions Assets/Resources/Player/Battle 4/Player 4-1.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 053d310f426c4b8459cd32f46e3491d4, type: 3}
m_Name: Player 4-1
m_EditorClassIdentifier:
PlayerID: 1
UnitData:
- {fileID: 11400000, guid: 46887c785e3822641a4fd79c553bda84, type: 2}
- {fileID: 11400000, guid: 069734e5b96bc064e8178d914cdae626, type: 2}
- {fileID: 11400000, guid: f016d481b03f2a04d86423fcbc9490f6, type: 2}
- {fileID: 11400000, guid: 7ab14eabf1920bc4a84647022949a215, type: 2}
UnitPositions:
- {x: -6, y: 2, z: 0}
- {x: -3, y: 1.2, z: 0}
- {x: -3, y: -1.2, z: 0}
- {x: -6, y: -2, z: 0}
25 changes: 25 additions & 0 deletions Assets/Resources/Player/Battle 4/Player 4-2.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 053d310f426c4b8459cd32f46e3491d4, type: 3}
m_Name: Player 4-2
m_EditorClassIdentifier:
PlayerID: 2
UnitData:
- {fileID: 11400000, guid: 62c3582c913eb5248a8469ef1883da78, type: 2}
- {fileID: 11400000, guid: 30d0684e24d795a42867d64014aece86, type: 2}
- {fileID: 11400000, guid: 14e444cabb3ddd34fbdfcb9fce6e5331, type: 2}
- {fileID: 11400000, guid: d2d35ed629463e646a7614dd021a47a2, type: 2}
UnitPositions:
- {x: 4, y: 2, z: 0}
- {x: 6, y: 1.2, z: 0}
- {x: 6, y: -1.2, z: 0}
- {x: 4, y: -2, z: 0}
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 1-1.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 1-1
m_EditorClassIdentifier:
UnitID: 1
UnitType: 1
UnitPrefab: {fileID: 7170176875333329667, guid: 94eb109406780014b814de72f826ea1e, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000300000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 1-2.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 1-2
m_EditorClassIdentifier:
UnitID: 2
UnitType: 2
UnitPrefab: {fileID: 7170176875333329667, guid: 696c0c4f156c7a94ba075ee5549f46d9, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 020000000400000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 1-3.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 1-3
m_EditorClassIdentifier:
UnitID: 3
UnitType: 3
UnitPrefab: {fileID: 7170176875333329667, guid: 8346e216771ef4d4d91d50605efc7328, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000500000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 1-4.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 1-4
m_EditorClassIdentifier:
UnitID: 4
UnitType: 4
UnitPrefab: {fileID: 7170176875333329667, guid: 51727404ff102f747bbef208e93b2b3e, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000600000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 2-1.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 2-1
m_EditorClassIdentifier:
UnitID: 1
UnitType: 1
UnitPrefab: {fileID: 3287956947383386545, guid: cc31d5544f3c02f48b8687eff615d8b4, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000300000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 2-2.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 2-2
m_EditorClassIdentifier:
UnitID: 2
UnitType: 2
UnitPrefab: {fileID: 3287956947383386545, guid: 5063a7765cfdaa74e81c7cba7436cd7b, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 020000000400000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 2-3.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 2-3
m_EditorClassIdentifier:
UnitID: 3
UnitType: 3
UnitPrefab: {fileID: 3287956947383386545, guid: 81e11e62b52cbc74dbd90ed212f91beb, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000500000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
22 changes: 22 additions & 0 deletions Assets/Resources/Player/Battle 4/Units/Unit 2-4.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66518e3bb2dd340478171f97ec326357, type: 3}
m_Name: Unit 2-4
m_EditorClassIdentifier:
UnitID: 4
UnitType: 4
UnitPrefab: {fileID: 3287956947383386545, guid: 601934b181c76164cb9dc247b665588e, type: 3}
MaxHealth: 10
Power: 5
executableCommands: 010000000600000002000000
EnemyBattlePositionOffset: {x: 3, y: 0, z: 0}
MovementSpeed: 20
15 changes: 9 additions & 6 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &101671527
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1445,6 +1445,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 53b82781cf2fb9a4aa3b0d3e0a71f056, type: 3}
m_Name:
m_EditorClassIdentifier:
undoButton: {fileID: 101671528}
turnText: {fileID: 144807538}
missedText: {fileID: 1222372628}
Player1BackgroundOverlay: {fileID: 1242843364}
Expand All @@ -1471,7 +1472,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &988327834
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1885,7 +1886,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.23529412}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
Expand Down Expand Up @@ -1947,7 +1948,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1260659848
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2233,6 +2234,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: f9f1d2cf049ff604aab41d149ba596e9, type: 2}
- {fileID: 11400000, guid: 32addf10f4370374993da88ffd77ac5c, type: 2}
- {fileID: 11400000, guid: f6b3f84e1bf293a4d847b3c8ba69cb3f, type: 2}
- {fileID: 11400000, guid: 641b40954bf84b04aa75aad904451f0b, type: 2}
sfxSource: {fileID: 363944623}
bgMusicSource: {fileID: 927446004}
--- !u!4 &1409757741
Expand Down Expand Up @@ -2376,7 +2378,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.23529412}
m_RaycastTarget: 1
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
Expand Down Expand Up @@ -2613,7 +2615,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 71}
m_SizeDelta: {x: 400, y: 32}
m_SizeDelta: {x: 400, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1861826650
MonoBehaviour:
Expand Down Expand Up @@ -2787,6 +2789,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
resultText: {fileID: 1682630446}
homeButton: {fileID: 799045267}
replayButton: {fileID: 988327835}
--- !u!1 &2089575972
GameObject:
m_ObjectHideFlags: 0
Expand Down
23 changes: 12 additions & 11 deletions Assets/Scripts/Action/ActionService.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
using Command.Input;
using Command.Commands;
using System.Collections.Generic;

namespace Command.Actions
{
public class ActionService
{
private Dictionary<ActionType, IAction> actions;
private Dictionary<CommandType, IAction> actions;

public ActionService() => CreateActions();

private void CreateActions()
{
actions = new Dictionary<ActionType, IAction>();
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<CommandType, IAction>();
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];
else
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;
}
}
Loading