Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc @ 12331

Last change on this file since 12331 was 12331, checked in by ahuwyler, 5 years ago

Walls are bigger

File size: 2.6 KB
Line 
1#include "OrxoBloxWall.h"
2#include "core/CoreIncludes.h"
3#include "core/XMLPort.h"
4
5#include "OrxoBlox.h"
6#include "OrxoBloxStones.h"
7#include "OrxoBloxCenterpoint.h"
8#include "util/Math.h"
9
10namespace orxonox
11{
12    RegisterClass(OrxoBloxWall);
13    /**
14    @brief
15        Constructor. Registers and initializes the object.
16    */
17    OrxoBloxWall::OrxoBloxWall(Context* context) : StaticEntity(context)
18    {
19        RegisterObject(OrxoBloxWall);
20
21        this->num_Stones_ = 1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7;
22        this->delay_ = false;
23        this->orxoblox_ = this->getOrxoBlox();
24        this->createWall();
25    }
26
27
28    void OrxoBloxWall::createWall(void){
29
30        for (unsigned int i=0; i<this->num_Stones_;++i){
31            OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
32
33
34            this->TotalStones_.push_back(stone);
35            this->attach(stone);
36           
37            stone->setPosition(0.0f, i, 0.0f);
38
39
40
41            if(this->orxoblox_ != nullptr)
42            {
43                stone->setGame(this->orxoblox_);
44                if(this->orxoblox_->getCenterpoint() != nullptr)
45                    stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
46                else
47                    orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
48            }
49            else
50                orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
51
52        }
53
54
55
56        // OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
57        // if(this->orxoblox_ != nullptr)
58        //     {
59        //         stone->setGame(this->orxoblox_);
60        //         if(this->orxoblox_->getCenterpoint() != nullptr)
61        //             stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
62        //         else
63        //             orxout()<< "orxoblox_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
64        //     }
65        //     else
66        //         orxout()<< "orxoblox_ == nullptr in TetrisBrick.cc"<< endl;
67    }
68
69    OrxoBloxStones* OrxoBloxWall::getStone(unsigned int i)
70    {
71        if(i < this->TotalStones_.size())
72            return this->TotalStones_[i];
73        else return nullptr;
74    }
75
76    OrxoBlox* OrxoBloxWall::getOrxoBlox()
77    {
78        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
79        {
80            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
81            return orxobloxGametype;
82        }
83        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
84        return nullptr;
85    }
86}
Note: See TracBrowser for help on using the repository browser.