Exemple #1
0
        public static void Main(string[] args)
        {
            Unit unit1     = new Unit();
            Unit musketeer = new Musketeer();
            Unit magician  = new Magician();

            unit1.Attack();
            musketeer.Attack();
            magician.Attack();
        }
Exemple #2
0
    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();
    }