Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc @ 10391

Last change on this file since 10391 was 10391, checked in by meggiman, 9 years ago

Implemented all necessary classes. No the weapon works without bugs.

File size: 1.2 KB
Line 
1/*
2 * GravityBombField.cc
3 *
4 *  Created on: Apr 2, 2015
5 *      Author: meggiman
6 */
7
8#include "GravityBombField.h"
9#include "graphics/Model.h"
10
11namespace orxonox{
12        RegisterClass(GravityBombField);
13
14        const float GravityBombField::FORCE_FIELD_LIFETIME = 100;
15        const float GravityBombField::FORCE_SPHERE_START_RADIUS = 500;
16        const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
17
18        GravityBombField::GravityBombField(Context* context) : ForceField(context)
19        {
20                RegisterObject(GravityBombField);
21                lifetime_=FORCE_FIELD_LIFETIME;
22                setVelocity(FORCE_SPHERE_START_STRENGTH);
23                setDiameter(FORCE_SPHERE_START_RADIUS);
24                setMode(modeInvertedSphere_s);
25                setCollisionResponse(false);
26
27                //Attach Demo Model for debuging.
28                        Model* model = new Model(this->getContext());
29                        model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
30                        model->scale(0.7f);
31                        this->attach(model);
32        }
33
34        GravityBombField::~GravityBombField(){}
35
36        void GravityBombField::tick(float dt)
37        {
38                SUPER(GravityBombField,tick,dt);
39                lifetime_-=dt;
40                if(lifetime_ < 0)
41                {
42                        orxout(debug_output) << "Timeout. Destroying field." << endl;
43                        this->destroy();
44                }
45        }
46
47        void GravityBombField::destroy()
48        {
49                //Animation
50                ForceField::destroy();
51        }
52
53}
Note: See TracBrowser for help on using the repository browser.