public IEnumerator <float> HeavyTortoise(GameObject go)
        {
            Enemy e = (Enemy)go;

            e.Rotation = (float)Math.PI / 2f * 3f;
            e.Health   = 25f;
            e.LerpVelocity(65f, 8f);
            e.LerpRotation(e.Rotation + VectorMathHelper.GetAngleTo(e.Center, manager.thisScene.player.InnerHitbox.Center) / 2f, 12f);
            yield return(1.5f);

            BulletEmitter mainEmitter = new BulletEmitter(e, e.Center, false);

            mainEmitter.LockedToParentPosition = true;
            mainEmitter.LockPositionOffset     = Vector2.Zero;
            yield return(.01f);

            while (true)
            {
                int shots = 0;
                while (shots < 20)
                {
                    if (manager.thisScene.PointOnScreen(go.Center))
                    {
                        AudioManager.PlaySoundEffect(GameScene.Shot4Sound, .25f);
                    }

                    mainEmitter.FireBulletCluster(VectorMathHelper.GetAngleTo(mainEmitter.Center, manager.thisScene.player.InnerHitbox.Center), 1, 10f, 150f, 0f, Color.DeepSkyBlue);
                    shots++;
                    yield return(.06f);
                }

                yield return(1.73f);
            }
        }
        public IEnumerator <float> Phase4Orb(GameObject go)
        {
            BulletEmitter thisEmitter = new BulletEmitter(this, go.Center, false);

            thisEmitter.Rotation     = VectorMathHelper.GetAngleTo(thisEmitter.Center, thisScene.player.InnerHitbox.Center);
            thisEmitter.CustomValue1 = thisEmitter.Rotation;
            while (true)
            {
                yield return(3f);

                float waveEnd = currentGameTime + 1.8f;

                while (currentGameTime < waveEnd)
                {
                    thisEmitter.Center   = go.Center;
                    thisEmitter.Rotation = thisEmitter.CustomValue1 + ((float)Math.Sin(currentGameTime * 2f)) / 3f;
                    AudioManager.PlaySoundEffect(GameScene.Shot5Sound, .8f, 0f);
                    Bullet b = thisEmitter.FireBullet(160f, Color.OrangeRed, BulletType.DiamondSmall);
                    b.LerpVelocity(80f, 4f);
                    yield return(.06f);
                }

                yield return(3f);
            }
        }
        public static RayCollisionPoint GetCollision(Ray ray, PlaneCollision plane, out float scale1, out float scale2)
        {
            try
            {
                // transformation matrix 2
                Vector3 eq = VectorMathHelper.SolveLinearEquation(-ray.Direction, plane.SpanVector1, plane.SpanVector2,
                                                                  ray.Position - plane.Origin);

                // point of collision
                Vector3 poc = ray.Position + eq.X * ray.Direction;

                scale1 = eq.Y;
                scale2 = eq.Z;


                return(new RayCollisionPoint(poc, plane.Normal, eq.X));
            }
            catch (Exception ex)
            {
                // equation could not be solved or an error occured.

                //Console.WriteLine($"Unable to collide ray with plane.");
                scale1 = 0.0f;
                scale2 = 0.0f;

                return(new RayCollisionPoint());
            }
        }
Exemple #4
0
        public IEnumerator <float> Phase3Ring2Script(GameObject go)
        {
            while (true)
            {
                foreach (BulletEmitter be in ring2Emitters)
                {
                    float angleToPlayer = VectorMathHelper.GetAngleTo(Center, thisScene.player.InnerHitbox.Center);
                    float thisRotation  = VectorMathHelper.GetAngleTo(Center, be.Center);

                    if (thisRotation < (angleToPlayer + .1f) && thisRotation > (angleToPlayer - .1f))
                    {
                        // Fire a bomb that will explode after a few moments.
                        AudioManager.PlaySoundEffect(GameScene.Shot6Sound, .75f, .5f);
                        Bullet bomb = be.FireBullet(140f, Color.Orange);
                        bomb.LerpVelocity(0f, 2f);
                        scriptManager.Execute(BombExplosion, bomb);

                        // Delay the spread.
                        nextSpreadShotTime += 1.5f;
                    }
                    else
                    {
                        AudioManager.PlaySoundEffect(GameScene.Shot4Sound, .5f, 0f);
                        foreach (Bullet b in be.FireBulletSpread(be.Rotation, 4, 25f, 130f, Color.DeepSkyBlue))
                        {
                            b.LerpVelocity(60f, 3f);
                        }
                    }
                }

                yield return(1.2f);
            }
        }
