Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/world_entities/weapons/laser_cannon.cc @ 10675

Last change on this file since 10675 was 9235, checked in by bensch, 18 years ago

merged the presentation back

File size: 2.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific
12   main-programmer: Patrick Boenzli
13   co-programmer:
14
15
16   @todo: direction in which the projectile flights
17   @todo: a target to set/hit
18*/
19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
20
21#include "laser_cannon.h"
22#include "world_entities/projectiles/projectile.h"
23
24#include "world_entity.h"
25#include "static_model.h"
26#include "weapon_manager.h"
27#include "util/loading/factory.h"
28
29#include "animation3d.h"
30
31#include "fast_factory.h"
32
33CREATE_FACTORY(LaserCannon, CL_LASER_CANNON);
34
35
36LaserCannon::LaserCannon(const TiXmlElement* root)
37{
38  this->init();
39  if (root != NULL)
40    this->loadParams(root);
41}
42
43/**
44 *  standard deconstructor
45*/
46LaserCannon::~LaserCannon ()
47{
48  // model will be deleted from WorldEntity-destructor
49}
50
51
52void LaserCannon::init()
53{
54  this->setClassID(CL_LASER_CANNON, "LaserCannon");
55
56//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
57
58  this->loadModel("models/guns/lasercannon.obj", 5.0f);
59
60  this->setStateDuration(WS_SHOOTING, .1);
61  this->setStateDuration(WS_RELOADING, .1);
62  this->setStateDuration(WS_ACTIVATING, .4);
63  this->setStateDuration(WS_DEACTIVATING, .4);
64
65  this->setEnergyMax(10000);
66  this->increaseEnergy(10000);
67  //this->minCharge = 2;
68
69  this->setActionSound(WA_SHOOT, "sound/laser.wav");
70  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
71
72
73  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
74  this->setProjectileType(CL_RAIL_PROJECTILE);
75  this->prepareProjectiles(100);
76  this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
77}
78
79
80void LaserCannon::loadParams(const TiXmlElement* root)
81{
82  Weapon::loadParams(root);
83
84}
85
86
87/**
88 *  this activates the weapon
89
90   This is needed, since there can be more than one weapon on a ship. the
91   activation can be connected with an animation. for example the weapon is
92   been armed out.
93*/
94void LaserCannon::activate()
95{
96}
97
98
99/**
100 *  this deactivates the weapon
101
102   This is needed, since there can be more than one weapon on a ship. the
103   activation can be connected with an animation. for example the weapon is
104   been armed out.
105*/
106void LaserCannon::deactivate()
107{
108}
109
110
111/**
112 *  fires the weapon
113
114   this is called from the player.cc, when fire-button is been pushed
115   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
116*/
117void LaserCannon::fire()
118{
119  Projectile* pj =  this->getProjectile();
120  if (pj == NULL)
121    return;
122
123  pj->setParent(PNode::getNullParent());
124
125  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
126
127  pj->setAbsCoor(this->getEmissionPoint());
128  pj->setAbsDir(this->getAbsDir());
129  pj->activate();
130}
Note: See TracBrowser for help on using the repository browser.