Exemple #1
0
        private void SpawnEnemy(EntityData entityData, GameTime gameTime)
        {
            if (entityData.Type == EntityType.BOSS)
            {
                Boss boss = new Boss(spriteBatch, game, audioManager, gameTime, "boss" + enemySpawnCounter.ToString(), this);
                boss.position = entityData.Position;
                addEntity(boss);
                levelManager.stopBgScroll();
            }
            else if (entityData.Type == EntityType.NIGHTMARE)
            {
                Nightmare nightmare = new Nightmare(spriteBatch, game, audioManager, this, "nightmare" + enemySpawnCounter.ToString());
                nightmare.onDie += new Nightmare.PowerupReleaseHandle(ReleasePowerup);
                nightmare.position = entityData.Position;
                addEntity(nightmare);
            }
            else if (entityData.Type == EntityType.BLUE_BLOOD_VESSEL)
            {
                BlueBloodvessel bloodvessel = new BlueBloodvessel(spriteBatch, game, audioManager, this, "blue_bloodvessel" + enemySpawnCounter.ToString());
                bloodvessel.onDie += new BlueBloodvessel.PowerupReleaseHandle(ReleasePowerup);
                //bloodvessel.position = entityData.Position;
                addEntity(bloodvessel);
            }
            else if (entityData.Type == EntityType.RED_BLOOD_VESSEL)
            {
                RedBloodvessel bloodvessel = new RedBloodvessel(spriteBatch, game, audioManager, this, "red_bloodvessel" + enemySpawnCounter.ToString());
                //bloodvessel.onDie += new RedBloodvessel.PowerupReleaseHandle(ReleasePowerup);
                bloodvessel.position = entityData.Position;
                addEntity(bloodvessel);
            }
            else if (entityData.Type == EntityType.PURPLE_BLOOD_VESSEL)
            {
                PurpleBloodvessel bloodvessel = new PurpleBloodvessel(spriteBatch, game, audioManager, this, "purple_bloodvessel" + enemySpawnCounter.ToString());
                //bloodvessel.onDie += new PurpleBloodvessel.PowerupReleaseHandle(ReleasePowerup);
                bloodvessel.position = entityData.Position;
                addEntity(bloodvessel);
            }
            else if (entityData.Type == EntityType.DARK_THOUGHT)
            {
                DarkThought darkThought = new DarkThought(spriteBatch, game, audioManager, gameTime, "darkthought" + enemySpawnCounter.ToString(), this, entityData.PathFinding);
                darkThought.onDie += new DarkThought.PowerupReleaseHandle(ReleasePowerup);
                darkThought.position = entityData.Position;
                addEntity(darkThought);
            }
            else if (entityData.Type == EntityType.INNER_DEMON)
            {
                InnerDemon innerDemon = new InnerDemon(spriteBatch, game, audioManager, "inner_demon" + enemySpawnCounter.ToString(), this, entityData.PathFinding);
                innerDemon.onDie += new InnerDemon.PowerupReleaseHandle(ReleasePowerup);
                innerDemon.position = entityData.Position;
                addEntity(innerDemon);
            }
            else if (entityData.Type == EntityType.DARK_WHISPER)
            {
                DarkWhisper darkWhisper = new DarkWhisper(spriteBatch, game, audioManager, "dark_whisper" + enemySpawnCounter.ToString(), this, entityData.PathFinding);
                darkWhisper.onDie += new DarkWhisper.PowerupReleaseHandle(ReleasePowerup);
                darkWhisper.position = entityData.Position;
                addEntity(darkWhisper);
            }
            else if (entityData.Type == EntityType.WEAPON_POWERUP_SPREAD)
            {
                WeaponPowerupSpread wpnPowerupSpread = new WeaponPowerupSpread(spriteBatch, game, "wpnPowerupSpread" + enemySpawnCounter.ToString(), entityData.Position);
                addEntity(wpnPowerupSpread);
            }
            else if (entityData.Type == EntityType.WEAPON_POWERUP_RAPID)
            {
                WeaponPowerupRapid wpnPowerupRapid = new WeaponPowerupRapid(spriteBatch, game, "wpnPowerupRapid" + enemySpawnCounter.ToString(), entityData.Position);
                addEntity(wpnPowerupRapid);
            }
            else if (entityData.Type == EntityType.HEALTH_POWERUP)
            {
                HealthPowerup healthPowerup = new HealthPowerup(spriteBatch, game, "healthPowerup" + enemySpawnCounter.ToString(), entityData.Position);
                addEntity(healthPowerup);
            }

            enemySpawnCounter++;
        }
