mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-30 17:18:00 +00:00
kill when no_clip ends in boxes
This commit is contained in:
@@ -62,21 +62,25 @@ namespace BBM {
|
||||
|
||||
Bonus::BonusType Bonus::getRandomBonusType()
|
||||
{
|
||||
return NOCLIP;
|
||||
static std::default_random_engine generator(time(nullptr));
|
||||
std::map<BonusType, float> chanceValue = {
|
||||
{NOTHING, 100.0f},
|
||||
{SPEEDUP, 45.0f},
|
||||
{BOMBSTOCK, 30.0f},
|
||||
{EXPLOSIONINC, 15.0f},
|
||||
{BOMBSTOCK, 46.5f},
|
||||
{SPEEDUP, 31.5f},
|
||||
{EXPLOSIONINC, 16.5f},
|
||||
{NOCLIP, 1.5f},
|
||||
};
|
||||
std::uniform_int_distribution<int> distribution(1,1000);
|
||||
float value = (distribution(generator) / 10);
|
||||
BonusType bonus = NOTHING;
|
||||
|
||||
std::cout << value << std::endl;
|
||||
for (auto &chance : chanceValue)
|
||||
if (chance.second > value)
|
||||
if (chance.second > value) {
|
||||
std::cout << value << "<" << chance.second << std::endl;
|
||||
bonus = chance.first;
|
||||
}
|
||||
return (bonus);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@
|
||||
//
|
||||
|
||||
#include "PlayerBonusSystem.hpp"
|
||||
#include "Component/Position/PositionComponent.hpp"
|
||||
#include "Component/Health//HealthComponent.hpp"
|
||||
#include "Component/Tag/TagComponent.hpp"
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -19,9 +23,20 @@ namespace BBM
|
||||
auto &playerBonus = entity.get<PlayerBonusComponent>();
|
||||
|
||||
playerBonus.nextNoClipRate -= dtime;
|
||||
if (playerBonus.nextNoClipRate <= 0ns) {
|
||||
if (playerBonus.nextNoClipRate <= 0ns && playerBonus.isNoClipOn) {
|
||||
playerBonus.nextNoClipRate = playerBonus.noClipBonusRate;
|
||||
playerBonus.isNoClipOn = false;
|
||||
auto playerPos = entity->tryGetComponent<PositionComponent>();
|
||||
auto playerHealth = entity->tryGetComponent<HealthComponent>();
|
||||
if (!playerHealth || !playerPos)
|
||||
return;
|
||||
for (auto &[other, pos, _] : this->_wal.getScene()->view<PositionComponent, CollisionComponent>()) {
|
||||
if (other.hasComponent<TagComponent<Player>>())
|
||||
continue;
|
||||
auto vec = playerPos->position.abs() - pos.position.abs();
|
||||
if (vec.abs().x < 0.65 && vec.abs().z < 0.65 && playerPos->position.distance(pos.position) < 1)
|
||||
playerHealth->takeDmg(playerHealth->getHealthPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user