#include "dxstdafx.h" #include ".\goodie.h" #include "GameScene.h" #include "Terrain.h" #include "SoundNode.h" #include "UserContactReport.h" #include Goodie::Goodie(void) : Object3d(){ this->lifeTime = 0; this->filename = ""; this->nodeType |= GameScene::NODE_GOODIE; } Goodie::~Goodie(void) { } void Goodie::setGoodieType(int _type) { this->goodieType = _type; this->firstTime = true; /*this->scheibe = this->sMgr->createFlaeche(*this); this->scheibe->setPosition(0, -15, 0); this->scheibe->setDimension(50, 50); this->scheibe->setRotation(-90, 0, 0); this->scheibe->setTextureName("./media/textures/goodieScheibe.bmp");*/ } int Goodie::getGoodieType() { return this->goodieType; } void Goodie::loadGoodieMesh() { std::string s; if(this->filename.compare("")==0) { switch(this->goodieType) { case(Goodie::GOODIE_HEALTH): this->loadMeshFromFile("./media/models/medipack.x"); break; case(Goodie::GOODIE_WEAPON): s="./media/models/waffe"; switch(this->weaponType) { case 0: s+= "1.x"; break; case 1: s+= "2.x"; break; case 2: s+= "3.x"; break; case 3: this->myScene->manager->printToConsole("Kein Modell für Flammenwerfer spezifiziert...verwende waff1!"); s="./media/models/waffe1.x"; break; default: this->myScene->manager->printToConsole("If you use a weapontype > 3 you must specify a xfile!"); break; } this->loadMeshFromFile(s); break; case(Goodie::GOODIE_AMO): s="./media/models/munpack"; switch(this->weaponType) { case 0: s+= "1.x"; break; case 1: s+= "2.x"; break; case 2: s+= "3.x"; break; case 3: this->myScene->manager->printToConsole("Kein Modell für Flammenwerfermunition spezifiziert...verwende munpack1!"); s="./media/models/munpack1.x"; break; default: this->myScene->manager->printToConsole("If you use a amotype > 3 you must specify a xfile!"); break; } this->loadMeshFromFile(s); break; } } else { this->loadMeshFromFile(this->filename); } } void Goodie::init() { if(this->pActor==NULL) { NxSphereShapeDesc sphereDesc; Vector dist = this->maxAABBox - this->minAABBox; sphereDesc.radius = max(dist.x, max(dist.y, dist.z)); this->pActorDesc.shapes.pushBack(&sphereDesc); this->setBehaveAs(Node::KINEMATIC); this->setColDetGroup(UserContactReport::COLGROUP_GOODIE); } else { this->setColDetGroup(UserContactReport::COLGROUP_GOODIE); } this->pActor->getShapes()[0]->setFlag(NX_SF_DISABLE_RAYCASTING, true); } void Goodie::setHealthAmount(float _healthAmount) { this->healthAmount = _healthAmount; /*if(this->filename.compare("")==0) { this->loadMeshFromFile("./media/models/medipack.x"); } else { this->loadMeshFromFile(this->filename); }*/ } void Goodie::setWeaponType(int _type) { this->weaponType = _type; /*if(this->envType == this->GOODIE_WEAPON) { if(this->filename.compare("")==0) { std::string s="./media/models/waffe"; switch(this->weaponType) { case 0: s+= "1.x"; break; case 1: s+= "2.x"; break; case 2: s+= "3.x"; break; } //MessageBox(NULL,s.c_str(), "Wuermer DEBUG",MB_OK|MB_ICONQUESTION); this->loadMeshFromFile(s); } else { this->loadMeshFromFile(this->filename); } }*/ } void Goodie::setArmorAmount(int _armorAmount) { this->armorAmount = _armorAmount; /*if(this->envType == this->GOODIE_AMO) { if(this->filename.compare("")==0) { std::string s="./media/models/munpack"; switch(this->weaponType) { case 0: s+= "1.x"; break; case 1: s+= "2.x"; break; case 2: s+= "3.x"; break; } //MessageBox(NULL,s.c_str(), "Wuermer DEBUG",MB_OK|MB_ICONQUESTION); this->loadMeshFromFile(s); } else { this->loadMeshFromFile(this->filename); } }*/ } void Goodie::update(float dt) { this->yPos = ((GameScene *) this->myScene)->getTerrainHeight(this->myPosition)+1;//getTerrain()->getHeight(this->myPosition.x, this->myPosition.z)+1; if(this->firstTime) { SoundNode *boom; boom = (SoundNode *) this->myScene->createNode(this->myScene->NODE_SOUND);//this->sMgr->createSoundNode(); boom->setPosition(this->getPosition()); if(!boom->loadFile("./media/sound/goodieArrival.mp3", false)) { //MessageBox(NULL,"Loading file failed!", "Wuermer DEBUG",MB_OK|MB_ICONQUESTION); } else { boom->play(); } this->firstTime = false; } this->myPosition.y = (FLOAT)(this->yPos + sin(this->lifeTime*4)*0.5); this->setPosition(this->myPosition); this->myRotation.y += D3DX_PI/2*dt; this->setRotation(this->myRotation); this->lifeTime+=dt; } void Goodie::hitByWeapon(Weapon &weapon) { } void Goodie::hitByPlayer(Player &player) { } float Goodie::getHealthAmount() { return this->healthAmount; } int Goodie::getWeaponType() { return this->weaponType; } int Goodie::getArmorAmount() { return this->armorAmount; } void Goodie::setXFile(std::string _filename) { this->filename = _filename; } Node* Goodie::clone() { this->myScene->manager->printToConsole("Goodie.clone not implemented!"); return NULL; }