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 {
|
namespace BBM {
|
||||||
void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||||
{
|
{
|
||||||
if (bonus.shouldDelete())
|
if (bonus.shouldDelete() || axis != 7)
|
||||||
return;
|
return;
|
||||||
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
||||||
if (bombHolder == nullptr)
|
if (!bombHolder)
|
||||||
return;
|
return;
|
||||||
bombHolder->maxBombCount++;
|
bombHolder->maxBombCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||||
{
|
{
|
||||||
static int test = 0;
|
if (bonus.shouldDelete() || axis != 7)
|
||||||
if (bonus.shouldDelete())
|
|
||||||
return;
|
return;
|
||||||
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
auto *bombHolder = player.tryGetComponent<BombHolderComponent>();
|
||||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||||
if (bombHolder == nullptr || playerBonus == nullptr)
|
if (!bombHolder || !playerBonus)
|
||||||
return;
|
return;
|
||||||
if (bombHolder->explosionRadius <= 6)
|
if (bombHolder->explosionRadius <= 6)
|
||||||
bombHolder->explosionRadius++;
|
bombHolder->explosionRadius++;
|
||||||
std::cout << ++test << " Explosion radius : " << bombHolder->explosionRadius << std::endl;
|
|
||||||
playerBonus->nextRangeBonusRate = playerBonus->rangeBonusRate;
|
playerBonus->nextRangeBonusRate = playerBonus->rangeBonusRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||||
{
|
{
|
||||||
if (bonus.shouldDelete())
|
if (bonus.shouldDelete() || axis != 7)
|
||||||
return;
|
return;
|
||||||
auto *controllable = player.tryGetComponent<ControllableComponent>();
|
auto *controllable = player.tryGetComponent<ControllableComponent>();
|
||||||
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||||
|
if (!controllable || !playerBonus)
|
||||||
|
return;
|
||||||
controllable->speed = 0.35f;
|
controllable->speed = 0.35f;
|
||||||
playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate;
|
playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace BBM {
|
|||||||
double rnd = static_cast<double>(std::rand()) / RAND_MAX;
|
double rnd = static_cast<double>(std::rand()) / RAND_MAX;
|
||||||
|
|
||||||
if (rnd < 0.8)
|
if (rnd < 0.8)
|
||||||
return (static_cast<BonusType>(std::rand() % (DAMAGEINC - 1) + 1));
|
return (static_cast<BonusType>(std::rand() % (EXPLOSIONINC - 1) + 1));
|
||||||
return (NOTHING);
|
return (NOTHING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,7 @@ namespace BBM {
|
|||||||
NOTHING,
|
NOTHING,
|
||||||
BOMBSTOCK,
|
BOMBSTOCK,
|
||||||
SPEEDUP,
|
SPEEDUP,
|
||||||
EXPLOSIONINC,
|
EXPLOSIONINC
|
||||||
DAMAGEINC
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static BonusType getRandomBonusType();
|
static BonusType getRandomBonusType();
|
||||||
|
|||||||
@@ -21,10 +21,6 @@ namespace BBM
|
|||||||
const WAL::Entity &wall,
|
const WAL::Entity &wall,
|
||||||
CollisionComponent::CollidedAxis collidedAxis)
|
CollisionComponent::CollidedAxis collidedAxis)
|
||||||
{
|
{
|
||||||
auto name = entity.getName();
|
|
||||||
if (name == "Unbreakable Wall" || name == "Breakable Block") {
|
|
||||||
name = "salut";
|
|
||||||
}
|
|
||||||
auto *mov = entity.tryGetComponent<MovableComponent>();
|
auto *mov = entity.tryGetComponent<MovableComponent>();
|
||||||
|
|
||||||
if (!mov)
|
if (!mov)
|
||||||
|
|||||||
Reference in New Issue
Block a user