#include "OrxoBloxWall.h" #include "core/CoreIncludes.h" #include "core/XMLPort.h" #include "OrxoBlox.h" #include "OrxoBloxStones.h" #include "OrxoBloxCenterpoint.h" #include "util/Math.h" namespace orxonox { RegisterClass(OrxoBloxWall); /** @brief Constructor. Registers and initializes the object. */ OrxoBloxWall::OrxoBloxWall(Context* context) : StaticEntity(context) { RegisterObject(OrxoBloxWall); this->num_Stones_ = 10; this->size_ = 9.0f; this->delay_ = false; this->orxoblox_ = this->getOrxoBlox(); this->center_ = this->orxoblox_->getCenterpoint(); this->createWall(); } void OrxoBloxWall::createWall(){ for (unsigned int i=0; inum_Stones_;++i){ unsigned int j=1 + static_cast(rnd(2.0f)); //size_ = 9.0f; OrxoBloxStones* stone = new OrxoBloxStones(this->center_->getContext()); if (stone == nullptr) { std::abort(); } this->TotalStones_.push_back(stone); this->attach(stone); float x_=(this->center_->getFieldDimension()).x; float y_=(this->center_->getFieldDimension()).y; stone->setPosition(size_*i -x_/2 +4.5f, -3.5f, -y_/2 + 6.5f); if(this->orxoblox_ != nullptr) { stone->setGame(this->orxoblox_); if(this->orxoblox_->getCenterpoint() != nullptr) stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate()); else orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl; } else orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl; } } this->num_Stones_ = TotalStones_.size(); // OrxoBloxStones* stone = new OrxoBloxStones(this->getContext()); // if(this->orxoblox_ != nullptr) // { // stone->setGame(this->orxoblox_); // if(this->orxoblox_->getCenterpoint() != nullptr) // stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate()); // else // orxout()<< "orxoblox_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl; // } // else // orxout()<< "orxoblox_ == nullptr in TetrisBrick.cc"<< endl; } OrxoBloxStones* OrxoBloxWall::getStone(unsigned int i) { if(i < this->TotalStones_.size()) return this->TotalStones_[i]; else return nullptr; } OrxoBlox* OrxoBloxWall::getOrxoBlox() { if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox))) { OrxoBlox* orxobloxGametype = orxonox_cast(this->getGametype()); return orxobloxGametype; } else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl; return nullptr; } int OrxoBloxWall::getNumberOfStones() { return num_Stones_; } void OrxoBloxWall::setNumberOfStones(int number) { this->num_Stones_ = number; } bool OrxoBloxWall::isEmpty() { if (num_Stones_ == 0) { return true; } return false; } void OrxoBloxWall::reduceNumberOfStones() { if(num_Stones_ == 0) { orxout() << "Wanted to reduce number of stones, but there were none" << endl; } this->num_Stones_ -= 1; } }