Пример #1
0
 public Enemy(EnemyBuilder enemyBuilder)
 {
     this.Name       = enemyBuilder.EnemyName;
     this.LifePoints = enemyBuilder.EnemyLifePoints;
     this.Position   = enemyBuilder.EnemyPosition;
     this.EnemyType  = enemyBuilder.EnemyType;
 }
Пример #2
0
        static void Main(string[] args)
        {
            //Reference: https://sourcemaking.com/design_patterns/builder
            EnemyBuilder normalEnemyBuilder = new EnemyBuilder().Name("Bad Guy").LifePoints(100).Type(EEnemyType.Normal).Position(new Tuple <int, int>(10, 10));
            EnemyBuilder bigEnemyBuilder    = new EnemyBuilder().Name("Big Bad Guy").LifePoints(300).Type(EEnemyType.Big).Position(new Tuple <int, int>(10, 10));
            Enemy        normalEnemy        = normalEnemyBuilder.Build();

            Console.WriteLine($"{normalEnemy.Name} created");
            Enemy bigEnemy = bigEnemyBuilder.Build();

            Console.WriteLine($"{bigEnemy.Name} created");
            Console.Read();
        }