Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.cc @ 10606

Last change on this file since 10606 was 10606, checked in by fvultier, 9 years ago

The most expensive tower fires now a new weapon: The Ice gun; a weapon that slows down a hit SpaceShip. This weapon may be used outside the tower defense minigame.

File size: 2.7 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 IceGunProjectile.cc
31    @brief Implementation of the IceGunProjectile class.
32*/
33
34#include "IceGunProjectile.h"
35
36#include "core/CoreIncludes.h"
37#include "graphics/Model.h"
38
39namespace orxonox
40{
41    RegisterClass(IceGunProjectile);
42
43    IceGunProjectile::IceGunProjectile(Context* context) : Projectile(context)
44    {
45        RegisterObject(IceGunProjectile);
46
47        this->setCollisionShapeRadius(8.0f);
48
49        this->setFreezeTime(3.0);
50        this->setFreezeFactor(0.5);
51
52        Model* model = new Model(this->getContext());
53        model->setMeshSource("IceBolt.mesh");
54        model->setScale(15.0);
55        this->attach(model);
56        model->setPosition(Vector3(0,0,0));
57    }
58
59    /**
60    @brief
61        Sets the freeze time variable to the passed value.
62    */
63    void IceGunProjectile::setFreezeTime(float freezeTime)
64    {
65        freezeTime_ = freezeTime;
66    }
67
68    /**
69    @brief
70        Sets the freeze factor variable to the passed value.
71    */
72    void IceGunProjectile::setFreezeFactor(float freezeFactor)
73    {
74        freezeFactor_ = freezeFactor;
75    }
76
77    bool IceGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
78    {
79        bool bCollision = Projectile::collidesAgainst(otherObject, cs, contactPoint);
80
81        if (bCollision)
82        {
83            IceGunFreezer* freezer = new IceGunFreezer(this->getContext());
84            freezer->setFreezeTime(freezeTime_);
85            freezer->setFreezeFactor(freezeFactor_);
86            otherObject->attach(freezer);           
87
88            Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition();
89            freezer->setPosition(Vector3(0,0,0));
90            freezer->translate(offset, WorldEntity::World);
91            freezer->startFreezing();
92        }
93
94        return bCollision;
95    }
96}
Note: See TracBrowser for help on using the repository browser.