Пример #1
0
        public BagelEnemy(BagelType bagelType,
                          ISizeProvider sizeProvider = null,
                          IEntityAdder entityAdder   = null,
                          float x         = 0,
                          float y         = 0,
                          float velX      = 0,
                          float velY      = 0,
                          int health      = 1,
                          float direction = 0) :
            base(x, y, velX, velY, health, direction)
        {
            BagelType = bagelType;

            this.sizeProvider = sizeProvider;
            if (sizeProvider == null && bagelType == BagelType.Bouncing)
            {
                throw new ArgumentException("How I can bounce when there're no walls?");
            }

            this.entityAdder = entityAdder;
            if (entityAdder == null &&
                (bagelType == BagelType.Shooting ||
                 bagelType == BagelType.Clone ||
                 bagelType == BagelType.InvincibleClone))
            {
                throw new ArgumentException("I must add \"bullets\" somewhere!");
            }
            if (bagelType == BagelType.Clone ||
                bagelType == BagelType.InvincibleClone)
            {
                rand = new Random();
            }

            UpdateCollisionBox();
        }
Пример #2
0
 protected DbContextBase(
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder         = null,
     IEntityUpdater entityUpdater     = null,
     IEntityDeleter entityDeleter     = null,
     IEntityDetacher entityDetacher   = null)
     : base()
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #3
0
 protected DbContextBase(
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder = null,
     IEntityUpdater entityUpdater = null,
     IEntityDeleter entityDeleter = null,
     IEntityDetacher entityDetacher = null)
     : base()
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #4
0
 public DbContextBase(
     string nameOrConnectionString,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder         = null,
     IEntityUpdater entityUpdater     = null,
     IEntityDeleter entityDeleter     = null,
     IEntityDetacher entityDetacher   = null)
     : base(nameOrConnectionString)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #5
0
 public DbContextBase(
     string nameOrConnectionString,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder = null,
     IEntityUpdater entityUpdater = null,
     IEntityDeleter entityDeleter = null,
     IEntityDetacher entityDetacher = null)
     : base(nameOrConnectionString)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #6
0
 public DbContextBase(
     ObjectContext objectContext,
     bool dbContextOwnsObjectContext,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder         = null,
     IEntityUpdater entityUpdater     = null,
     IEntityDeleter entityDeleter     = null,
     IEntityDetacher entityDetacher   = null)
     : base(objectContext, dbContextOwnsObjectContext)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #7
0
 public DbContextBase(
     DbConnection existingConnection,
     bool contextOwnsConnection,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder         = null,
     IEntityUpdater entityUpdater     = null,
     IEntityDeleter entityDeleter     = null,
     IEntityDetacher entityDetacher   = null)
     : base(existingConnection, contextOwnsConnection)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #8
0
 public DbContextBase(
     ObjectContext objectContext,
     bool dbContextOwnsObjectContext,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder = null,
     IEntityUpdater entityUpdater = null,
     IEntityDeleter entityDeleter = null,
     IEntityDetacher entityDetacher = null)
     : base(objectContext, dbContextOwnsObjectContext)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #9
0
 public DbContextBase(
     DbConnection existingConnection,
     bool contextOwnsConnection,
     IExceptionMapper exceptionMapper = null,
     IEntityAdder entityAdder = null,
     IEntityUpdater entityUpdater = null,
     IEntityDeleter entityDeleter = null,
     IEntityDetacher entityDetacher = null)
     : base(existingConnection, contextOwnsConnection)
 {
     Init(exceptionMapper, entityAdder, entityUpdater, entityDeleter, entityDetacher);
 }
Пример #10
0
 private void Init(
     IExceptionMapper exceptionMapper,
     IEntityAdder entityAdder,
     IEntityUpdater entityUpdater,
     IEntityDeleter entityDeleter,
     IEntityDetacher entityDetacher)
 {
     SetExceptionMapper(exceptionMapper);
     SetEntityAdder(entityAdder);
     SetEntityUpdater(entityUpdater);
     SetEntityDeleter(entityDeleter);
     SetEntityDetacher(entityDetacher);
 }
