1 /* 2 * This file is part of Dune Legacy. 3 * 4 * Dune Legacy is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * Dune Legacy is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Dune Legacy. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include <units/Soldier.h> 19 20 #include <globals.h> 21 22 #include <FileClasses/GFXManager.h> 23 #include <House.h> 24 #include <SoundPlayer.h> 25 Soldier(House * newOwner)26Soldier::Soldier(House* newOwner) : InfantryBase(newOwner) { 27 Soldier::init(); 28 29 setHealth(getMaxHealth()); 30 } 31 Soldier(InputStream & stream)32Soldier::Soldier(InputStream& stream) : InfantryBase(stream) { 33 Soldier::init(); 34 } 35 init()36void Soldier::init() { 37 itemID = Unit_Soldier; 38 owner->incrementUnits(itemID); 39 40 numWeapons = 1; 41 bulletType = Bullet_ShellSmall; 42 43 graphicID = ObjPic_Soldier; 44 graphic = pGFXManager->getObjPic(graphicID,getOwner()->getHouseID()); 45 46 numImagesX = 4; 47 numImagesY = 3; 48 } 49 ~Soldier()50Soldier::~Soldier() { 51 } 52 canAttack(const ObjectBase * object) const53bool Soldier::canAttack(const ObjectBase* object) const { 54 if ((object != nullptr) 55 && (object->isAStructure() 56 || !object->isAFlyingUnit()) 57 && ((object->getOwner()->getTeam() != owner->getTeam()) 58 || object->getItemID() == Unit_Sandworm) 59 && object->isVisible(getOwner()->getTeam())) 60 { 61 return true; 62 } 63 else 64 return false; 65 } 66 67 playAttackSound()68void Soldier::playAttackSound() { 69 soundPlayer->playSoundAt(Sound_Gun,location); 70 } 71