示例#1
0
void LootManager::logic() {
	std::vector<Loot>::iterator it;
	for (it = loot.begin(); it != loot.end(); ++it) {

		// animate flying loot
		if (it->animation) {
			it->animation->advanceFrame();
			if (it->animation->isSecondLastFrame()) {
				it->on_ground = true;
			}
		}

		if (it->on_ground && !it->sound_played && !it->stack.empty()) {
			Point pos;
			pos.x = static_cast<int>(it->pos.x);
			pos.y = static_cast<int>(it->pos.y);
			items->playSound(it->stack.item, pos);
			it->sound_played = true;
		}
	}

	checkEnemiesForLoot();
	checkMapForLoot();

	// clear any tiles that were blocked from dropped loot
	for (unsigned i=0; i<tiles_to_unblock.size(); i++) {
		mapr->collider.unblock(static_cast<float>(tiles_to_unblock[i].x), static_cast<float>(tiles_to_unblock[i].y));
	}
	tiles_to_unblock.clear();
}
示例#2
0
void LootManager::logic() {
	int max_frame = anim_loot_frames * anim_loot_duration - 1;
	
	for (int i=0; i<loot_count; i++) {
	
		// animate flying loot
		if (loot[i].frame < max_frame)
			loot[i].frame++;

		if (loot[i].frame == max_frame-1) {
			if (loot[i].stack.item > 0)
				items->playSound(loot[i].stack.item);
			else
				items->playCoinsSound();
		}
	}
	
	checkEnemiesForLoot();
	checkMapForLoot();
}