Exemplo n.º 1
0
        //float enemySpacing = 100;
        //float enemySpacing = MathHelper.Clamp(3000, 70, 1000);
        public Enemy(ContentManager content, GraphicsDeviceManager graphics,EnemyType type, Direction direction = Direction.Left )
        {
            this.type = type;
            Image = type.image;

            _maxHealth = 50;
            _currentHealth = _maxHealth;

            Position = Vector2.Zero;
            position.Y = 50;
            Movement = Vector2.Zero;

            if (direction == Direction.Right)
            {
                position.X += graphics.PreferredBackBufferWidth + 300 + type.spacing * (index + 1);
                movement = Vector2.UnitX * -type.speed;
                movement.Y = (float)(rand.NextDouble() * type.speed - .2f);
            }
            else if (direction == Direction.Left)
            {
                position.X = -300 - type.spacing * (index + 1);
                movement = Vector2.UnitX * type.speed;
                movement.Y = (float)(rand.NextDouble() * type.speed - .2f);
            }
            else
            {
                position.X = (type.spacing * (index + 1)) * graphics.PreferredBackBufferWidth / 2;
                movement = Vector2.UnitX / 2;
                movement.Y = (float)(type.speed * rand.NextDouble());
            }
            //position.X = graphics.PreferredBackBufferWidth / 2;
            index++;
        }
 public AnimatedSprite(int frameTotal, int startX, int startY, int width, int height, Game game, Texture2D texture, Vector2 position, SpriteBatch batch, EnemyType type)
     : base(game, texture, position, batch, type)
 {
     this.frameTotal = frameTotal;
     this.startX = startX;
     this.startY = startY;
     this.width = width;
     this.height = height;
 }
Exemplo n.º 3
0
 public EnemyGroup(ContentManager content, GraphicsDeviceManager graphics, EnemyType enemyType, long distance, int enemyCount = 3, Enemy.Direction entryDirection = Enemy.Direction.Left, bool isBoss = false, bool isMidBoss = false)
 {
     distanceToPop = distance;
     this.isBoss = isBoss;
     this.isMidBoss = isMidBoss;
     group = new List<Enemy>();
     for (int i = 0; i < enemyCount; i++)
     {
         Enemy enemy = new Enemy(content, graphics, enemyType, entryDirection);
         if (enemyType.type == EnemyType.Etype.Level2MidBoss || enemyType.type == EnemyType.Etype.Level2Boss || enemyType.type == EnemyType.Etype.Level3Boss || enemyType.type == EnemyType.Etype.Level4Boss)
         {
             enemy.isAnimatedSprite = true;
         }
         group.Add(enemy);
     }
     Enemy.index = 1;
 }
Exemplo n.º 4
0
        public LevelCreator(ContentManager Content)
        {
            this.Content = Content;

            simple = new EnemyType(Content, EnemyType.Etype.Simple);
            bombers = new EnemyType(Content, EnemyType.Etype.Bomber);
            gunners = new EnemyType(Content, EnemyType.Etype.Gunner);
            darting = new EnemyType(Content, EnemyType.Etype.Darting);
            hards = new EnemyType(Content, EnemyType.Etype.Hard);
            midBoss = new EnemyType(Content, EnemyType.Etype.Level1MidBoss);
            boss = new EnemyType(Content, EnemyType.Etype.Level1Boss);
            level2midboss = new EnemyType(Content, EnemyType.Etype.Level2MidBoss);
            level2boss = new EnemyType(Content, EnemyType.Etype.Level2Boss);
            level3midboss = new EnemyType(Content, EnemyType.Etype.Level3MidBoss);
            level3boss = new EnemyType(Content, EnemyType.Etype.Level3Boss);
            level4midboss = new EnemyType(Content, EnemyType.Etype.Level4MidBoss);
            level4boss = new EnemyType(Content, EnemyType.Etype.Level4Boss);
            level5midboss = new EnemyType(Content, EnemyType.Etype.Level5MidBoss);
            level5boss = new EnemyType(Content, EnemyType.Etype.Level5Boss);
        }
Exemplo n.º 5
0
        public Sprite(Game game, Texture2D texture, Vector2 position, SpriteBatch batch, EnemyType type, float scale = 1, float opacity = 1, float rotation = 0, float rotationPerUpdate = 0)
            : base(game)
        {
            Texture = texture;
            Position = position;
            SpriteBatch = batch;
            Scale = scale;
            Opacity = opacity;
            Rotation = rotation;
            RotationPerUpdate = rotationPerUpdate;
            Color = Color.White;
            enemyType = type;

            this.width = texture.Width;
            this.height = texture.Height;

            _maxHealth = type.life;

            _currentHealth = _maxHealth;
        }
Exemplo n.º 6
0
        public Vector2 Update(EnemyType enemyType, Vector2 position, Vector2 movement, GraphicsDeviceManager graphics, Sprite playerOneSprite, Sprite playerTwoSprite = null, Player one = null, Player two = null)
        {
            Vector2 AIMovement = Vector2.Zero;

            if (enemyType.type == Etype.Simple)
            {
                AIMovement = simpleAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Gunner)
            {
                AIMovement = gunnerAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Bomber)
            {
                AIMovement = bomberAIMovement(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Darting)
            {
                AIMovement = dartingAIMovement(graphics, position, movement);
            }
            else if (type == Etype.Blinking)
            {
                // update ai
                AIMovement = createBlinking(graphics, position, movement);
            }
            else if (enemyType.type == Etype.Hard)
            {
                AIMovement = hardAIMovement(graphics, position, movement, enemyType.speed, playerOneSprite, playerTwoSprite, one, two);
            }
            else if (type == Etype.Level1MidBoss)
            {
                // update ai
                AIMovement = createLevel1MidBoss(graphics, position, movement);
            }
            else if (type == Etype.Level1Boss)
            {
                AIMovement = createLevel1Boss(graphics, position, movement);
            }
            else if (type == Etype.Level2MidBoss)
            {
                AIMovement = createLevel2MidBoss(graphics, position, movement);
            }
            else if (type == Etype.Level3Boss)
            {
                AIMovement = createLevel3Boss(graphics, position, movement);
            }
            return AIMovement;
        }