Exemple #5
0
        public IEnumerator <float> SeekingHailBullets(GameObject thisObject)
        {
            Bullet thisBullet = (Bullet)thisObject;

            yield return(3f);

            AudioManager.PlaySoundEffect(GameScene.Shot6Sound, .5f, 0f);
            thisBullet.Rotation = VectorMathHelper.GetAngleTo(thisBullet.Center, thisScene.player.InnerHitbox.Center);
            thisBullet.LerpVelocity(350f, 0.3f);
        }
Exemple #6
0
        public IEnumerator <float> SlicerSimpleShot(GameObject go)
        {
            yield return(.6f);

            while (true)
            {
                new BulletEmitter(go, go.Center, true).FireBullet(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 140f, Color.Orange);
                yield return(1.5f);
            }
        }
Exemple #7
0
        public IEnumerator <float> SlowHomingBullet(GameObject go)
        {
            yield return(1.5f);

            AudioManager.PlaySoundEffect(GameScene.Shot8Sound, .3f, -.6f);
            go.LerpVelocity(0f, .5f);

            go.Rotation = VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center);
            go.LerpVelocity(145f, 1.5f);
        }
        public IEnumerator <float> SimplePlayerSpreadShot(GameObject go)
        {
            while (true)
            {
                yield return(go.CustomValue1);

                AudioManager.PlaySoundEffect(GameScene.Shot2Sound, .4f);
                new BulletEmitter(go, go.Center, true).FireBulletSpread(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), (int)go.CustomValue2, go.CustomValue3, go.CustomValue4, Color.DeepSkyBlue);
            }
        }
        public IEnumerator <float> Phase2Orb(GameObject go)
        {
            while (true)
            {
                yield return(2f);

                new BulletEmitter(this, go.Center, true).FireBulletWave(VectorMathHelper.GetAngleTo(go.Center, thisScene.player.InnerHitbox.Center), 3, 100f, 25f, Color.MediumPurple, BulletType.DiamondSmall);
                AudioManager.PlaySoundEffect(GameScene.Shot6Sound, .75f, 0f);
            }
        }
        public IEnumerator <float> Phase1Orb(GameObject go)
        {
            while (true)
            {
                yield return(3f);

                new BulletEmitter(this, go.Center, true).FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, thisScene.player.InnerHitbox.Center), 14, 35f, 140f, 40f, Color.Purple);
                AudioManager.PlaySoundEffect(GameScene.Shot1Sound, .7f, -.5f);
            }
        }
        public IEnumerator <float> SimplePlayerShot(GameObject go)
        {
            while (true)
            {
                yield return(go.CustomValue1);

                AudioManager.PlaySoundEffect(GameScene.Shot6Sound, 1f);
                new BulletEmitter(go, go.Center, true).FireBullet(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), go.CustomValue2, Color.Orange);
            }
        }
        public IEnumerator <float> Phase4Script(GameObject go)
        {
            yield return(3f);

            // Set the order the emitters will fire in.
            List <BulletEmitter> emitters = new List <BulletEmitter>()
            {
                arm3Emitter,
                arm4Emitter,
                arm1Emitter,
                arm6Emitter,
                arm2Emitter,
                arm5Emitter,
            };

            List <Color> colors = new List <Color>()
            {
                Color.Orange,
                Color.Purple,
                Color.MediumPurple,
                Color.Orange,
                Color.Purple,
                Color.MediumPurple
            };

            int   orbsSummoned   = 0;
            float nextSummonTime = currentGameTime + 6f;
            int   currentArm     = 0;

            while (true)
            {
                emitters[currentArm].Rotation = VectorMathHelper.GetAngleTo(emitters[currentArm].Center, thisScene.player.InnerHitbox.Center);
                AudioManager.PlaySoundEffect(GameScene.Shot7Sound, .65f, .45f);
                foreach (Bullet b in emitters[currentArm].FireBulletExplosion(25, 190f, colors[currentArm], BulletType.DiamondSmall))
                {
                    b.LerpVelocity(100f, 3f);
                }

                currentArm++;
                if (currentArm > emitters.Count - 1)
                {
                    currentArm = 0;
                }

                if (currentGameTime > nextSummonTime && orbsSummoned < 3)
                {
                    orbsSummoned++;
                    nextSummonTime += 15f;
                    scriptManager.Execute(Phase4Orb, SummonOrb());
                }

                yield return(.23f);
            }
        }
        public IEnumerator <float> DragonflyDelayedShoot(GameObject go)
        {
            yield return(go.CustomValue2);

            while (true)
            {
                AudioManager.PlaySoundEffect(GameScene.Shot5Sound, .6f, 0f);
                new BulletEmitter(go, go.Center, true).FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 1, 10f, 130f, 150f, Color.Orange);
                yield return(go.CustomValue1);
            }
        }
        public IEnumerator <float> StabbingSlicer(GameObject go)
        {
            go.Rotation = VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center);
            yield return(.5f);

            while (true)
            {
                AudioManager.PlaySoundEffect(GameScene.Shot3Sound, .7f, .5f);
                new BulletEmitter(go, go.Center, true).FireBulletSpread(go.Rotation, 3, 70f, 130f, Color.Orange);
                yield return(1.5f);
            }
        }
        IEnumerator <float> ColumnDragonfly(GameObject go)
        {
            go.DrawAtTrueRotation = true;
            go.Rotation           = ((float)Math.PI / 2) * 3;
            go.Velocity           = 150f;
            yield return(1f);

            go.LerpVelocity(50f, 2f);
            yield return(2f);

            go.Rotation = VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center);
            go.LerpVelocity(150f, 2f);
        }
        public IEnumerator <float> SimpleStrafe(GameObject go)
        {
            while (true)
            {
                yield return(1.3f);

                if (manager.thisScene.PointOnScreen(go.Center))
                {
                    AudioManager.PlaySoundEffect(GameScene.Shot1Sound, .7f, .5f);
                }
                new BulletEmitter(go, go.Center, true).FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 1, 20f, 100f, 0f, Color.Orange);
            }
        }
