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: 16 additions & 0 deletions Assets/Scripts/Command/CommandInvoker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class CommandInvoker {
private Stack<ICommand> commandHistory = new Stack<ICommand>();

public void ProcessCommand(ICommand command) {
ExecuteCommand(command);
RegisterCommand(command);
}

private void ExecuteCommand(ICommand command) {
command.Execute();
}

private void RegisterCommand(ICommand command) {
commandHistory.Push(command);
}
}
4 changes: 4 additions & 0 deletions Assets/Scripts/Command/ICommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface ICommand
{
void Execute();
}
13 changes: 13 additions & 0 deletions Assets/Scripts/Command/IUnitCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class IUnitCommand : ICommand
{
public int ActorUnitId { get; set; }
public int TargetUnitId { get; set; }
public int ActorPlayerId { get; set; }
public int TargetPlayerId { get; set; }

protected UnitController actor;
protected UnitController target;

public abstract void Execute();
public abstract bool WillHitTarget();
}