예제 #1
0
        protected override void Behave(bool trigger, float time)
        {
            if (divideNo < MAX_DIVIDES)
            {
                scale += 0.01f;
                Size   = originalSize * scale;
            }
            if (trigger && divideNo < MAX_DIVIDES)
            {
                Vector2 nextV;
                for (int i = 0; i < 1; i++)
                {
                    nextV = RandUnitVector2();
                    EDivider e = new EDivider(tex, position, velocity + nextV, divideNo + 1);
                    EnemyManager.AddEnemy((Enemy)e);
                }

                nextV = RandUnitVector2();

                velocity += nextV;

                angle = (float)Math.Atan2(velocity.Y, velocity.X);
                scale = 1;
                Size  = originalSize;
                divideNo++;
            }
        }
예제 #2
0
        protected override void Behave(bool trigger)
        {
            if (trigger && divideNo < MAX_DIVIDES)
            {
                Vector2 nextV = new Vector2();

                for (int i = 0; i < 2; i++)
                {
                    nextV = RandUnitVector2();
                    EDivider e = new EDivider(tex, position, velocity + nextV, divideNo + 1);
                    EnemyManager.AddEnemy((Enemy)e);
                }
                nextV = RandUnitVector2();

                velocity += nextV;

                angle = (float)Math.Atan2(velocity.Y, velocity.X);
                divideNo++;
            }
        }
        private void Spawn()
        {
            Vector2 pos    = new Vector2();
            Vector2 vel    = new Vector2();
            Vector2 centre = new Vector2(Game1.ScreenX / 2, Game1.ScreenY / 2);

            if (!bossMode)
            {
                if (currentTime / (SPAWN_A + stats.SpawnModifier) > counterA && stats.DividersOn)
                {
                    counterA++;
                    int numCreate = Game1.rand.Next(1, 2 + stats.SpawnAmountModifier);

                    for (int i = 0; i < numCreate; i++)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        EDivider e = new EDivider(divideTex, pos, vel, 0);
                        enemies.Add((Enemy)e);
                    }
                }
                if (currentTime / (SPAWN_B + stats.SpawnModifier) > counterB && stats.ChasersOn)
                {
                    counterB++;
                    int numCreate = Game1.rand.Next(1, 6 + stats.SpawnAmountModifier);

                    for (int i = 0; i < numCreate; i++)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        EChaser e = new EChaser(chaseTex, pos, vel);
                        enemies.Add((Enemy)e);
                    }
                }
                if (ESpinner.CurrentCount < MAX_SPINNERS && currentTime / (SPAWN_C + stats.SpawnModifier) > counterC && stats.SpinnersOn)
                {
                    counterC++;
                    int numCreate = Game1.rand.Next(1, 3);

                    for (int i = 0; i < numCreate; i++)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        //vel *= ESpinner.SPEED;
                        ESpinner e = new ESpinner(spinTex, pos, vel);
                        enemies.Add((Enemy)e);
                    }
                }
                if (EWorm.CurrentCount < stats.MaxWorms && currentTime / (SPAWN_D + stats.SpawnModifier) > counterD && stats.WormsOn)
                {
                    counterD++;
                    int loopControl;
                    if (LevelManager.Mode == GameMode.Worms)
                    {
                        loopControl = stats.MaxWorms - EWorm.CurrentCount;
                    }
                    else
                    {
                        loopControl = stats.SpawnAmountModifier / 2;
                    }
                    for (int i = 0; i < loopControl; i++)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        EWorm w = new EWorm(pos, vel, WormTex, 0, stats.SpawnAmountModifier + 1, null);
                        enemies.Add((Enemy)w);
                    }
                }
            }
            else
            {
                if (LevelManager.Mode != GameMode.Worms)
                {
                    if (boss == null && enemies.Count == 0)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        boss = new Boss(bossTex, pos, vel);
                    }
                }
                else
                {
                    if (wBoss == null && enemies.Count == 0)
                    {
                        SetSpawnParameters(ref pos, ref vel, centre);
                        wBoss = new WormBoss(pos, vel, WBossTex, 0, (int)LevelManager.Current.BossStats.SpawnRate + 4, null);
                    }
                }
            }
        }