Exemple #17
0
        public IEnumerator <float> FirstKomodo(GameObject go)
        {
            yield return(2f);

            BulletEmitter be = new BulletEmitter(go, go.Center);

            be.LockedToParentPosition = true;
            be.LockPositionOffset     = Vector2.Zero;

            while (true)
            {
                int shots = 0;

                while (shots < 15)
                {
                    be.FireBulletSpread(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 5, 70f, 220f, Color.Orange);
                    AudioManager.PlaySoundEffect(GameScene.Shot3Sound, .5f);
                    shots++;
                    yield return(.3f);
                }

                yield return(.5f);

                go.LerpPosition(new Vector2(500, go.Center.Y), 1.5f);
                yield return(2f);

                shots = 0;
                float turnMod = 1;
                while (shots < 20)
                {
                    if (shots > 10)
                    {
                        turnMod = -1f;
                    }

                    be.FireBulletExplosion(15, 120f, Color.DeepSkyBlue);
                    AudioManager.PlaySoundEffect(GameScene.Shot6Sound, .5f);
                    be.Rotation += .1f * turnMod;

                    shots++;
                    yield return(.1f);
                }

                yield return(.5f);

                go.LerpPosition(new Vector2(300, go.Center.Y), 1.5f);
                yield return(2f);
            }
        }
Exemple #18
0
        public static Boolean GetCollision(SphereCollision collidableA, PlaneCollision collidableB, out Vector3 position,
                                           out Vector3 normal, out float scale1, out float scale2)
        {
            Vector3 eq = VectorMathHelper.SolveLinearEquation(collidableB.Normal / collidableB.Normal.Length(), collidableB.SpanVector1,
                                                              collidableB.SpanVector2, collidableA.Position - collidableB.Origin);

            // get the point of collision
            position = collidableB.Origin + eq.Y * collidableB.SpanVector1 + eq.Z * collidableB.SpanVector2;
            normal   = (eq.X < 0 ? -1 : 1) * collidableB.Normal;           // invert normal if the scalar is negative

            scale1 = eq.Y;
            scale2 = eq.Z;

            return(Math.Abs(eq.X) < collidableA.Radius);
        }
        public ParasiteOrb SummonOrb()
        {
            AudioManager.PlaySoundEffect(GameScene.PhaseInSound, .8f, 0f);
            ParasiteOrb orb = new ParasiteOrb(thisScene, Center);

            orb.SetTexture(boss4OrbTexture);
            orbs.Add(orb);
            orb.Rotation = VectorMathHelper.GetRandom();
            orb.Velocity = 55f;
            orb.Color    = Color.Transparent;
            orb.LerpColor(Color.White, .5f);
            orb.SetParent(this);
            orb.SetHealth(thisPhaseOrbHealth);

            return(orb);
        }
