Example #1
0
 private void ShootBullet()
 {
     AudioPlayer.PlayAudio("shoot", 0f, (float)((2 * (pos.X + sprite.rectangle.Width / 2) / 256) - 1));
     shootDelay = 0;
     GameScene.AddEntity(new Bullet(this, BulletPath.StraightUp, new Vector2(pos.X + 4, pos.Y + 2), BULLET_SPEED));
     GameScene.AddEntity(new Bullet(this, BulletPath.StraightUp, new Vector2(pos.X + 10, pos.Y + 2), BULLET_SPEED));
 }
Example #2
0
        public override void Update()
        {
            float time = (float)GlobalTime.ElapsedGameMilliseconds / 1000;

            if (progress < appearTime)
            {
                position.Y = (float)(srcYPos + (dstYPos - srcYPos) * Easing.ApplyEasingFromOne(progress / appearTime, EasingMode.CubicOut));
                progress  += time;
            }

            if (moving)
            {
                if (goingLeft)
                {
                    position.X -= X_VELOCITY * time;
                }
                else
                {
                    position.X += X_VELOCITY * time;
                }
            }
            if (position.X < 0)
            {
                position.X = 0;
                goingLeft  = false;
            }
            if (position.X + sprite.rectangle.Width > 256)
            {
                position.X = 256 - sprite.rectangle.Width;
                goingLeft  = true;
            }

            if (shootTime > SHOOT_TIME)
            {
                shootTime -= SHOOT_TIME;
                GameScene.AddEntity(new Bullet(this, BulletPath.StraightDown, new Vector2(position.X + 7, position.Y + 14), BULLET_VELOCITY));
                shootTime += random.NextDouble() * SHOOT_TIME / 2;
            }
            shootTime += time;

            if (GameScene.Flip)
            {
                sprite.flip = sprite.flip == SpriteEffects.None ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            }

            bbox.X = (int)position.X;
            bbox.Y = (int)position.Y;

            base.Update();
        }
Example #3
0
        public static void SpawnNonSpecial(int yPos, int enemy)
        {
            switch (enemy)
            {
            case 0:
                GameScene.AddEntity(new ClassicEnemy(0.5, yPos));
                break;

            case 1:
                GameScene.AddEntity(new ShieldEnemy(0.5, yPos));
                break;

            case 2:
                GameScene.AddEntity(new ShootingEnemy(random.NextDouble(), 0.5, yPos));
                break;
            }
        }
Example #4
0
        public static void SpawnFormation(Point?pos = null, int?formationNum = null)
        {
            if (formationNum == null)
            {
                formationNum = random.Next(0, formations.Count);
            }

            Point location;

            if (pos == null)
            {
                location = new Point(random.Next(0, 32 - (formations[(int)formationNum][0].Length) * 2), random.Next(0, 5));
            }
            else
            {
                location = (Point)pos;
            }

            for (int j = 0; j < formations[(int)formationNum].Length; j++)
            {
                for (int i = 0; i < formations[(int)formationNum][j].Length; i++)
                {
                    bool moveIt = char.IsLower(formations[(int)formationNum][j][i]);
                    switch (formations[(int)formationNum][j][i])
                    {
                    case 'c':
                    case 'C':
                        GameScene.AddEntity(new ClassicEnemy(1, location.Y + j * 2, location.X + i * 2, moveIt));
                        break;

                    case 'g':
                    case 'G':
                        GameScene.AddEntity(new ShootingEnemy(random.NextDouble(), 1, location.Y + j * 2, location.X + i * 2, moveIt));
                        break;

                    case 's':
                    case 'S':
                        GameScene.AddEntity(new ShieldEnemy(1, location.Y + j * 2, location.X + i * 2, moveIt));
                        break;
                    }
                }
            }
        }
Example #5
0
 public static void SpawnZooming(int xPos, double speed)
 {
     GameScene.AddEntity(new ShieldEnemy(speed, 34, xPos));
 }