Example #1
0
        //constructor
        public Enemy(Vector2 pos, float size_scale, int movementStrategy, int bulletStrategy)
        {
            this.bulletStrat   = bulletStrategy;
            this.movementStrat = movementStrategy;
            entPosition        = pos;
            this.size_scale    = size_scale;
            gun       = new BulletFactory();
            ENEMY_SPD = rand.Next(3, 6);
            int rand_dir = rand.Next(0, 2);

            active = 1;

            /*
             * switch (rand_dir)
             * {
             *  case 0:
             *      ai_direction = 1;
             *      break;
             *  case 1:
             *      ai_direction = -1;
             *      break;
             * }
             */
            //Console.WriteLine("Pos x: {0}", pos.X);
            //Console.WriteLine("Pos y: {0}", pos.Y);
        }
Example #2
0
        public virtual Bullet CreateBullet(Property.BulletType t, float angle, BulletFactory factory)
        {
            Vector2 direction = new Vector2(0, 0);


            return(factory.CreateBullet(t, this.entPosition, direction, (float)3.15, bulletStrat));
        }
Example #3
0
 public GameManager()
 {
     enemySelection = new EnemyFactorySelector();
     bulletFactory  = new BulletFactory();
     interpreter    = new Interpreter();
     powerupFactory = new PowerUpFactory();
 }
Example #4
0
        public void FireSpecialAttack(BulletFactory factory)
        {
            Vector2 direction  = new Vector2(0, 1);
            Vector2 currentPos = this.entPosition;

            currentPos.X -= 140;
            currentPos.Y += 64;

            // this function calls the CreateBullet pattern 8 times passing the modified spawn position each time then calls Create special bullet

            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));
            currentPos.X += 40;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Yellow, currentPos, direction, 0, this.bulletStrat));

            currentPos.X -= 170;
            currentPos.Y -= 96;
            Property.enemyBullets.Add(factory.CreateBullet(Property.BulletType.Special, currentPos, direction, 0, this.bulletStrat));
        }
Example #5
0
 //basic constructor, in which we only assign initial position
 //this can obviously be changed as needed
 public Player(Vector2 pos)
 {
     gun         = new BulletFactory();
     entPosition = pos;
     health      = 1;
     lives       = 20;
     FrameDelay  = 0;
     dead        = false;
 }
Example #6
0
        public Bullet CreateSpecialBullet(BulletFactory bFact)
        {
            // Pass in the proper factory and get the bullet back
            ExternalBulletDecorator NewSpecialBulletCreator = new ExternalBulletDecorator(bFact);

            // This constructor handles the creation of the special bullet and save it to the DecoratedBullet property

            return(NewSpecialBulletCreator.DecoratedBullet);
        }
Example #7
0
        //constructor
        public Enemy(Texture2D texture, Vector2 pos)
        {
            entTexture  = texture;
            entPosition = pos;
            gun         = new BulletFactory();
            ENEMY_SPD   = rand.Next(1, 7);
            int rand_dir = rand.Next(0, 2);

            switch (rand_dir)
            {
            case 0:
                ai_direction = 1;
                break;

            case 1:
                ai_direction = -1;
                break;
            }
        }
Example #8
0
 public override Bullet CreateBullet(Property.BulletType t, float angle, BulletFactory factory)  // Bosses must override CreatBullet() to implement the decorator
 {
     return(base.CreateBullet(t, angle, factory));
 }