Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/laser_cannon.cc @ 9496

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

merged the presentation back

File size: 2.9 KB
RevLine 
[4592]1/*
[3618]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
[4592]13   co-programmer:
[3631]14
15
[4836]16   @todo: direction in which the projectile flights
17   @todo: a target to set/hit
[3618]18*/
[5357]19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
[3618]20
[9131]21#include "laser_cannon.h"
[6434]22#include "world_entities/projectiles/projectile.h"
[3618]23
24#include "world_entity.h"
[6022]25#include "static_model.h"
[4955]26#include "weapon_manager.h"
[7193]27#include "util/loading/factory.h"
[3618]28
[3851]29#include "animation3d.h"
[3618]30
[4940]31#include "fast_factory.h"
[4287]32
[9131]33CREATE_FACTORY(LaserCannon, CL_LASER_CANNON);
[3618]34
35
[9131]36LaserCannon::LaserCannon(const TiXmlElement* root)
[4972]37{
38  this->init();
[7084]39  if (root != NULL)
40    this->loadParams(root);
[4972]41}
42
43/**
44 *  standard deconstructor
45*/
[9131]46LaserCannon::~LaserCannon ()
[4972]47{
48  // model will be deleted from WorldEntity-destructor
49}
50
51
[9131]52void LaserCannon::init()
[4972]53{
[9131]54  this->setClassID(CL_LASER_CANNON, "LaserCannon");
[4972]55
[9131]56//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
[4972]57
[9159]58  this->loadModel("models/guns/lasercannon.obj", 5.0f);
[5053]59
[5457]60  this->setStateDuration(WS_SHOOTING, .1);
61  this->setStateDuration(WS_RELOADING, .1);
[4910]62  this->setStateDuration(WS_ACTIVATING, .4);
63  this->setStateDuration(WS_DEACTIVATING, .4);
[4885]64
[9002]65  this->setEnergyMax(10000);
66  this->increaseEnergy(10000);
[4927]67  //this->minCharge = 2;
[4885]68
[5819]69  this->setActionSound(WA_SHOOT, "sound/laser.wav");
70  this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav");
[4934]71
[5819]72
[5441]73  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[9167]74  this->setProjectileType(CL_RAIL_PROJECTILE);
[8983]75  this->prepareProjectiles(100);
[9159]76  this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
[3683]77}
[3618]78
79
[9131]80void LaserCannon::loadParams(const TiXmlElement* root)
[3618]81{
[6512]82  Weapon::loadParams(root);
[4972]83
[3618]84}
85
86
87/**
[4836]88 *  this activates the weapon
[3618]89
[4592]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.
[3618]93*/
[9131]94void LaserCannon::activate()
[3980]95{
96}
[3618]97
98
99/**
[4836]100 *  this deactivates the weapon
[3618]101
[4592]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
[3618]104   been armed out.
105*/
[9131]106void LaserCannon::deactivate()
[3980]107{
108}
[3618]109
110
111/**
[4836]112 *  fires the weapon
[4592]113
[3618]114   this is called from the player.cc, when fire-button is been pushed
[4836]115   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
[3618]116*/
[9131]117void LaserCannon::fire()
[3620]118{
[5356]119  Projectile* pj =  this->getProjectile();
120  if (pj == NULL)
121    return;
[3888]122
[6074]123  pj->setParent(PNode::getNullParent());
[5000]124
[6162]125  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
[4955]126
[4927]127  pj->setAbsCoor(this->getEmissionPoint());
[3708]128  pj->setAbsDir(this->getAbsDir());
[5443]129  pj->activate();
[3620]130}
Note: See TracBrowser for help on using the repository browser.