Weapon::WeaponI * Weapon::Armory::getRifle(int level, int projLevel) { //Min level 0 int weaplv = std::max(0, std::min(level, 8)); //If -1, match weapon level (default behaviour) int projlv = (projLevel > -1 ? projLevel : level); Weapon::AutoMag* rifle = new Weapon::AutoMag(fireCallback_, getBullet(projlv), "rifle"); upgradeRifle(rifle, weaplv, projlv); return static_cast<Weapon::WeaponI*>(rifle); }
//--------------------------------------------------- void WarManager::fire(const Ogre::Vector3& pos,const Ogre::Vector3& dir) { Bullet* pBullet=getBullet(); if(pBullet!=NULL) { pBullet->shoot(pos, dir); notifyFire(pBullet); } return ; }
void Weapon::Armory::upgradeRifle(Weapon::AutoMag* rifle, int level, int projLevel) { //Match weapon level if (projLevel > -1) rifle->setProjectile(getBullet(projLevel)); else rifle->setProjectile(getBullet(level)); rifle->setLevel(level); //Set base attributes rifle->setMagSize(27, true); rifle->setRefireTime(150); rifle->setReloadTime(4000); rifle->setSpread(0.125f); //L1H : Spread- if (level > 0) { rifle->setSpread(0.0025); } //L2B : Mag+ if (level > 1) { rifle->setMagSize(36, true); } //L3F : ReloadTime- if (level > 2) { rifle->setReloadTime(3000); } //L4S : Mag+ if (level > 3) { rifle->setSpread(.1f); } //L5H : ReloadTime-- if (level > 4) { rifle->setReloadTime(2000); } //L6B : Spread-- if (level > 5) { rifle->setSpread(0.05f); } //L7F : RefireTime- if (level > 6) { rifle->setRefireTime(50); } //L8S : Mag++ if (level > 7) { rifle->setMagSize(45, true); } }
//--------------------------------------------------- void WarManager::fire() { Bullet* pBullet=getBullet(); if(pBullet==NULL) return ; Ogre::SceneNode* pCameraNode=Application::getSingleton().getMainCamera()->getParentSceneNode(); Ogre::Matrix3 matrix= pCameraNode->getLocalAxes(); Ogre::Vector3 pos=pCameraNode->getPosition(); Ogre::Vector3 dir(matrix[0][2],matrix[1][2],matrix[2][2]); dir.normalise(); pos-=dir*2; pos.y-=0.5f; dir.y-=0.15f; dir.normalise(); ///子弹发送时稍稍向上发送一点 //dir.y-=0.15; //dir.normalise(); fire(pos,dir); }
void Bullet::bulletAnimation() { auto animation = f_createAnimation(2, 60); getBullet()->runAction(RepeatForever::create(Animate::create(animation))); }