add timer on noclipBonus

This commit is contained in:
Askou
2021-06-15 09:25:26 +02:00
parent be48b46b7a
commit 8126d4a7e4
4 changed files with 11 additions and 7 deletions
@@ -24,8 +24,10 @@ namespace BBM
std::chrono::nanoseconds rangeBonusRate = 10s;
//! @brief The number of nanosecond before the expiration of a range bonus.
std::chrono::nanoseconds nextRangeBonusRate = rangeBonusRate;
//! @brief Tell if the bonus no clip is on
bool isNoClipOn = false;
//! @brief The number of seconds before a range bonus expire. This variable is used to reset the nextRangeBonusRate value.
std::chrono::nanoseconds noClipBonusRate = 10s;
//! @brief The number of nanosecond before the expiration of a range bonus.
std::chrono::nanoseconds nextNoClipRate = noClipBonusRate;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
+2 -4
View File
@@ -52,9 +52,7 @@ namespace BBM {
auto *playerBonus = player.tryGetComponent<PlayerBonusComponent>();
if (!playerBonus)
return;
static void SpeedUSpeedUpBonuspBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis);
static void SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis);
playerBonus->isNoClipOn = true
playerBonus->nextNoClipRate = playerBonus->nextSpeedBonusRate;
}
Bonus::BonusType Bonus::getRandomBonusType()
@@ -62,7 +60,7 @@ namespace BBM {
double rnd = static_cast<double>(std::rand()) / RAND_MAX;
if (rnd < 0.8)
return (static_cast<BonusType>(std::rand() % (EXPLOSIONINC - 1) + 1));
return (static_cast<BonusType>(std::rand() % (NOCLIP - 1) + 1));
return (NOTHING);
}
}
+2 -1
View File
@@ -12,6 +12,7 @@
#include "Component/Movable/MovableComponent.hpp"
#include <Component/Timer/TimerComponent.hpp>
#include <Component/Tag/TagComponent.hpp>
#include <Component/P/TagComponent.hpp>
namespace RAY3D = RAY::Drawables::Drawables3D;
using namespace std::chrono_literals;
@@ -23,7 +24,7 @@ namespace BBM
CollisionComponent::CollidedAxis collidedAxis)
{
auto *mov = entity.tryGetComponent<MovableComponent>();
auto *playerBonus = entity.tryGetComponent<Pl
if (!mov)
return;
if (collidedAxis & CollisionComponent::CollidedAxis::X)
@@ -28,5 +28,8 @@ namespace BBM
playerBonus.nextRangeBonusRate = playerBonus.rangeBonusRate;
holder.explosionRadius = 3;
}
playerBonus.nextNoClipRate -= dtime;
if (playerBonus.nextNoClipRate <= 0ns)
playerBonus.nextNoClipRate = playerBonus.noClipBonusRate;
}
}