game/mario/visitors/visitor_generator.cpp

36 lines
1.2 KiB
C++
Raw Normal View History

#include "visitor_generator.hpp"
#include "../objectids.hpp"
#include "mario_visitor.hpp"
2021-08-07 19:42:51 +00:00
#include "mushroom_visitor.hpp"
2021-08-08 19:45:05 +00:00
#include "goomba_visitor.hpp"
2022-09-25 17:44:28 +00:00
#include "../mario.hpp"
2021-10-18 08:10:43 +00:00
std::shared_ptr<SDLPP::Visitor>
2022-09-25 17:44:28 +00:00
getVisitor(const MarioBlock &block, SDLPP::Scene &scene,
2021-10-18 08:10:43 +00:00
int &coin_count,
std::vector<std::shared_ptr<MarioBlock>> &moving_objects) {
std::shared_ptr<SDLPP::Visitor> result{};
switch (block.getId()) {
case MARIO_ID:
2022-09-25 17:44:28 +00:00
{
auto &mario = dynamic_cast<const Mario &>(block);
result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MarioVisitor>(block.getMovement().getY() < 0,
scene, coin_count,
moving_objects, mario.isBig(), mario.hasStar()));
}
2021-10-18 08:10:43 +00:00
break;
case MUSHROOM_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MushroomVisitor>());
break;
case GOOMBA_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(
2022-09-25 17:44:28 +00:00
std::make_shared<GoombaVisitor>(block.getPos()));
2021-10-18 08:10:43 +00:00
break;
default:
break;
}
return result;
}