Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hoverHS15/src/modules/hover/HoverFlag.cc @ 10930

Last change on this file since 10930 was 10930, checked in by meierman, 9 years ago

Finished with comments

File size: 3.5 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 HoverFlag.cc
31    @brief The Flags that are being set in the Hover Minigame They support two coordinates from 0-9 each
32*/
33
34#include "HoverFlag.h"
35#include "HoverShip.h"
36
37#include "core/CoreIncludes.h"
38#include "core/GameMode.h"
39#include "graphics/Model.h"
40#include "gametypes/Gametype.h"
41
42
43
44
45#include "core/XMLPort.h"
46
47namespace orxonox
48{
49    RegisterClass(HoverFlag);
50
51    HoverFlag::HoverFlag(Context* context) : StaticEntity(context)
52    {
53        RegisterObject(HoverFlag);
54        model_ = NULL;
55        cs_ = NULL;
56    }
57
58    /**
59    @brief
60        Constructor that expects two coordinate-values in the range 0-9
61    @param xCoordinate
62        X-Coordinate of the flage, 0-9, origin is bottom left
63    @param yCoordinate
64        Y-Coordinate of the flage, 0-9, origin is bottom left
65    */
66    HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate) : StaticEntity(context)
67    {
68        RegisterObject(HoverFlag);
69        enableCollisionCallback();
70        model_ = NULL;
71        cs_ = NULL;
72
73        model_ = new Model(context);
74        model_->setMeshSource("ss_flag_eu.mesh");
75        model_->setScale3D(Vector3(5, 5, 5));
76        model_->setPosition(Vector3(xCoordinate*100 + 50,10,yCoordinate*100 + 50));
77
78        this->attach(model_);
79
80        this->enableCollisionCallback();
81        this->setCollisionResponse(true);
82        this->setCollisionType(Static);
83
84        cs_ = new BoxCollisionShape(context);
85        cs_->setHalfExtents(Vector3(5, 5, 5));
86        cs_->setPosition(Vector3(xCoordinate*100 + 50,0,yCoordinate*100 + 50));
87
88        this->attachCollisionShape(cs_);
89        this->collided_ = false;
90
91    }
92
93    /**
94    @brief
95        Destructor.
96    */
97    HoverFlag::~HoverFlag()
98    {
99
100    }
101
102    //xml port unused
103    void HoverFlag::XMLPort(Element& xmlelement, XMLPort::Mode mode)
104    {
105        SUPER(HoverFlag, XMLPort, xmlelement, mode);
106    }
107
108
109
110
111    /**
112    @brief
113        Is called every tick.
114    @param dt
115        The time since the last tick.
116    */
117    void HoverFlag::tick(float dt)
118    {
119        SUPER(HoverFlag, tick, dt);
120       
121    }
122
123    /**
124    @brief
125        Checks if the Hovership collided with the flag
126    */
127    bool HoverFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
128    {
129        if(otherObject->isA(Class(HoverShip)))
130            collided_ = true;
131        return false;
132    }
133
134    bool HoverFlag::getCollided(){
135        return collided_;
136    }
137
138    void HoverFlag::setCollided(bool setValue){
139        collided_ = setValue;
140    }
141   
142   
143}
Note: See TracBrowser for help on using the repository browser.