コード例 #1
0
ファイル: LootManager.cpp プロジェクト: dorkster/flare-engine
void LootManager::addLoot(ItemStack stack, const FPoint& pos, bool dropped_by_hero) {
	if (static_cast<size_t>(stack.item) >= items->items.size()) {
		Utils::logError("LootManager: Loot item with id %d is not valid.", stack.item);
		return;
	}

	Loot ld;
	ld.stack = stack;
	ld.pos.x = pos.x;
	ld.pos.y = pos.y;
	ld.pos.align(); // prevent "rounding jitter"
	ld.dropped_by_hero = dropped_by_hero;

	if (!items->items[stack.item].loot_animation.empty()) {
		size_t index = items->items[stack.item].loot_animation.size()-1;

		for (unsigned int i=0; i<items->items[stack.item].loot_animation.size(); i++) {
			int low = items->items[stack.item].loot_animation[i].low;
			int high = items->items[stack.item].loot_animation[i].high;
			if (stack.quantity >= low && (stack.quantity <= high || high == 0)) {
				index = i;
				break;
			}
		}
		ld.loadAnimation(items->items[stack.item].loot_animation[index].name);
	}
	else {
		// immediately place the loot on the ground if there's no animation
		ld.on_ground = true;
	}

	loot.push_back(ld);
	snd->play(sfx_loot, snd->DEFAULT_CHANNEL, pos, false);
}
コード例 #2
0
void LootManager::addLoot(ItemStack stack, FPoint pos, bool dropped_by_hero) {
	// TODO: z-sort insert?
	Loot ld;
	ld.stack = stack;
	ld.pos.x = pos.x;
	ld.pos.y = pos.y;
	alignFPoint(&ld.pos);
	ld.dropped_by_hero = dropped_by_hero;

	int index = items->items[stack.item].loot_animation.size()-1;
	if (index >= 0) {
		for (unsigned int i=0; i<items->items[stack.item].loot_animation.size(); i++) {
			int low = items->items[stack.item].loot_animation[i].low;
			int high = items->items[stack.item].loot_animation[i].high;
			if (stack.quantity >= low && (stack.quantity <= high || high == 0)) {
				index = i;
				break;
			}
		}
		ld.loadAnimation(items->items[stack.item].loot_animation[index].name);
	}
	else {
		// immediately place the loot on the ground if there's no animation
		ld.on_ground = true;
	}

	loot.push_back(ld);
	snd->play(sfx_loot, GLOBAL_VIRTUAL_CHANNEL, pos, false);
}
コード例 #3
0
ファイル: LootManager.cpp プロジェクト: ambient/flare-game
void LootManager::addLoot(ItemStack stack, Point pos) {
	// TODO: z-sort insert?
	Loot ld;
	ld.stack = stack;
	ld.pos.x = pos.x;
	ld.pos.y = pos.y;

	const string anim_id = items->items[stack.item].loot_animation;
	const string animationname = "animations/loot/" + anim_id + ".txt";
	ld.loadAnimation(animationname);
	ld.currency = 0;
	loot.push_back(ld);
	playSfx(loot_flip);
}
コード例 #4
0
void LootManager::addLoot(ItemStack stack, Point pos) {
    // TODO: z-sort insert?
    Loot ld;
    ld.stack = stack;
    ld.pos.x = pos.x;
    ld.pos.y = pos.y;

    const string anim_id = items->items[stack.item].loot_animation;
    const string animationname = "animations/loot/" + anim_id + ".txt";
    ld.loadAnimation(animationname);
    ld.currency = 0;
    loot.push_back(ld);
    snd->play(sfx_loot, GLOBAL_VIRTUAL_CHANNEL, pos, false);
}
コード例 #5
0
ファイル: LootManager.cpp プロジェクト: ambient/flare-game
void LootManager::addCurrency(int count, Point pos) {
	Loot ld;
	ld.stack.item = 0;
	ld.stack.quantity = 0;
	ld.pos.x = pos.x;
	ld.pos.y = pos.y;

	int index = currency_range.size()-1;
	for (unsigned int i=0; i<currency_range.size(); i++) {
		if (count >= currency_range[i].low && (count <= currency_range[i].high || currency_range[i].high == -1)) {
			index = i;
			break;
		}
	}
	const string anim_id = currency_range[index].filename;
	const string animationname = "animations/loot/" + anim_id + ".txt";
	ld.loadAnimation(animationname);

	ld.currency = count;
	loot.push_back(ld);
	playSfx(loot_flip);
}