Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

jetzt mehrere Bloecke

File size: 2.7 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_ = 2;//1 + static_cast<unsigned int>(rnd(6.0f)); //<! random number between 0 and 7;
22        this->size_ = 10.0f;
23        this->delay_ = false;
24        this->orxoblox_ = this->getOrxoBlox();
25        this->createWall();
26    }
27
28
29    void OrxoBloxWall::createWall(void){
30        orxout() <<"Hello idiot"<< endl;
31        for (unsigned int i=0; i<this->num_Stones_;++i){
32            orxout() <<i<< endl;
33            OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
34            this->TotalStones_.push_back(stone);
35            this->attach(stone);
36            stone->setPosition(size_*i, 0, 0.0f);
37
38
39
40            if(this->orxoblox_ != nullptr)
41            {
42                stone->setGame(this->orxoblox_);
43                if(this->orxoblox_->getCenterpoint() != nullptr)
44                    stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
45                else
46                    orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
47            }
48            else
49                orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
50
51        }
52
53
54
55        // OrxoBloxStones* stone = new OrxoBloxStones(this->getContext());
56        // if(this->orxoblox_ != nullptr)
57        //     {
58        //         stone->setGame(this->orxoblox_);
59        //         if(this->orxoblox_->getCenterpoint() != nullptr)
60        //             stone->addTemplate(this->orxoblox_->getCenterpoint()->getStoneTemplate());
61        //         else
62        //             orxout()<< "orxoblox_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
63        //     }
64        //     else
65        //         orxout()<< "orxoblox_ == nullptr in TetrisBrick.cc"<< endl;
66    }
67
68    OrxoBloxStones* OrxoBloxWall::getStone(unsigned int i)
69    {
70        if(i < this->TotalStones_.size())
71            return this->TotalStones_[i];
72        else return nullptr;
73    }
74
75    OrxoBlox* OrxoBloxWall::getOrxoBlox()
76    {
77        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
78        {
79            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
80            return orxobloxGametype;
81        }
82        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
83        return nullptr;
84    }
85}
Note: See TracBrowser for help on using the repository browser.