Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoKart_HS18/src/modules/orxokart/OrxoKartFlag.cc @ 12128

Last change on this file since 12128 was 12108, checked in by ottka, 6 years ago

implement simple respawn

File size: 3.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Manuel Meier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file OrxoKartFlag.cc
31    @brief The Flags that are being set in the OrxoKart Minigame They support two coordinates from 0-9 each
32*/
33
34#include "OrxoKartFlag.h"
35#include "OrxoKartKart.h"
36
37#include "core/CoreIncludes.h"
38
39#include "graphics/Model.h"
40#include "objects/collisionshapes/BoxCollisionShape.h"
41#include "core/XMLPort.h"
42
43namespace orxonox
44{
45    RegisterClass(OrxoKartFlag);
46
47    OrxoKartFlag::OrxoKartFlag(Context* context) : StaticEntity(context)
48    {
49        RegisterObject(OrxoKartFlag);
50
51        this->model_ = nullptr;
52        this->cs_ = nullptr;
53        this->collided_ = false;
54        this->kartCollider = nullptr;
55
56        this->enableCollisionCallback();
57        this->setCollisionResponse(true);
58        this->setCollisionType(CollisionType::Static);
59    }
60
61    /**
62    @brief
63        Destructor.
64    */
65    OrxoKartFlag::~OrxoKartFlag()
66    {
67        if (this->isInitialized())
68        {
69            if (this->model_)
70                this->model_->destroy();
71            if (this->cs_)
72                this->cs_->destroy();
73        }
74    }
75
76    /**
77    @brief
78        Initializes the flag.
79    @param xCoordinate
80        X-Coordinate of the flage, 0-9, origin is bottom left
81    @param yCoordinate
82        Y-Coordinate of the flage, 0-9, origin is bottom left
83    @param cellSize
84        The size of the cells
85    */
86    void OrxoKartFlag::init(int n, int s)
87    {
88        /*model_ = new Model(this->getContext());
89        model_->setMeshSource("OrxoKartStreckenabschnitt.mesh");
90        model_->setScale3D(Vector3(s*n*2, 1, s*n*2));
91        model_->setPosition(Vector3(s*n*0.5f,-60.0f, s*n*0.5f));
92
93        this->attach(model_);*/
94
95        cs_ = new BoxCollisionShape(this->getContext());
96        cs_->setHalfExtents(Vector3(s*n, 1, s*n));
97        cs_->setPosition(Vector3(s*n*0.5f,-60.0f, s*n*0.5f));
98
99        this->attachCollisionShape(cs_);
100    }
101
102    /**
103    @brief
104        Checks if the OrxoKartship collided with the flag
105    */
106    bool OrxoKartFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
107    {
108        if(otherObject->isA(Class(OrxoKartKart))) {
109            collided_ = true;
110            kartCollider = (OrxoKartKart*) otherObject;
111        }
112
113        return false;
114    }
115}
Note: See TracBrowser for help on using the repository browser.