void ChestEntity::dropItem(enumItemType item) { ItemEntity* newItem = new ItemEntity(item, x, y); newItem->setVelocity(Vector2D(50.0f + rand()% 140)); if (newItem->getVelocity().y < 0.0f) newItem->setVelocity(Vector2D(newItem->getVelocity().x, -newItem->getVelocity().y)); newItem->setViscosity(0.96f); newItem->startsJumping(); }
void LargeSlimeEntity::dying() { isDying = true; game().addKilledEnemy(enemyType, hurtingType); if (slimeType == SlimeTypeBlue) game().addCorpse(x, y, FRAME_CORPSE_GIANT_SLIME_BLUE); else if (slimeType == SlimeTypeRed) game().addCorpse(x, y, FRAME_CORPSE_GIANT_SLIME_RED); else if (slimeType == SlimeTypeStandard) game().addCorpse(x, y, FRAME_CORPSE_GIANT_SLIME); float xSlime = x; float ySlime = y; if (x <= 1.5 * TILE_WIDTH) x = 1.5f * TILE_WIDTH + 2; else if (x >= TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH) x = TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH -3; if (y <= 1.5 * TILE_HEIGHT) y = 1.5 * TILE_HEIGHT + 2; else if (y >= TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT) y = TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT -3; for (int i = 0; i < 9; i++) { game().generateBlood(xSlime, ySlime, bloodColor); if (i % 2 == 0) { switch (slimeType) { case SlimeTypeBlue: new SlimeEntity(x, y, SlimeTypeBlue, true); break; case SlimeTypeRed: new SlimeEntity(x, y, SlimeTypeRed, true); break; case SlimeTypeViolet: new SlimeEntity(x, y, SlimeTypeViolet, true); break; default: new SlimeEntity(x, y, SlimeTypeStandard, true); break; } } } game().makeShake(1.0f); SoundManager::getInstance().playSound(SOUND_SLIME_SMASH); ItemEntity* newItem = new ItemEntity(ItemSilverCoin, x, y); newItem->setVelocity(Vector2D(100.0f + rand()% 250)); newItem->setViscosity(0.96f); SpriteEntity* star = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_GIANT_SLIME), x, y, 128, 128, 8); star->setFrame(4); star->setFading(true); star->setZ(y+ 100); star->setAge(-0.4f); star->setLifetime(0.3f); star->setType(ENTITY_EFFECT); star->setSpin(400.0f); }
void GiantSlimeEntity::dying() { isDying = true; game().addKilledEnemy(enemyType, hurtingType); game().addCorpse(x, y, FRAME_CORPSE_GIANT_SLIME); float xSlime = x; float ySlime = y; if (x <= 1.5 * TILE_WIDTH) x = 1.5f * TILE_WIDTH + 2; else if (x >= TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH) x = TILE_WIDTH * MAP_WIDTH - 1.5f * TILE_WIDTH -3; if (y <= 1.5 * TILE_HEIGHT) y = 1.5 * TILE_HEIGHT + 2; else if (y >= TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT) y = TILE_HEIGHT * MAP_HEIGHT - 1.5f * TILE_HEIGHT -3; for (int i = 0; i < 9; i++) { game().generateBlood(xSlime, ySlime, bloodColor); SlimeEntity* slime = new SlimeEntity(x, y, SlimeTypeStandard, true); slime->disableCollidingTemporary(); } game().makeShake(1.0f); SoundManager::getInstance().playSound(SOUND_SLIME_SMASH); ItemEntity* newItem = new ItemEntity(ItemBossHeart, x, y); newItem->setVelocity(Vector2D(100.0f + rand()% 250)); newItem->setViscosity(0.96f); SpriteEntity* star = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_GIANT_SLIME), x, y, 128, 128, 8); star->setFrame(4); star->setFading(true); star->setZ(y+ 100); star->setAge(-0.4f); star->setLifetime(0.3f); star->setType(ENTITY_EFFECT); star->setSpin(400.0f); }
void ChestEntity::open() { isOpen = true; if (chestType >= ChestFairy) SoundManager::getInstance().playSound(SOUND_GLASS); else SoundManager::getInstance().playSound(SOUND_CHEST_OPENING); if (chestType == ChestBasic) { int r = rand()% 50; if (r == 0 && !game().getPlayer()->isEquiped(EQUIP_FLOOR_MAP)) dropItem(ItemFloorMap); else if (r == 1 && !game().getPlayer()->isEquiped(EQUIP_ALCOHOL)) dropItem(ItemAlcohol); else if (r == 2 && !game().getPlayer()->isEquiped(EQUIP_LUCK)) dropItem(ItemLuck); else if (r == 3 && !game().getPlayer()->isEquiped(EQUIP_FAIRY_POWDER) && game().getPlayer()->getFairieNumber() > 0) dropItem(ItemFairyPowder); else if (r < 10) { // consumable if (rand() % 3 == 0) { // scroll dropItem(ItemScrollRevelation); } else { // potion dropItem((enumItemType)(ItemPotion01 + rand() % NUMBER_UNIDENTIFIED)); } } else { // gold int r = 2 + rand() % 6; if (game().getPlayer()->isEquiped(EQUIP_LUCK)) r += 1 + rand() % 5; for (int i = 0; i < r; i++) { dropItem(ItemCopperCoin); } } // trap ! if (game().getLevel() >= 2 && !game().getPlayer()->isEquiped(EQUIP_DISPLACEMENT_GLOVES)) { if (rand() % 5 == 0) // trap { SoundManager::getInstance().playSound(SOUND_TRAP); int r; // no "earthquake" trap in insel rooms if (game().getCurrentMap()->isWalkable(1, 1)) r = rand() % 3; else r = 1 + rand() % 2; if (r == 1) { timer = 1.0f; trap = TrapExplosion; } else if (r == 2) { timer = 1.0f; trap = TrapSnakes; } else { timer = 0.5f; trap = TrapStones; } } } } else if (chestType >= ChestFairy) { enumItemType itemType = ItemFairy; switch (chestType - ChestFairy) { case FamiliarFairy: itemType = ItemFairy; break; case FamiliarFairyIce: itemType = ItemFairyIce; break; case FamiliarFairyFire: itemType = ItemFairyFire; break; case FamiliarFairyTarget: itemType = ItemFairyTarget; break; case FamiliarFairyPoison: itemType = ItemFairyPoison; break; case FamiliarFairyStone: itemType = ItemFairyStone; break; } ItemEntity* newItem = new ItemEntity(itemType, x, y); newItem->setVelocity(Vector2D(50.0f + rand()% 150)); newItem->setViscosity(0.96f); } else if (chestType == ChestExit) { // Multiplayer bonus game().gainMultiplayerPower(); int r = rand() % 3; if (r == 0) { for (int i = 0; i < (game().getPlayer()->isEquiped(EQUIP_LUCK) ? 6 : 5); i++) { dropItem(ItemSilverCoin); } } else if (r == 1) { for (int i = 0; i < (game().getPlayer()->isEquiped(EQUIP_LUCK) ? 4 : 3); i++) { dropItem(ItemSilverCoin); } dropItem(ItemHealth); } else { int bonusType = game().getRandomEquipItem(false, true); if (game().getPlayer()->isEquiped(bonusType)) dropItem(ItemBonusHealth); else dropItem((enumItemType)(FirstEquipItem + bonusType)); } } else if (chestType == ChestChallenge) { game().generateChallengeBonus(x, y); } }
void ChestEntity::open() { isOpen = true; SoundManager::getInstance().playSound(SOUND_CHEST_OPENING); if (chestType == CHEST_BASIC) { int r = 2 + rand() % 6; for (int i = 0; i < r; i++) { ItemEntity* newItem = new ItemEntity(ItemCopperCoin, x, y); newItem->setVelocity(Vector2D(50.0f + rand()% 150)); newItem->setViscosity(0.96f); } // trap ! if (game().getLevel() >= 4) { if (rand() % 6 == 0) timer = 0.5f; } } else if (chestType >= CHEST_FAIRY) { enumItemType itemType = ItemFairy; switch (chestType - CHEST_FAIRY) { case FamiliarFairy: itemType = ItemFairy; break; case FamiliarFairyIce: itemType = ItemFairyIce; break; case FamiliarFairyFire: itemType = ItemFairyFire; break; case FamiliarFairyTarget: itemType = ItemFairyTarget; break; } ItemEntity* newItem = new ItemEntity(itemType, x, y); newItem->setVelocity(Vector2D(50.0f + rand()% 150)); newItem->setViscosity(0.96f); } else if (chestType == CHEST_EXIT) { int r = rand() % 3; if (r == 0) { for (int i = 0; i < 5; i++) { ItemEntity* newItem = new ItemEntity(ItemSilverCoin, x, y); newItem->setVelocity(Vector2D(90.0f + rand()% 150)); newItem->setViscosity(0.96f); } } else if (r == 1) { for (int i = 0; i < 3; i++) { ItemEntity* newItem = new ItemEntity(ItemSilverCoin, x, y); newItem->setVelocity(Vector2D(90.0f + rand()% 150)); newItem->setViscosity(0.96f); } ItemEntity* newItem = new ItemEntity(ItemHealth, x, y); newItem->setVelocity(Vector2D(90.0f + rand()% 150)); newItem->setViscosity(0.96f); } else { int bonusType = game().getRandomEquipItem(false, true); ItemEntity* newItem; if (game().getPlayer()->isEquiped(bonusType)) newItem = new ItemEntity( (enumItemType)(ItemBonusHealth), x ,y); else newItem = new ItemEntity( (enumItemType)(FirstEquipItem + bonusType), x ,y); newItem->setVelocity(Vector2D(90.0f + rand()% 150)); newItem->setViscosity(0.96f); } } }