Exemple #20
0
        public IEnumerator <float> ClusterBombs(GameObject go)
        {
            Bullet thisBullet = (Bullet)go;

            thisBullet.LerpVelocity(0f, 3f);
            yield return(3f + (thisBullet.CustomValue1 * .6f));

            BulletEmitter explosion = new BulletEmitter(this, thisBullet.Center);

            AudioManager.PlaySoundEffect(GameScene.Shot1Sound, .7f, 0f);
            AudioManager.PlaySoundEffect(GameScene.Shot7Sound, .7f, 0f);
            explosion.FireBulletExplosion(6, 160f, Color.Lerp(Color.White, Color.DeepSkyBlue, .4f));
            explosion.FireBulletCluster(VectorMathHelper.GetAngleTo(thisBullet.Center, thisScene.player.InnerHitbox.Center), 3, 40f, 160f, 40f, Color.Lerp(Color.White, Color.DeepSkyBlue, .4f), BulletType.Circle);
            explosion.FireBulletCluster(VectorMathHelper.GetAngleTo(thisBullet.Center, thisScene.player.InnerHitbox.Center), 4, 50f, 140f, 50f, Color.Lerp(Color.White, Color.DeepSkyBlue, .4f), BulletType.CircleSmall);
            explosion.Destroy();

            thisBullet.Destroy();
        }
Exemple #21
0
        public IEnumerator <float> FocusFireTortoise(GameObject go)
        {
            yield return(.6f);

            while (true)
            {
                int shots = 0;
                while (shots < 60f)
                {
                    shots++;
                    new BulletEmitter(go, go.Center, true).FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 1, 10f, 150f, 25f, Color.DeepSkyBlue);
                    if (go.Center.X > manager.thisScene.ScreenArea.X && go.Center.X < manager.thisScene.ScreenArea.X + manager.thisScene.ScreenArea.Width && go.Center.Y > manager.thisScene.ScreenArea.Y && go.Center.Y < manager.thisScene.ScreenArea.Y + manager.thisScene.ScreenArea.Height)
                    {
                        AudioManager.PlaySoundEffect(GameScene.Shot4Sound, .05f);
                    }
                    yield return(.03f);
                }
                yield return(3f);
            }
        }
        // Method that creates a bullet and shoots it in any direction
        public Bullet[] FireBulletSpread(float rotation, int numberOfBullets, float spread, float velocity, Color newColor, BulletType type = BulletType.Circle)
        {
            if (AsteroidRebuttal.ManicMode)
            {
                velocity *= 2;
            }

            List <Bullet> bullets = new List <Bullet>();

            spread = VectorMathHelper.DegreesToRadians(spread);

            float angleDifference = spread / ((float)numberOfBullets - 1);
            float startAngle      = rotation - (spread / 2);

            for (int i = 0; i < numberOfBullets; i++)
            {
                bullets.Add(FireBullet(startAngle + (angleDifference * i), velocity, newColor, type));
            }

            return(bullets.ToArray());
        }