Exemple #2
0
        public void Update(GameTime gameTime)
        {
            if (!spawningPaused && !tutorial)
            {
                timer += (uint)gameTime.ElapsedGameTime.Milliseconds;
            }
            else if (!tutorial)
            {
                spawningPaused = !allEnemiesDead();
            }

            CheckSpawnQueue(gameTime);
            collisionManager.checkCollision();
            Vector2 tmpPlayerPosition = Vector2.Zero;

            for (int i = 0; i < entityList.Count; i++)
            {
                if (entityList[i].Type == EntityType.BOSS || entityList[i].Type == EntityType.NIGHTMARE || entityList[i].Type == EntityType.INNER_DEMON || entityList[i].Type == EntityType.LESSER_DEMON || entityList[i].Type == EntityType.DARK_WHISPER)
                {
                    if (player != null)
                    {
                        entityList[i].Target = player.position;
                    }
                }
                entityList[i].Update(gameTime);
                if (entityList[i].KillMe == true)
                {
                    killList.Add(entityList[i]);
                }
            }

            for (int i = 0; i < bulletList.Count; i++)
            {
                bulletList[i].Update(gameTime);
                if (bulletList[i].rangeExceded())
                {
                    bulletList.RemoveAt(i);
                }
            }

            if (killList.Count > 0)
            {
                RemoveEntity();
            }

            #region spawn_enemies_dev
            if(bool.Parse(game.config.getValue("Debug", "SpawnKeys")))
            {
                spawnEnemies.Update(gameTime);
                if (spawnEnemies.One == true)
                {
                    int count = EntityCount(EntityType.NIGHTMARE);
                    Nightmare nightmare = new Nightmare(spriteBatch, game, audioManager, this, "nightmare_spawned" + count.ToString());
                    nightmare.onDie += new Nightmare.PowerupReleaseHandle(ReleasePowerup);
                    nightmare.position.X = 0.0f;
                    float newY = random.Next(50, game.Window.ClientBounds.Bottom - 50);
                    nightmare.position.X = 0.0f;
                    nightmare.position.Y = newY;
                    while (addEntity(nightmare) == false)
                    {
                        count++;
                        nightmare.Alias = "nightmare" + count.ToString();
                    }
                }

                if (spawnEnemies.Two == true)
                {
                    int count = EntityCount(EntityType.BLUE_BLOOD_VESSEL);
                    BlueBloodvessel bloodvessel = new BlueBloodvessel(spriteBatch, game, audioManager, this, "bloodvessel_spawned" + count.ToString());
                    //bloodvessel.onDie += new BlueBloodvessel.PowerupReleaseHandle(ReleasePowerup);
                    bloodvessel.position.X = 0.0f;
                    float newY = random.Next(50, game.Window.ClientBounds.Bottom - 50);
                    bloodvessel.position.X = 0.0f;
                    bloodvessel.position.Y = newY;
                    while (addEntity(bloodvessel) == false)
                    {
                        count++;
                        bloodvessel.Alias = "bloodvessel" + count.ToString();
                    }

                }

                if (spawnEnemies.Three == true)
                {
                    int count = EntityCount(EntityType.DARK_THOUGHT);
                    Vector2 waypoint = new Vector2(100.0f, game.Window.ClientBounds.Center.Y);
                    Path waypoints = new Path(waypoint);
                    waypoint = new Vector2(200.0f, 200.0f);
                    waypoints.AddPath(waypoint);
                    waypoint = new Vector2(1000.0f, 600.0f);
                    waypoints.AddPath(waypoint);
                    DarkThought darkThought = new DarkThought(spriteBatch, game, audioManager, gameTime, "darkthought_spawned" + count.ToString(), this, waypoints);
                    darkThought.onDie += new DarkThought.PowerupReleaseHandle(ReleasePowerup);
                    darkThought.position.X = 100.0f;
                    darkThought.position.Y = 100.0f;
                    while (addEntity(darkThought) == false)
                    {
                        count++;
                        darkThought.Alias = "darkthought" + count.ToString();
                    }
                }

                if (spawnEnemies.Four == true)
                {
                    int count = EntityCount(EntityType.DARK_WHISPER);
                    DarkWhisper darkWhisper = new DarkWhisper(spriteBatch, game, audioManager, "dark_whisper_spawned" + count.ToString(), this, null);
                    darkWhisper.onDie += new DarkWhisper.PowerupReleaseHandle(ReleasePowerup);
                    darkWhisper.position.X = 200.0f;
                    darkWhisper.position.Y = 200.0f;
                    while (addEntity(darkWhisper) == false)
                    {
                        count++;
                        darkWhisper.Alias = "dark_whisper_spawned" + count.ToString();
                    }
                }

                if (spawnEnemies.Five == true)
                {
                    int count = EntityCount(EntityType.INNER_DEMON);
                    Vector2 waypoint = new Vector2(100.0f, game.Window.ClientBounds.Center.Y);
                    Path waypoints = new Path(waypoint);
                    waypoint = new Vector2(200.0f, 200.0f);
                    waypoints.AddPath(waypoint);
                    waypoint = new Vector2(1000.0f, 600.0f);
                    waypoints.AddPath(waypoint);
                    InnerDemon innerDemon = new InnerDemon(spriteBatch, game, audioManager, "inner_demon_spawned" + count.ToString(), this, waypoints);
                    innerDemon.onDie += new InnerDemon.PowerupReleaseHandle(ReleasePowerup);
                    innerDemon.position.X = 200.0f;
                    innerDemon.position.Y = 200.0f;
                    while (addEntity(innerDemon) == false)
                    {
                        count++;
                        innerDemon.Alias = "inner_demon_spawned" + count.ToString();
                    }
                }
                #endregion spawn_enemies_dev
            }
        }