mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-02 02:05:25 +00:00
score system update scores
This commit is contained in:
@@ -5,7 +5,7 @@ namespace BBM
|
||||
{
|
||||
ScoreComponent::ScoreComponent(WAL::Entity &entity)
|
||||
: Component(entity),
|
||||
score(PLAYING)
|
||||
aliveTime(std::chrono::nanoseconds::zero())
|
||||
{}
|
||||
|
||||
WAL::Component *ScoreComponent::clone(WAL::Entity &entity) const
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Component/Component.hpp"
|
||||
#include <chrono>
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
@@ -9,10 +10,8 @@ namespace BBM
|
||||
class ScoreComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
//! @brief score of player (4 is the looser, 1 is the winner)
|
||||
enum Score {FIRST = 1, SECOND = 2, THIRD = 3, FOURTH = 4, PLAYING = -1};
|
||||
//! @brief the score of the player
|
||||
enum Score score;
|
||||
std::chrono::nanoseconds aliveTime;
|
||||
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
@@ -11,10 +11,9 @@ namespace BBM {
|
||||
: System(wal)
|
||||
{}
|
||||
|
||||
void ScoreSystem::onSelfUpdate()
|
||||
void ScoreSystem::onUpdate(WAL::ViewEntity<ScoreComponent, HealthComponent> &entity, std::chrono::nanoseconds dtime)
|
||||
{
|
||||
ScoreComponent::Score maxScore = ScoreComponent::Score::PLAYING;
|
||||
|
||||
for (auto &[_, score, _], this->_wal.getScene()->view<PositionComponent, CollisionComponent>())
|
||||
if (entity.get<HealthComponent>().getHealthPoint())
|
||||
entity.get<ScoreComponent>().aliveTime += dtime;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace BBM
|
||||
{
|
||||
public:
|
||||
//! @inherit
|
||||
void onFixedUpdate(WAL::ViewEntity<ScoreComponent, HealthComponent> &entity) override;
|
||||
void onUpdate(WAL::ViewEntity<ScoreComponent, HealthComponent> &entity, std::chrono::nanoseconds dtime) override;
|
||||
|
||||
//! @brief ctor
|
||||
ScoreSystem(WAL::Wal &wal);
|
||||
|
||||
Reference in New Issue
Block a user