Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10894 was 10894, checked in by meierman, 8 years ago

Flag generator implemented

File size: 4.0 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 *      Fabien Vultier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file HoverFlag.cc
31    @brief All platforms in this minigame inherit from this class. The basic functions of a platform (interact with figure) is implemented here. Special functions are implemented in the specialized classes.
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    HoverFlag::HoverFlag(Context* context, int xCoordinate, int yCoordinate) : StaticEntity(context)
59    {
60        RegisterObject(HoverFlag);
61        enableCollisionCallback();
62        model_ = NULL;
63        cs_ = NULL;
64
65        model_ = new Model(context);
66        model_->setMeshSource("ss_flag_eu.mesh");
67        model_->setScale3D(Vector3(5, 5, 5));
68        model_->setPosition(Vector3(xCoordinate*100 + 50,10,yCoordinate*100 + 50));
69
70        this->attach(model_);
71
72        this->enableCollisionCallback();
73        this->setCollisionResponse(true);
74        this->setCollisionType(Static);
75
76        cs_ = new BoxCollisionShape(context);
77        cs_->setHalfExtents(Vector3(5, 5, 5));
78        cs_->setPosition(Vector3(xCoordinate*100 + 50,0,yCoordinate*100 + 50));
79
80        this->attachCollisionShape(cs_);
81        this->collided_ = false;
82
83    }
84
85    /**
86    @brief
87        Destructor.
88    */
89    HoverFlag::~HoverFlag()
90    {
91
92    }
93
94    //xml port for loading height and width of the platform
95    void HoverFlag::XMLPort(Element& xmlelement, XMLPort::Mode mode)
96    {
97        SUPER(HoverFlag, XMLPort, xmlelement, mode);
98
99       // XMLPortParam(HoverFlag, "height", setHeight, getHeight, xmlelement, mode);
100        //XMLPortParam(HoverFlag, "width", setWidth, getWidth, xmlelement, mode);
101    }
102
103
104
105
106    /**
107    @brief
108        Is called every tick.
109        Handles the movement of the ball and its interaction with the boundaries and bats.
110    @param dt
111        The time since the last tick.
112    */
113    void HoverFlag::tick(float dt)
114    {
115        SUPER(HoverFlag, tick, dt);
116       
117    }
118
119    bool HoverFlag::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
120    {
121       
122
123        if(otherObject->isA(Class(HoverShip))){
124
125            orxout()<<"TestCollision"<<endl;
126            collided_ = true;
127            //this->destroyLater();
128        }
129
130
131        /*if (GameMode::isMaster() && enableCollisionDamage_)
132        {
133            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
134            if (victim)
135            {
136                float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
137                victim->hit(0, contactPoint, ownCollisionShape, damage);
138            }
139        }*/
140
141        return false;
142    }
143
144    bool HoverFlag::getCollided(){
145        return collided_;
146    }
147
148    void HoverFlag::setCollided(bool setValue){
149        collided_ = setValue;
150    }
151   
152   
153}
Note: See TracBrowser for help on using the repository browser.