Пример #11
0
 protected virtual void SetEntityAdder(IEntityAdder entityAdder)
 {
     _entityAdder = entityAdder ?? new EntityAdder();
 }
Пример #12
0
        public EnemyGenerator(IEntityAdder entityAdder, ISizeProvider sizeProvider)
        {
            this.entityAdder  = entityAdder;
            this.sizeProvider = sizeProvider;
            rand = new Random();
            enemyWaveGenerators = new List <Action>
            {
                () =>
                {
                    //4-way bounce attack
                    const int health = 3;
                    var       farX   = sizeProvider.Width - 40;
                    var       farY   = sizeProvider.Height - 40;
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Bouncing, this.sizeProvider, null, 40, 40, 5, 5, health));
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Bouncing, this.sizeProvider, null, 40, farY, 5, -5, health));

                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Bouncing, this.sizeProvider, null, farX, 40, -5, 5, health));
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Bouncing, this.sizeProvider, null, farX, farY, -5, -5, health));
                },
                () =>
                {
                    //clone attack
                    const int health = 10;
                    var       farX   = sizeProvider.Width - 40;
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Clone, this.sizeProvider, this.entityAdder,
                                       40, 40, 0, 0, health));
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Clone, this.sizeProvider, this.entityAdder,
                                       farX, 40, 0, 0, health));
                }, () =>
                {
                    //healing attack
                    const int health = 10;
                    var       farX   = sizeProvider.Width - 40;
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.Healing, this.sizeProvider, this.entityAdder,
                                       40, 40, 0, 0, health));
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.InvincibleClone, this.sizeProvider, this.entityAdder,
                                       farX, 40, 0, 0, health));
                },
                () =>
                {
                    //inv clone attack
                    const int health = 10;
                    var       farX   = sizeProvider.Width - 40;
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.InvincibleClone, this.sizeProvider, this.entityAdder,
                                       40, 40, 0, 0, health));
                    entityAdder.AddEntity(
                        new BagelEnemy(BagelType.InvincibleClone, this.sizeProvider, this.entityAdder,
                                       farX, 40, 0, 0, health));
                },
                () =>
                {
                    const int health = 1;
                    for (var i = 0; i > -500; i -= 64)
                    {
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Shooting, this.sizeProvider, this.entityAdder,
                                           i, i, 10, 3, health));
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Shooting, this.sizeProvider, this.entityAdder,
                                           sizeProvider.Width - i, i, -10, 3, health));
                    }
                },
                () =>
                {
                    const int health = 2;
                    for (var i = 0; i > -500; i -= 64)
                    {
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Basic, this.sizeProvider, this.entityAdder,
                                           i, i, 5, 5, health));
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Basic, this.sizeProvider, this.entityAdder,
                                           sizeProvider.Width - i, i, -5, 5, health));
                    }
                },
                () =>
                {
                    const int health = 2;
                    for (var i = 40; i < 700; i += 64)
                    {
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Basic, this.sizeProvider, this.entityAdder,
                                           i / 2, i - 1000, 0, 5, health));
                        entityAdder.AddEntity(
                            new BagelEnemy(BagelType.Basic, this.sizeProvider, this.entityAdder,
                                           sizeProvider.Width - i / 2, i - 1000, 0, 5, health));
                    }
                }
            };
        }
Пример #13
0
 private void Init(
     IExceptionMapper exceptionMapper,
     IEntityAdder entityAdder,
     IEntityUpdater entityUpdater,
     IEntityDeleter entityDeleter,
     IEntityDetacher entityDetacher)
 {
     SetExceptionMapper(exceptionMapper);
     SetEntityAdder(entityAdder);
     SetEntityUpdater(entityUpdater);
     SetEntityDeleter(entityDeleter);
     SetEntityDetacher(entityDetacher);
 }
Пример #14
0
 protected virtual void SetEntityAdder(IEntityAdder entityAdder)
 {
     _entityAdder = entityAdder ?? new EntityAdder();
 }