Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.P))
        {
            HealthPowerup newHealthPowerup = new HealthPowerup();
            newHealthPowerup.amount     = 100;
            newHealthPowerup.data       = GetComponent <ShipData>();
            newHealthPowerup.isInfinite = true;
            powerupManager.AddPowerup(newHealthPowerup);
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            powerupManager.RemovePowerup(powerupManager.powerups[0]);
        }
    }
Пример #2
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++;
        }
Пример #3
0
 private void ReleasePowerup(Entity entity)
 {
     if (player != null && powerupsDisabled)
     {
         if (player.Health >= player.MaxHealth)
         {
             return;
         }
         else
         {
                 int value = random.Next(0, 100);
                 if (value >= 80)
                 {
                     HealthPowerup healthPowerup = new HealthPowerup(spriteBatch, game, "healthpowerUp" + powerupCount.ToString(), entity.position);
                     addEntity(healthPowerup);
                     powerupCount++;
                 }
          }
     }
 }