Exemple #23
0
        public IEnumerator <float> Phase3Ring1Script(GameObject go)
        {
            int   inrangeof = 0;
            float angleToPlayer;
            float thisRotation;

            while (true)
            {
                inrangeof = 0;

                foreach (BulletEmitter be in ring1Emitters)
                {
                    if (currentGameTime < be.CustomValue2)
                    {
                        continue;
                    }

                    angleToPlayer = VectorMathHelper.GetAngleTo(Center, thisScene.player.InnerHitbox.Center);
                    thisRotation  = VectorMathHelper.GetAngleTo(Center, be.Center);

                    if (thisRotation < (angleToPlayer + .1f) && thisRotation > (angleToPlayer - .1f))
                    {
                        AudioManager.PlaySoundEffect(GameScene.Shot1Sound, .7f, .3f);
                        be.FireBulletCluster(be.Rotation, 10, 20f, 100f, 200f, Color.Red);

                        // Stop it from firing for .2 seconds
                        be.CustomValue2 = currentGameTime + .2f;
                        inrangeof++;
                    }
                }

                if (inrangeof > 0)
                {
                    // The player is in range of at least one cannon, so delay the next spreading shot from the center by .7 seconds.
                    nextSpreadShotTime += .7f;
                }

                yield return(.03f);
            }
        }
        // Method that creates a cluster of bullets in a random spread and at variable velocity.
        public Bullet[] FireBulletCluster(float rotation, int numberOfBullets, float spread, float baseVelocity, float randomVelocity, Color newColor, BulletType type = BulletType.Circle)
        {
            if (AsteroidRebuttal.ManicMode)
            {
                baseVelocity *= 2;
            }

            List <Bullet> bullets = new List <Bullet>();

            spread = VectorMathHelper.DegreesToRadians(spread);
            float launchRotation;
            float velocity;

            for (int i = 0; i < numberOfBullets; i++)
            {
                velocity       = baseVelocity + ((float)rand.NextDouble() * randomVelocity);
                launchRotation = rotation + ((((float)rand.NextDouble() * 2) - 1) * (spread / 2));
                bullets.Add(FireBullet(launchRotation, velocity, newColor, type));
            }

            return(bullets.ToArray());
        }
        public override void Update(GameTime gameTime)
        {
            if (Center.X - Hitbox.Radius < thisScene.ScreenArea.X && nextRightBounceTime < gameTime.TotalGameTime.TotalSeconds)
            {
                // Bounce right
                Rotation = MathHelper.WrapAngle(Rotation = VectorMathHelper.GetRandomBetween((float)Math.PI / 4f, (float)Math.PI / -4f));
                Center   = new Vector2(thisScene.ScreenArea.X + Hitbox.Radius, Center.Y);

                nextRightBounceTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }
            else if (Center.X + Hitbox.Radius > thisScene.ScreenArea.X + thisScene.ScreenArea.Width && nextLeftBounceTime < gameTime.TotalGameTime.TotalSeconds)
            {
                // Bounce left
                Rotation = MathHelper.WrapAngle(VectorMathHelper.GetRandomBetween(((float)Math.PI / 4) * 3f, ((float)Math.PI / 4f) * 6f));
                Center   = new Vector2(thisScene.ScreenArea.X + thisScene.ScreenArea.Width - Hitbox.Radius, Center.Y);

                nextLeftBounceTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }
            else if (Center.Y - Hitbox.Radius < thisScene.ScreenArea.Y && nextDownBounceTime < gameTime.TotalGameTime.TotalSeconds)
            {
                // Bounce down
                Rotation = MathHelper.WrapAngle(Rotation = VectorMathHelper.GetRandomBetween((float)Math.PI / 4f, ((float)Math.PI / 4f) * 3f));
                Center   = new Vector2(Center.X, thisScene.ScreenArea.Y + Hitbox.Radius);

                nextDownBounceTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }
            else if (Center.Y + Hitbox.Radius > thisScene.ScreenArea.Y + thisScene.ScreenArea.Height && nextUpBounceTime < gameTime.TotalGameTime.TotalSeconds)
            {
                // Bounce up
                Rotation = MathHelper.WrapAngle((Rotation = VectorMathHelper.GetRandomBetween((float)Math.PI / -4f, ((float)Math.PI / -4f) * 3f)));
                Center   = new Vector2(Center.X, thisScene.ScreenArea.Y + thisScene.ScreenArea.Height - Hitbox.Radius);

                nextUpBounceTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }

            base.Update(gameTime);
        }
        public IEnumerator <float> Phase2Script(GameObject go)
        {
            yield return(3f);

            int cycles = 0;

            while (true)
            {
                float waveEndTime = currentGameTime + 5f;
                while (currentGameTime < waveEndTime)
                {
                    AudioManager.PlaySoundEffect(GameScene.Shot4Sound, .25f, 0f);
                    Bullet[] firedBullets = mainEmitter.FireBulletSpread(VectorMathHelper.GetAngleTo(mainEmitter.Center, thisScene.player.InnerHitbox.Center), 5, 80f, 180f, Color.White, BulletType.DiamondSmall);
                    firedBullets[0].Color = Color.Orange;
                    firedBullets[1].Color = Color.Purple;
                    firedBullets[2].Color = Color.OrangeRed;
                    firedBullets[3].Color = Color.Purple;
                    firedBullets[4].Color = Color.Orange;

                    foreach (Bullet b in firedBullets)
                    {
                        scriptManager.Execute(Phase2BulletCurve, b);
                    }

                    yield return(.03f);
                }
                cycles++;

                yield return(1.5f);

                if (cycles < 3)
                {
                    scriptManager.Execute(Phase2Orb, SummonOrb());
                }
                yield return(1.5f);
            }
        }
