mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-20 13:25:10 +00:00
added a bandage to a huge wound (collisionsystem wasn't calling the two callbacks, just one, now it's still only one, but the bonuses are applied only if you're on them
This commit is contained in:
@@ -12,35 +12,35 @@
|
||||
namespace BBM {
|
||||
void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
{
|
||||
if (bonus.shouldDelete())
|
||||
if (bonus.shouldDelete() || axis != 7)
|
||||
return;
|
||||
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
||||
if (bombHolder == nullptr)
|
||||
if (!bombHolder)
|
||||
return;
|
||||
bombHolder->maxBombCount++;
|
||||
}
|
||||
|
||||
void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
{
|
||||
static int test = 0;
|
||||
if (bonus.shouldDelete())
|
||||
if (bonus.shouldDelete() || axis != 7)
|
||||
return;
|
||||
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||
if (bombHolder == nullptr || playerBonus == nullptr)
|
||||
if (!bombHolder || !playerBonus)
|
||||
return;
|
||||
if (bombHolder->explosionRadius <= 6)
|
||||
bombHolder->explosionRadius++;
|
||||
std::cout << ++test << " Explosion radius : " << bombHolder->explosionRadius << std::endl;
|
||||
playerBonus->nextRangeBonusRate = playerBonus->rangeBonusRate;
|
||||
}
|
||||
|
||||
void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
{
|
||||
if (bonus.shouldDelete())
|
||||
if (bonus.shouldDelete() || axis != 7)
|
||||
return;
|
||||
auto *controllable = player.tryGetComponent<ControllableComponent>();
|
||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||
if (!controllable || !playerBonus)
|
||||
return;
|
||||
controllable->speed = 0.35f;
|
||||
playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace BBM {
|
||||
double rnd = static_cast<double>(std::rand()) / RAND_MAX;
|
||||
|
||||
if (rnd < 0.8)
|
||||
return (static_cast<BonusType>(std::rand() % (DAMAGEINC - 1) + 1));
|
||||
return (static_cast<BonusType>(std::rand() % (EXPLOSIONINC - 1) + 1));
|
||||
return (NOTHING);
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,7 @@ namespace BBM {
|
||||
NOTHING,
|
||||
BOMBSTOCK,
|
||||
SPEEDUP,
|
||||
EXPLOSIONINC,
|
||||
DAMAGEINC
|
||||
EXPLOSIONINC
|
||||
};
|
||||
|
||||
static BonusType getRandomBonusType();
|
||||
|
||||
@@ -21,10 +21,6 @@ namespace BBM
|
||||
const WAL::Entity &wall,
|
||||
CollisionComponent::CollidedAxis collidedAxis)
|
||||
{
|
||||
auto name = entity.getName();
|
||||
if (name == "Unbreakable Wall" || name == "Breakable Block") {
|
||||
name = "salut";
|
||||
}
|
||||
auto *mov = entity.tryGetComponent<MovableComponent>();
|
||||
|
||||
if (!mov)
|
||||
|
||||
Reference in New Issue
Block a user