public static void Main(string[] args) { Unit unit1 = new Unit(); Unit musketeer = new Musketeer(); Unit magician = new Magician(); unit1.Attack(); musketeer.Attack(); magician.Attack(); }
void Start() { Debug.Log("===================== Strategy Pattern ====================="); Mob AllRounder = new Knight(new MoveLand(), new Attack()); AllRounder.Move(); AllRounder.Attack(); AllRounder = new Magician(new MoveSky(), new Attack()); AllRounder.Move(); AllRounder.Attack(); AllRounder = new Healer(new MoveLand(), new NoAttack()); AllRounder.Move(); AllRounder.Attack(); AllRounder = new Healer(new MoveLand(), new SpecialAttack()); AllRounder.Move(); AllRounder.Attack(); }