Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 9 additions & 7 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 @@ -1392,7 +1392,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 13, y: 27}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &940484822
Expand Down Expand Up @@ -1453,6 +1453,7 @@ MonoBehaviour:
EnemyOverlayColor: {r: 1, g: 0, b: 0, a: 0.23529412}
ActionSelectionOverlayColor: {r: 0, g: 0, b: 1, a: 0.23529412}
backgroundImage: {fileID: 1331666487}
undoButton: {fileID: 101671528}
--- !u!1 &988327833
GameObject:
m_ObjectHideFlags: 0
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 @@ -1868,8 +1869,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 480, y: -540}
m_SizeDelta: {x: 960, y: 1080}
m_AnchoredPosition: {x: 480, y: -539.8176}
m_SizeDelta: {x: 960, y: 1079.6353}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1242843364
MonoBehaviour:
Expand Down Expand Up @@ -2437,8 +2438,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1440, y: -540}
m_SizeDelta: {x: 960, y: 1080}
m_AnchoredPosition: {x: 1440, y: -539.8176}
m_SizeDelta: {x: 960, y: 1079.6353}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1682630444
GameObject:
Expand Down Expand Up @@ -2787,6 +2788,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
resultText: {fileID: 1682630446}
homeButton: {fileID: 799045267}
replayButton: {fileID: 988327835}
--- !u!1 &2089575972
GameObject:
m_ObjectHideFlags: 0
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Action/Actions/AttackAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ 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);
}
Expand All @@ -23,14 +25,12 @@ 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()
Expand Down
10 changes: 5 additions & 5 deletions Assets/Scripts/Action/Actions/AttackStanceAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public class AttackStanceAction : IAction
{
private UnitController actorUnit;
private UnitController targetUnit;
TargetType IAction.TargetType { get => TargetType.Self; }
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.AttackStance, CalculateMovePosition(targetUnit), OnActionAnimationCompleted);
}
Expand All @@ -23,14 +25,12 @@ public void OnActionAnimationCompleted()
{
GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.ATTACK_STANCE);

if (IsSuccessful())
if (isSuccessful)
targetUnit.CurrentPower += (int)(targetUnit.CurrentPower * 0.2f);
else
GameService.Instance.UIService.ActionMissed();
}

public bool IsSuccessful() => true;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
}
7 changes: 4 additions & 3 deletions Assets/Scripts/Action/Actions/BerserkAttackAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ 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);
}
Expand All @@ -24,7 +26,7 @@ public void OnActionAnimationCompleted()
{
GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.BERSERK_ATTACK);

if (IsSuccessful())
if (isSuccessful)
targetUnit.TakeDamage(actorUnit.CurrentPower * 2);
else
{
Expand All @@ -33,7 +35,6 @@ public void OnActionAnimationCompleted()
}
}

public bool IsSuccessful() => Random.Range(0f, 1f) < hitChance;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
Expand Down
10 changes: 5 additions & 5 deletions Assets/Scripts/Action/Actions/CleanseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ public class CleanseAction : IAction
private const float hitChance = 0.2f;
private UnitController actorUnit;
private UnitController targetUnit;
public TargetType TargetType => TargetType.Enemy;
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.Cleanse, CalculateMovePosition(targetUnit), OnActionAnimationCompleted);
}
Expand All @@ -24,14 +26,12 @@ public void OnActionAnimationCompleted()
{
GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.CLEANSE);

if (IsSuccessful())
if (isSuccessful)
targetUnit.ResetStats();
else
GameService.Instance.UIService.ActionMissed();
}

public bool IsSuccessful() => Random.Range(0f, 1f) < hitChance;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
}
8 changes: 4 additions & 4 deletions Assets/Scripts/Action/Actions/HealAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ 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 isSuccessful)
{
this.actorUnit = actorUnit;
this.targetUnit = targetUnit;
this.isSuccessful = isSuccessful;

actorUnit.PlayBattleAnimation(ActionType.Heal, CalculateMovePosition(targetUnit), OnActionAnimationCompleted);
}
Expand All @@ -23,12 +25,10 @@ public void OnActionAnimationCompleted()
{
GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.HEAL);

if (IsSuccessful())
if (isSuccessful)
targetUnit.RestoreHealth(actorUnit.CurrentPower);
}

public bool IsSuccessful() => true;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
}
7 changes: 4 additions & 3 deletions Assets/Scripts/Action/Actions/MeditateAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ 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 isSuccessful)
{
this.actorUnit = actorUnit;
this.targetUnit = targetUnit;
this.isSuccessful = isSuccessful;

actorUnit.PlayBattleAnimation(ActionType.Meditate, CalculateMovePosition(targetUnit), OnActionAnimationCompleted);
}
Expand All @@ -23,7 +25,7 @@ public void OnActionAnimationCompleted()
{
GameService.Instance.SoundService.PlaySoundEffects(Sound.SoundType.MEDITATE);

if (IsSuccessful())
if (isSuccessful)
{
var healthToIncrease = (int)(targetUnit.CurrentMaxHealth * 0.2f);
targetUnit.CurrentMaxHealth += healthToIncrease;
Expand All @@ -33,7 +35,6 @@ public void OnActionAnimationCompleted()
GameService.Instance.UIService.ActionMissed();
}

public bool IsSuccessful() => true;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/Action/Actions/ThirdEyeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ 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 isSuccessful)
{
this.actorUnit = actorUnit;
this.targetUnit = targetUnit;
this.isSuccessful = isSuccessful;

actorUnit.PlayBattleAnimation(ActionType.BerserkAttack, CalculateMovePosition(targetUnit), OnActionAnimationCompleted);
}

public void OnActionAnimationCompleted()
{
if (IsSuccessful())
if (isSuccessful)
{
int healthToConvert = (int)(targetUnit.CurrentHealth * 0.25f);
targetUnit.TakeDamage(healthToConvert);
Expand All @@ -31,8 +33,6 @@ public void OnActionAnimationCompleted()
GameService.Instance.UIService.ActionMissed();
}

public bool IsSuccessful() => true;

public Vector3 CalculateMovePosition(UnitController targetUnit) => targetUnit.GetEnemyPosition();
}
}
6 changes: 2 additions & 4 deletions Assets/Scripts/Action/IAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ 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);
}
}
}
9 changes: 8 additions & 1 deletion Assets/Scripts/Battle/BattleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ public BattleService(List<BattleScriptableObject> battleScriptableObjects)
SubscribeToEvents();
}

private void SubscribeToEvents() => GameService.Instance.EventService.OnBattleSelected.AddListener(LoadBattle);
private void SubscribeToEvents()
{
GameService.Instance.EventService.OnBattleSelected.AddListener(LoadBattle);
GameService.Instance.EventService.OnReplayButtonClicked.AddListener(ReplayBattle);

}

private void ReplayBattle() => LoadBattle(currentBattleId);

private void LoadBattle(int battleId)
{
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Command.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Assets/Scripts/Command/CommandData.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Command/CommandData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading