Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/adm/src/world_entities/npcs/adm_turret.cc @ 10663

Last change on this file since 10663 was 10663, checked in by retolu, 17 years ago

My work so far concerning Auto Defense Mechanism (Turret)

File size: 3.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: Reto Luechinger
13*/
14
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17#include "adm_turret.h"
18#include "weapon_manager.h"
19#include "lib/util/loading/factory.h"
20#include "world_entities/projectiles/projectile.h"
21
22
23ObjectListDefinition(AdmTurret);
24CREATE_FACTORY(AdmTurret);
25
26public:
27       
28/**
29*  Standard constructor
30*/
31AdmTurret::AdmTurret ()
32{
33          this->init();
34}
35
36       
37/**
38*  destructs the turret, deletes allocated memory
39*/
40AdmTurret::~AdmTurret ()
41{
42          // will be deleted
43}
44
45AdmTurret::AdmTurret (const  TiXmlElemet* root)
46{
47             this->init();
48             if (root != NULL)
49                 this->loadParams(root);
50}
51       
52void AdmTurret::init()
53{
54     this->registerObject(this, GroundTurret::_objectList);
55     
56     // load the 3 parts of the turret
57     // this-> loadModel ("...", , )
58     // this-> loadModel ("...", , )
59     // this-> loadModel ("...", , )
60     
61     
62     //Cannon Node: 2 Cannons fixed left and right of the main turret
63     this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT)
64     this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE)
65     this->cannonNode.setParent(this)
66     // this->cannonNode.setRelCoor( , , )
67     
68     
69     
70     //Sensor Node: Sensor rotating independently from main turret (like Radar)
71     this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT)
72     this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE)
73     this->sensorNode.setParent(this)
74     // this->sensorNode.setRelCoor( , , )
75     
76
77     this->setStateDuration(WS_SHOOTING, .1);
78     this->setStateDuration(WS_RELOADING, .1);
79         this->setStateDuration(WS_ACTIVATING, .4);
80         this->setStateDuration(WS_DEACTIVATING, .4);
81
82         this->setEnergyMax(10000);
83         this->increaseEnergy(10000);
84         //this->minCharge = ;
85       
86     //this->setActionSound(WA_SHOOT, "sounds/guns/xyz.wav");
87         //this->setActionSound(WA_ACTIVATE, "sounds/voices/xxyz.wav");
88
89         this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
90         this->setProjectileTypeC("Projectile");
91         // this->prepareProjectiles(10000);
92         
93     
94     // PROBLEM!! 2 emission Points!
95     // this->setEmissionPoint(Vector( , , ) );
96     
97     // initialise here
98}
99
100void AdmTurret::loadParams(const TiXmlElement* root)
101{
102        Weapon::loadParams(root);
103       
104        LoadParam(root, "target", this, GroundTurret, setTarget)
105}
106
107virtual void AdmTurret::tick(float dt);
108
109virtual void GroundTurret::draw() const;
110
111virtual void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location);
112
113virtual void AdmTurret::activate()
114{
115}
116       
117virtual void AdmTurret::deactivate()
118{       
119}
120
121virtual void AdmTurret::setTarget(const std::string& target)
122{
123        WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);
124        if (targetEntity != NULL) 
125        {
126            this->myTarget = targetEntity;
127        }
128        else
129        {
130            PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str());
131        }
132}
133           
134private:
135       
136bool AdmTurret::isVisible(const WorldEntity myTarget)
137{     
138}
139
140float AdmTurret::aim(const WorldEntity Target);
141
142void AdmTurret::fire()
143{
144     Projectile* pj =  this->getProjectile();
145     if (pj == NULL) return;
146     
147     //pj->setOwner(this->getOwner());
148         
149     //pj->setParent(PNode::getNullParent());
150
151         //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) );
152         
153         //pj->setAbsCoor(this->getEmissionPoint());
154         //pj->setAbsDir(this->getAbsDir());
155         //pj->activate();
156}       
Note: See TracBrowser for help on using the repository browser.