Exemple #27
0
        public void EquationSystem1()
        {
            // create a plane that spans over the x axis

            // p: x = ZERO3 + (0, 1, 0) + (0, 0, 1)

            // create the plane
            Vector3 planeOrigin     = new Vector3(0, 0, 0);
            Vector3 planeParameter1 = new Vector3(0, 1, 0);
            Vector3 planeParameter2 = new Vector3(0, 0, 1);
            Vector3 planeNormal     = new Vector3(1, 0, 0);             // pp1 x pp2

            // create our point of interest
            Vector3 sphere = new Vector3(-1, 0, 0);

            // We want to solve Ax = b
            // create our Vector "b", which is our solution
            Vector3 b = sphere - planeOrigin;

            // now we can create a room with our plane and the normal which contains all points in R3
            Vector3 solution = VectorMathHelper.SolveLinearEquation(planeParameter1, planeParameter2, planeNormal, b);

            // now we should have a solution. (-1, 0, 0)
        }
Exemple #28
0
        public IEnumerator <float> CircleSquadKomodo(GameObject go)
        {
            if (go.CustomValue2 < 200)
            {
                go.CustomValue2 = 200;
            }

            yield return(2f + (go.CustomValue1 * 1.1f));

            while (true)
            {
                if (Vector2.Distance(manager.thisScene.player.InnerHitbox.Center, circleSquadOrigin) > go.CustomValue2)
                {
                    AudioManager.PlaySoundEffect(GameScene.Shot6Sound, .8f);
                    new BulletEmitter(go, go.Center, true).FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 15, 35f, 200f, 50f, Color.DeepSkyBlue);
                }
                else
                {
                    AudioManager.PlaySoundEffect(GameScene.Shot3Sound, .3f);
                    new BulletEmitter(go, go.Center, true).FireBullet(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 100f, Color.DeepSkyBlue);
                }
                yield return(2f);
            }
        }
