void BaseCreatureEntity::generateStar(sf::Color starColor)
{
  SpriteEntity* spriteStar = new SpriteEntity(
                           ImageManager::getInstance().getImage(IMAGE_STAR_2),
                            x, y);
  spriteStar->setScale(0.8f, 0.8f);
  spriteStar->setZ(z-1.0f);
  spriteStar->setLifetime(0.8f);
  spriteStar->setSpin(-100 + rand()%200);
  spriteStar->setVelocity(Vector2D(10 + rand()%40));
  spriteStar->setWeight(-150);
  spriteStar->setFading(true);
  spriteStar->setColor(starColor);
  spriteStar->setType(ENTITY_EFFECT);
}
Beispiel #2
0
void ChestEntity::generateStar(sf::Color starColor)
{
  SpriteEntity* spriteStar = new SpriteEntity(
                           ImageManager::getInstance().getImage(IMAGE_STAR_2),
                            x - 15 + rand() % 30, y - 10 + rand() % 30);
  spriteStar->setScale(0.8f, 0.8f);
  spriteStar->setZ(1000.0f);
  spriteStar->setSpin(-100 + rand()%200);
  spriteStar->setVelocity(Vector2D(50 + rand()%40));
  spriteStar->setWeight(-130);
  spriteStar->setFading(true);
  spriteStar->setAge(-0.8f);
  spriteStar->setLifetime(0.2f + (rand() % 100) * 0.005f );
  spriteStar->setColor(starColor);
  spriteStar->setType(ENTITY_EFFECT);
  spriteStar->setRenderAdd();
}
void CauldronEntity::animate(float delay)
{
  if (isAgonising)
  {
    agonizingDelay -= delay;
    if (agonizingDelay <= 0.0f)
    {
      isDying = true;
      game().addCorpse(x, y, deathFrame);
    }
  }
  else
  {
    SoundManager::getInstance().playSound(SOUND_CAULDRON, false);

    invokeDelay -= delay;
    if (invokeDelay < 0.0f)
    {
      if (cauldronType == CauldronTypeElemental)
      {
        if (game().getEnemyCount() < 9)
        {
          slimeTypeEnum slimeType = SlimeTypeStandard;
          switch (colorState)
          {
            case 0: slimeType = SlimeTypeBlue; break;
            case 1: slimeType = SlimeTypeRed; break;
            case 2: slimeType = SlimeTypeStandard; break;
          }
          SlimeEntity* slime = new SlimeEntity(x, y, slimeType, true);
          slime->disableCollidingTemporary();
          invokeDelay = 3.75f + (float)(rand() % 3000) / 1000.0f;
        }
      }
      else
      {
        SlimeEntity* slime = new SlimeEntity(x, y, SlimeTypeViolet, true);
        slime->disableCollidingTemporary();
        invokeDelay = 1.5f + (float)(rand() % 2500) / 1000.0f;
      }
    }

    if (cauldronType == CauldronTypeElemental)
    {
      colorChangeDelay -= delay;
      if (colorChangeDelay < 0.0f)
      {
        colorChangeDelay = 4.0f + rand()% 50 * 0.1f;
        if (rand() % 2 == 0)
        {
          colorState++;
          if (colorState > 2) colorState = 0;
        }
        else
        {
          colorState--;
          if (colorState < 0) colorState = 2;
        }
      }
    }

    bubbleDelay -= delay;
    if (bubbleDelay < 0.0f)
    {
      bubbleDelay = 0.3f;
      int bubbleFrame = 32;
      if (cauldronType == CauldronTypeElemental)
      {
        switch (colorState)
        {
          case 0: bubbleFrame = 33; break;
          case 1: bubbleFrame = 34; break;
          case 2: bubbleFrame = 35; break;
        }
      }

      for (int i=0; i < 2; i++)
      {
        float xBub = x - 16 + rand() % 32;
        SpriteEntity* bubble = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_CAULDRON), xBub, y - 20, 8, 8);
        bubble->setZ(z);
        bubble->setFrame(bubbleFrame);
        bubble->setType(ENTITY_EFFECT);
        bubble->setWeight(-20 - rand() % 40);
        bubble->setLifetime(2.0f);
        float bloodScale = 0.3f + (rand() % 20) * 0.1f;
        bubble->setScale(bloodScale, bloodScale);
      }
    }
    frame = hp > hpMax / 2 ? 0 : 1;
    if (cauldronType == CauldronTypeElemental)
    {
      switch (colorState)
      {
        case 0: frame += 2; break;
        case 1: frame += 4; break;
        case 2: frame += 6; break;
      }
    }

    EnemyEntity::animate(delay);
  }
}