[1378] | 1 | #include "dxstdafx.h"
|
---|
| 2 | #include ".\goodie.h"
|
---|
| 3 | #include "GameScene.h"
|
---|
| 4 | #include "Terrain.h"
|
---|
| 5 | #include "SoundNode.h"
|
---|
| 6 | #include "UserContactReport.h"
|
---|
| 7 | #include <string>
|
---|
| 8 |
|
---|
| 9 | Goodie::Goodie(void) : Object3d(){
|
---|
| 10 | this->lifeTime = 0;
|
---|
| 11 | this->filename = "";
|
---|
| 12 | this->nodeType |= GameScene::NODE_GOODIE;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | Goodie::~Goodie(void) {
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | void Goodie::setGoodieType(int _type) {
|
---|
| 19 | this->goodieType = _type;
|
---|
| 20 | this->firstTime = true;
|
---|
| 21 | /*this->scheibe = this->sMgr->createFlaeche(*this);
|
---|
| 22 | this->scheibe->setPosition(0, -15, 0);
|
---|
| 23 | this->scheibe->setDimension(50, 50);
|
---|
| 24 | this->scheibe->setRotation(-90, 0, 0);
|
---|
| 25 | this->scheibe->setTextureName("./media/textures/goodieScheibe.bmp");*/
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | int Goodie::getGoodieType() {
|
---|
| 29 | return this->goodieType;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void Goodie::loadGoodieMesh()
|
---|
| 33 | {
|
---|
| 34 | std::string s;
|
---|
| 35 | if(this->filename.compare("")==0) {
|
---|
| 36 | switch(this->goodieType) {
|
---|
| 37 | case(Goodie::GOODIE_HEALTH):
|
---|
| 38 | this->loadMeshFromFile("./media/models/medipack.x");
|
---|
| 39 | break;
|
---|
| 40 | case(Goodie::GOODIE_WEAPON):
|
---|
| 41 | s="./media/models/waffe";
|
---|
| 42 | switch(this->weaponType) {
|
---|
| 43 | case 0: s+= "1.x"; break;
|
---|
| 44 | case 1: s+= "2.x"; break;
|
---|
| 45 | case 2: s+= "3.x"; break;
|
---|
| 46 | case 3: this->myScene->manager->printToConsole("Kein Modell für Flammenwerfer spezifiziert...verwende waff1!");
|
---|
| 47 | s="./media/models/waffe1.x";
|
---|
| 48 | break;
|
---|
| 49 | default: this->myScene->manager->printToConsole("If you use a weapontype > 3 you must specify a xfile!"); break;
|
---|
| 50 | }
|
---|
| 51 | this->loadMeshFromFile(s);
|
---|
| 52 | break;
|
---|
| 53 | case(Goodie::GOODIE_AMO):
|
---|
| 54 | s="./media/models/munpack";
|
---|
| 55 | switch(this->weaponType) {
|
---|
| 56 | case 0: s+= "1.x"; break;
|
---|
| 57 | case 1: s+= "2.x"; break;
|
---|
| 58 | case 2: s+= "3.x"; break;
|
---|
| 59 | case 3: this->myScene->manager->printToConsole("Kein Modell für Flammenwerfermunition spezifiziert...verwende munpack1!");
|
---|
| 60 | s="./media/models/munpack1.x";
|
---|
| 61 | break;
|
---|
| 62 | default: this->myScene->manager->printToConsole("If you use a amotype > 3 you must specify a xfile!"); break;
|
---|
| 63 | }
|
---|
| 64 | this->loadMeshFromFile(s);
|
---|
| 65 | break;
|
---|
| 66 | }
|
---|
| 67 | } else {
|
---|
| 68 | this->loadMeshFromFile(this->filename);
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | void Goodie::init()
|
---|
| 73 | {
|
---|
| 74 | if(this->pActor==NULL) {
|
---|
| 75 | NxSphereShapeDesc sphereDesc;
|
---|
| 76 | Vector dist = this->maxAABBox - this->minAABBox;
|
---|
| 77 | sphereDesc.radius = max(dist.x, max(dist.y, dist.z));
|
---|
| 78 |
|
---|
| 79 | this->pActorDesc.shapes.pushBack(&sphereDesc);
|
---|
| 80 | this->setBehaveAs(Node::KINEMATIC);
|
---|
| 81 | this->setColDetGroup(UserContactReport::COLGROUP_GOODIE);
|
---|
| 82 | } else {
|
---|
| 83 | this->setColDetGroup(UserContactReport::COLGROUP_GOODIE);
|
---|
| 84 | }
|
---|
| 85 | this->pActor->getShapes()[0]->setFlag(NX_SF_DISABLE_RAYCASTING, true);
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | void Goodie::setHealthAmount(float _healthAmount) {
|
---|
| 89 | this->healthAmount = _healthAmount;
|
---|
| 90 | /*if(this->filename.compare("")==0) {
|
---|
| 91 | this->loadMeshFromFile("./media/models/medipack.x");
|
---|
| 92 | } else {
|
---|
| 93 | this->loadMeshFromFile(this->filename);
|
---|
| 94 | }*/
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | void Goodie::setWeaponType(int _type) {
|
---|
| 98 | this->weaponType = _type;
|
---|
| 99 | /*if(this->envType == this->GOODIE_WEAPON) {
|
---|
| 100 | if(this->filename.compare("")==0) {
|
---|
| 101 | std::string s="./media/models/waffe";
|
---|
| 102 | switch(this->weaponType) {
|
---|
| 103 | case 0: s+= "1.x"; break;
|
---|
| 104 | case 1: s+= "2.x"; break;
|
---|
| 105 | case 2: s+= "3.x"; break;
|
---|
| 106 | }
|
---|
| 107 | //MessageBox(NULL,s.c_str(), "Wuermer DEBUG",MB_OK|MB_ICONQUESTION);
|
---|
| 108 | this->loadMeshFromFile(s);
|
---|
| 109 | } else {
|
---|
| 110 | this->loadMeshFromFile(this->filename);
|
---|
| 111 | }
|
---|
| 112 | }*/
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | void Goodie::setArmorAmount(int _armorAmount) {
|
---|
| 116 | this->armorAmount = _armorAmount;
|
---|
| 117 | /*if(this->envType == this->GOODIE_AMO) {
|
---|
| 118 | if(this->filename.compare("")==0) {
|
---|
| 119 | std::string s="./media/models/munpack";
|
---|
| 120 | switch(this->weaponType) {
|
---|
| 121 | case 0: s+= "1.x"; break;
|
---|
| 122 | case 1: s+= "2.x"; break;
|
---|
| 123 | case 2: s+= "3.x"; break;
|
---|
| 124 | }
|
---|
| 125 | //MessageBox(NULL,s.c_str(), "Wuermer DEBUG",MB_OK|MB_ICONQUESTION);
|
---|
| 126 | this->loadMeshFromFile(s);
|
---|
| 127 | } else {
|
---|
| 128 | this->loadMeshFromFile(this->filename);
|
---|
| 129 | }
|
---|
| 130 | }*/
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | void Goodie::update(float dt) {
|
---|
| 134 | this->yPos = ((GameScene *) this->myScene)->getTerrainHeight(this->myPosition)+1;//getTerrain()->getHeight(this->myPosition.x, this->myPosition.z)+1;
|
---|
| 135 | if(this->firstTime) {
|
---|
| 136 | SoundNode *boom;
|
---|
| 137 | boom = (SoundNode *) this->myScene->createNode(this->myScene->NODE_SOUND);//this->sMgr->createSoundNode();
|
---|
| 138 | boom->setPosition(this->getPosition());
|
---|
| 139 | if(!boom->loadFile("./media/sound/goodieArrival.mp3", false)) {
|
---|
| 140 | //MessageBox(NULL,"Loading file failed!", "Wuermer DEBUG",MB_OK|MB_ICONQUESTION);
|
---|
| 141 | } else {
|
---|
| 142 | boom->play();
|
---|
| 143 | }
|
---|
| 144 | this->firstTime = false;
|
---|
| 145 | }
|
---|
| 146 | this->myPosition.y = (FLOAT)(this->yPos + sin(this->lifeTime*4)*0.5);
|
---|
| 147 | this->setPosition(this->myPosition);
|
---|
| 148 | this->myRotation.y += D3DX_PI/2*dt;
|
---|
| 149 | this->setRotation(this->myRotation);
|
---|
| 150 | this->lifeTime+=dt;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | void Goodie::hitByWeapon(Weapon &weapon) {
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | void Goodie::hitByPlayer(Player &player) {
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | float Goodie::getHealthAmount() {
|
---|
| 160 | return this->healthAmount;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | int Goodie::getWeaponType() {
|
---|
| 164 | return this->weaponType;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | int Goodie::getArmorAmount() {
|
---|
| 168 | return this->armorAmount;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | void Goodie::setXFile(std::string _filename)
|
---|
| 172 | {
|
---|
| 173 | this->filename = _filename;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | Node* Goodie::clone()
|
---|
| 177 | {
|
---|
| 178 | this->myScene->manager->printToConsole("Goodie.clone not implemented!");
|
---|
| 179 | return NULL;
|
---|
| 180 | } |
---|