Exemple #29
0
        public IEnumerator <float> BulletFountain(GameObject go)
        {
            BulletEmitter thisEmitter = new BulletEmitter(go, go.Center, false);

            thisEmitter.LockedToParentPosition = true;
            thisEmitter.LockPositionOffset     = Vector2.Zero;

            yield return(go.CustomValue1);

            float timeToFire = go.CustomValue2;

            float startTime = manager.thisScene.currentGameTime;

            while (manager.thisScene.currentGameTime < startTime + timeToFire)
            {
                if (manager.thisScene.PointOnScreen(go.Center))
                {
                    AudioManager.PlaySoundEffect(GameScene.Shot4Sound, .1f, -.3f);
                }

                thisEmitter.FireBulletCluster(VectorMathHelper.GetAngleTo(go.Center, manager.thisScene.player.InnerHitbox.Center), 1, 10f, (float)Math.Max(100, go.CustomValue3), 0f, Color.DeepSkyBlue);
                yield return(.06f);
            }
        }
        public override IEnumerator <float> LevelScript()
        {
            manager.thisScene.fader.LerpColor(Color.Transparent, 1f);
            Enemy e;

            AudioManager.PlaySong(Level1Theme, false, .5f);

            TitleShown = true;
            manager.thisScene.LerpTitleColor(Color.White, 1f);
            yield return(1f);

            yield return(2f);

            manager.thisScene.LerpTitleColor(Color.Transparent, 1f);
            yield return(1f);

            TitleShown = false;

            // A wave of downward enemies
            for (int i = 0; i < 5; i++)
            {
                e          = SpawnEnemy(EnemyType.Slicer, new Vector2(100 + 100 * i, -40));
                e.Velocity = 100f;

                e.CustomValue1 = 3f;
                e.CustomValue2 = 100f;

                yield return(.8f);
            }

            yield return(.5f);

            // Level time: 8.5 seconds

            // Enemies coming in from the sides at an angle with homing shots
            e = SpawnEnemyAtAngle(EnemyType.Slicer, new Vector2(manager.thisScene.ScreenArea.Width + 60, 25), (float)Math.PI / 4 * 3, 70);
            e.CustomValue1 = .9f;
            e.CustomValue2 = 100;
            scriptManager.Execute(SimplePlayerShot, e);
            yield return(1f);

            e = SpawnEnemyAtAngle(EnemyType.Slicer, new Vector2(-60, 25), (float)Math.PI / 4, 70);
            e.CustomValue1 = .9f;
            e.CustomValue2 = 100;
            scriptManager.Execute(SimplePlayerShot, e);
            yield return(1f);

            e = SpawnEnemyAtAngle(EnemyType.Slicer, new Vector2(manager.thisScene.ScreenArea.Width + 60, 55), (float)Math.PI / 4 * 3, 70);
            e.CustomValue1 = .9f;
            e.CustomValue2 = 100;
            scriptManager.Execute(SimplePlayerShot, e);
            yield return(1f);

            e = SpawnEnemyAtAngle(EnemyType.Slicer, new Vector2(-60, 55), (float)Math.PI / 4, 70);
            e.CustomValue1 = .9f;
            e.CustomValue2 = 100;
            scriptManager.Execute(SimplePlayerShot, e);

            yield return(4f);

            // Level time: 15.5 seconds
            List <Enemy> enemygroup = new List <Enemy>();

            // Spawn a larger group of 5 enemies from the top to drop toward the middle before beginning to fire spread shots
            for (int i = 0; i < 3; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(250 + 50 * i, -40));
                enemygroup.Add(e);
                e.Health = 5;
                e.LerpPosition(new Vector2(e.Center.X, 250), 3f);
                e.CustomValue1 = 1.5f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }
            for (int i = 0; i < 2; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(275 + 50 * i, -80));
                enemygroup.Add(e);
                e.Health = 5;
                e.LerpPosition(new Vector2(e.Center.X, 210), 3f);

                e.CustomValue1 = 2f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }

            yield return(3f);

            // Level time: 18.5

            // Spawn a larger group of 5 enemies from the top to drop toward the middle before beginning to fire spread shots
            for (int i = 0; i < 3; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(100 + 50 * i, -40));
                enemygroup.Add(e);
                e.Health = 3;
                e.LerpPosition(new Vector2(e.Center.X, 350), 3f);
                e.CustomValue1 = 1.5f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }
            for (int i = 0; i < 2; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(125 + 50 * i, -80));
                enemygroup.Add(e);
                e.Health = 3;
                e.LerpPosition(new Vector2(e.Center.X, 310), 3f);

                e.CustomValue1 = 2f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }

            yield return(2f);

            // Level time: 20.5

            // Spawn a larger group of 5 enemies from the top to drop toward the middle before beginning to fire spread shots
            for (int i = 0; i < 3; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(425 + 50 * i, -40));
                enemygroup.Add(e);
                e.Health = 3;
                e.LerpPosition(new Vector2(e.Center.X, 350), 3f);
                e.CustomValue1 = 1.5f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }
            for (int i = 0; i < 2; i++)
            {
                e = SpawnEnemy(EnemyType.Slicer, new Vector2(450 + 50 * i, -80));
                enemygroup.Add(e);
                e.Health = 3;
                e.LerpPosition(new Vector2(e.Center.X, 310), 3f);

                e.CustomValue1 = 2f;
                e.CustomValue2 = 3;
                e.CustomValue3 = 50f;
                e.CustomValue4 = 140f;

                scriptManager.Execute(SimplePlayerSpreadShot, e);
            }

            yield return(5f);

            // Level time: 25.5

            foreach (Enemy enemy in enemygroup)
            {
                enemy.LerpVelocity(100f, 3f);
            }

            yield return(3f);

            // Level time 28.5

            // Spawn a tortoise from below a couple times, and then add a couple from above
            e = SpawnEnemyAtAngle(EnemyType.Tortoise, new Vector2(55, 655), ((float)Math.PI / 2f) * -.8f, 40f);
            scriptManager.Execute(TortoiseExplosiveShot, e);
            yield return(2.5f);

            e = SpawnEnemyAtAngle(EnemyType.Tortoise, new Vector2(555, 655), (((float)Math.PI / 2f) * -.3f) - ((float)Math.PI / 2), 40f);
            scriptManager.Execute(TortoiseExplosiveShot, e);
            yield return(3f);

            e = SpawnEnemy(EnemyType.Tortoise, new Vector2(200f, -50f));
            e.LerpVelocity(40f, 4f);
            scriptManager.Execute(TortoiseExplosiveShot, e);

            e = SpawnEnemy(EnemyType.Tortoise, new Vector2(400f, -50f));
            e.LerpVelocity(40f, 4f);
            scriptManager.Execute(TortoiseExplosiveShot, e);

            // Level time: 34

            yield return(2f);

            // Level time 36

            for (int i = 0; i < 12; i++)
            {
                float x;
                if (i % 2 == 0)
                {
                    x = -40;
                }
                else
                {
                    x = 740;
                }

                Vector2 spawnPoint = new Vector2(x, 100 + (15 * i));

                e = SpawnEnemyAtAngle(EnemyType.Dragonfly, spawnPoint, VectorMathHelper.GetAngleTo(spawnPoint, manager.thisScene.player.InnerHitbox.Center), 130f);
                yield return(.5f);
            }

            //Level time 42
            Random rand = new Random();

            for (int i = 0; i < 15; i++)
            {
                e          = SpawnEnemy(EnemyType.Slicer, new Vector2(rand.Next(50, 600), -50));
                e.Velocity = 200f;
                e.LerpVelocity(55f, 2f);
                e.CustomValue1 = 1.25f;
                e.CustomValue2 = 135f;
                scriptManager.Execute(SimplePlayerShot, e);

                yield return(.5f);
            }

            // Level time 49.5

            yield return(1.5f);

            // A tortoise from below that will track the player with its cannons as it moves
            e          = SpawnEnemy(EnemyType.Tortoise, new Vector2(250, 680));
            e.Rotation = (float)Math.PI / 2f * 3f;
            scriptManager.Execute(HeavyTortoise, e);

            yield return(4f);

            // A tortoise from below that will track the player with its cannons as it moves
            e          = SpawnEnemy(EnemyType.Tortoise, new Vector2(550, 680));
            e.Rotation = (float)Math.PI / 2f * 3f;
            scriptManager.Execute(HeavyTortoise, e);

            yield return(4f);

            yield return(6f);

            manager.thisScene.PlayBossWarning();
            yield return(6.6f);

            //SPAWN THE BOSS
            Boss boss = new TestBoss(manager.thisScene, new Vector2(350f, -20f));

            BeginBossBattle(boss);
            yield return(1f);

            bossTheme = AudioManager.PlaySong(BossTheme);

            while (boss.Health > 0)
            {
                yield return(.03f);
            }

            // Stop the boss theme and hide the health bar
            bossTheme.Dispose();
            manager.thisScene.HideBossHealthbar();

            // Explode the boss!!
            scriptManager.AbortObjectScripts(boss);
            manager.thisScene.player.Phasing = true;
            foreach (GameObject b in manager.thisScene.gameObjects.FindAll(x => x is Bullet))
            {
                scriptManager.AbortObjectScripts(b);
                b.Phasing = true;
                b.LerpColor(Color.Transparent, 1f);
            }

            scriptManager.Execute(manager.thisScene.BossExplosion, boss);
            yield return(3.3f);

            yield return(2f);

            manager.thisScene.fader.LerpColor(Color.Transparent, 3f);
            yield return(3f);

            manager.thisScene.fader.LerpColor(Color.Black, 2f);


            yield return(2f);

            manager.thisScene.player.Phasing = false;
            manager.SetLevel(2);
        }