forked from XINCGer/Unity3DTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.cs
More file actions
70 lines (60 loc) · 1.35 KB
/
Copy pathCommand.cs
File metadata and controls
70 lines (60 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommandPattern
{
/// <summary>
/// 抽象的命令
/// </summary>
abstract class Command
{
protected Soliders soliders;
public Command(Soliders soliders)
{
this.soliders = soliders;
}
public abstract void ExcuteCommand();
}
//对应士兵的每种行为,设计不同的具体命令类
/// <summary>
/// 集合命令
/// </summary>
class CombinateCommand : Command
{
public CombinateCommand(Soliders soliders) : base(soliders)
{
}
public override void ExcuteCommand()
{
soliders.Combinate();
}
}
/// <summary>
/// 战斗命令
/// </summary>
class FightCommand : Command
{
public FightCommand(Soliders soliders) : base(soliders)
{
}
public override void ExcuteCommand()
{
soliders.Fight();
}
}
/// <summary>
/// 铁索连舟命令
/// </summary>
class CableBoatCommand:Command
{
public CableBoatCommand(Soliders soliders) : base(soliders)
{
}
public override void ExcuteCommand()
{
soliders.CableBoat();
}
}
}