24 files changed

+983
-3
lines changed
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern
6+
{
7+
//Base class for the commands
8+
//This class should always look like this to make it more general, so no constructors, parameters, etc!!!
9+
public abstract class Command
10+
{
11+
public abstract void Execute();
12+
13+
public abstract void Undo();
14+
}
15+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern.RebindKeys
6+
{
7+
//The point of this command is to do nothing
8+
//Is used instead of setting a command to null, so it's called Null Object, which is another programming pattern
9+
public class DoNothingCommand : Command
10+
{
11+
public override void Execute()
12+
{
13+
14+
}
15+
16+
public override void Undo()
17+
{
18+
19+
}
20+
}
21+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern.RebindKeys
6+
{
7+
public class MoveBackCommand : Command
8+
{
9+
private MoveObject moveObject;
10+
11+
12+
public MoveBackCommand(MoveObject moveObject)
13+
{
14+
this.moveObject = moveObject;
15+
}
16+
17+
18+
public override void Execute()
19+
{
20+
moveObject.MoveBack();
21+
}
22+
23+
24+
//Undo is just the opposite
25+
public override void Undo()
26+
{
27+
moveObject.MoveForward();
28+
}
29+
}
30+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern.RebindKeys
6+
{
7+
public class MoveForwardCommand : Command
8+
{
9+
private MoveObject moveObject;
10+
11+
12+
public MoveForwardCommand(MoveObject moveObject)
13+
{
14+
this.moveObject = moveObject;
15+
}
16+
17+
18+
public override void Execute()
19+
{
20+
moveObject.MoveForward();
21+
}
22+
23+
24+
//Undo is just the opposite
25+
public override void Undo()
26+
{
27+
moveObject.MoveBack();
28+
}
29+
}
30+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern.RebindKeys
6+
{
7+
public class TurnLeftCommand : Command
8+
{
9+
private MoveObject moveObject;
10+
11+
12+
public TurnLeftCommand(MoveObject moveObject)
13+
{
14+
this.moveObject = moveObject;
15+
}
16+
17+
18+
public override void Execute()
19+
{
20+
moveObject.TurnLeft();
21+
}
22+
23+
24+
//Undo is just the opposite
25+
public override void Undo()
26+
{
27+
moveObject.TurnRight();
28+
}
29+
}
30+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace CommandPattern.RebindKeys
6+
{
7+
public class TurnRightCommand : Command
8+
{
9+
private MoveObject moveObject;
10+
11+
12+
public TurnRightCommand(MoveObject moveObject)
13+
{
14+
this.moveObject = moveObject;
15+
}
16+
17+
18+
public override void Execute()
19+
{
20+
moveObject.TurnRight();
21+
}
22+
23+
24+
//Undo is just the opposite
25+
public override void Undo()
26+
{
27+
moveObject.TurnLeft();
28+
}
29+
}
30+
}
Some generated files are not rendered by default. Learn more about customizing how changed files appear on .

0 commit comments

Comments
 (0)