Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Random Walls are created

File size: 2.8 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->size_ = 9.0f;
23        this->delay_ = false;
24        this->orxoblox_ = this->getOrxoBlox();
25        this->createWall();
26    }
27
28
29    void OrxoBloxWall::createWall(void){
30        for (unsigned int i=0; i<this->num_Stones_;++i){
31            unsigned int j=1 + static_cast<unsigned int>(rnd(2.0f)); //<! random number between 0 and 2;
32            if(j<2){
33                this->size_ = 9.0f;
34                OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
35                this->TotalStones_.push_back(stone);
36                this->attach(stone);
37                stone->setPosition(size_*i -55.5f, 0, 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
57        // OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
58        // if(this->orxoblox_ != nullptr)
59        //     {
60        //         stone->setGame(this->orxoblox_);
61        //         if(this->orxoblox_->getCenterpoint() != nullptr)
62        //             stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
63        //         else
64        //             orxout()<< "orxoblox_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
65        //     }
66        //     else
67        //         orxout()<< "orxoblox_ == nullptr in TetrisBrick.cc"<< endl;
68    }
69
70    OrxoBloxStones* OrxoBloxWall::getStone(unsigned int i)
71    {
72        if(i < this->TotalStones_.size())
73            return this->TotalStones_[i];
74        else return nullptr;
75    }
76
77    OrxoBlox* OrxoBloxWall::getOrxoBlox()
78    {
79        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
80        {
81            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
82            return orxobloxGametype;
83        }
84        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
85        return nullptr;
86    }
87}
Note: See TracBrowser for help on using the repository browser.