Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/weapons/projectiles/IceGunProjectile.cc @ 10817

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

Merged towerdefenseFabien branch back to trunk. The towerdefense Minigame is now a plugin.

File size: 2.9 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            // If there was a collision, attach a IceGunFreezer to the hit object.
84            IceGunFreezer* freezer = new IceGunFreezer(this->getContext());
85            freezer->setFreezeTime(freezeTime_);
86            freezer->setFreezeFactor(freezeFactor_);
87            otherObject->attach(freezer);           
88
89            Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition();
90            freezer->setPosition(Vector3(0,0,0));
91            freezer->translate(offset, WorldEntity::World);
92            // Start the freezing effect.
93            freezer->startFreezing();
94        }
95
96        return bCollision;
97    }
98}
Note: See TracBrowser for help on using the repository browser.