NormalTower::NormalTower(shared_ptr<Tile> mTile) :Tower(mTile) { for (int i = 0; i < 3; i++) { damage[i] = NORMAL_TOWER_DAMAGE[i]; income[i] = NORMAL_TOWER_INCOME[i]; range[i] = NORMAL_TOWER_RANGE[i]; speed[i] = NORMAL_TOWER_SPEED[i]; } timer = speed[level - 1]; price = NORMAL_TOWER_PRICE; attack = make_shared<NormalAttack>(); setAttack(); if (!texture.loadFromFile(NORMAL_TOWER_SPRITE_ADD)) { // TODO erreur... } setTowerTexture(); setRangeCircle(); }
Character::Character() { setName("Bro"); setHealth(300); setAttack(25); setDefence(5); setMoney(10); mana = 300; facingRight = true; attackingRight = true; entityRect.h = 100; entityRect.w = 100; healthBar.x = 5; healthBar.y = 10; healthBar.w = 300; healthBar.h = 25; manaBar.x = 5; manaBar.y = 40; manaBar.w = 300; manaBar.h = 25; }
void initADSR(struct ADSR* adsr, unsigned a, unsigned d, float s, unsigned r){ setSustain(adsr, s); setAttack(adsr, a); setDecay(adsr, d); setRelease(adsr, r); adsr->index = 0; adsr->level = 0.00000000001f; }
Archer::Archer() { setAttack(15); //level 1 arher is 10 * setAttack = 150 setHealth(20); //level 1 arher is 10 * setHealth = 200 setSpawnRate(0.1); setAttackRate(0.2); setSpeed(3); }
void Building::setAttributes(int type) { BuildingBaseStatus* baseStatus = field->getBaseStatus()->getBuildingBaseStatus(type); setBaseValue(baseStatus->getBaseValue()); setAttackRate(baseStatus->getAttackRate()); setAttack(baseStatus->getAttack()); setRangeOfEffect(baseStatus->getRangeOfEffect()); }
void MonsterProperties::attackRedo() { if (!InternalOperation && targetSprite){ auto sprite = dynamic_cast<EntityImageSprite*>(targetSprite); sprite->setAttack(attack->text().toInt()); } else if (!InternalOperation && !targetSprite && templateFile != ""){ resetTemplateValue(resetAttack); } }
//克隆对象 AttackObject* AttackObject::clone() { auto aClone=AttackObject::create(); aClone->setAttackObject(m_AttackObject); aClone->setIsSubBoold(m_isSubBoold); aClone->setIsHitDown(m_isHitDown); aClone->setAttRange(m_attRange); aClone->setAttack(m_Attack); aClone->setRepelPower(m_RepelPower); return aClone; }
void Compressor::setNValue(int idx, double value) { switch (idx) { case RMS_PEAK: setRmsPeak(value); break; case ATTACK: setAttack(value); break; case RELEASE: setRelease(value); break; case THRESHOLD: setThreshold(value); break; case RATIO: setRatio(value); break; case KNEE: setKnee(value); break; case GAIN: setMakeupGain(value); break; } }
//Dragon class Dragon::Dragon(string name, int health, int attack, int defence, int money) { setName(name); setHealth(health); setAttack(attack); setDefence(defence); setMoney(money); entityRect.x = 0; entityRect.y = 0; entityRect.h = 100; entityRect.w = 100; }
AttackObject* HeroKnight::createAttackObject() { std::string strAttID=getArmature()->getAnimation()->getCurrentMovementID(); auto actionMode=getActionFileMode(); //创建攻击对象 int attack=getHeroModel()->Attack; auto att=AttackObject::create(); att->setAttackObject(this); //默认是普通攻击距离 float attDist=getHeroModel()->AttackDist; if (strAttID==actionMode->ActionAttackName1) { att->setRepelPower(20); }else if (strAttID==actionMode->ActionAttackName2) { att->setRepelPower(10); }else if (strAttID==actionMode->ActionAttackName3) { att->setRepelPower(35); } //技能攻击距离 if (strAttID==actionMode->SkillName1){ attDist=skills[0].AttackDist; //加血 int addHp=skills[0].CurrAttack + attack / 4; HeroBase::addHp(addHp); return nullptr; }else if (strAttID==actionMode->SkillName2){ attack=skills[1].CurrAttack + attack / 4; att->setRepelPower(180); attDist=skills[1].AttackDist; }else if (strAttID==actionMode->SkillName3){ attack=skills[2].CurrAttack + attack / 4; att->setRepelPower(290); attDist=skills[2].AttackDist; }else if (strAttID==actionMode->SkillName4){ attack=skills[3].CurrAttack + attack / 4; attDist=skills[3].AttackDist; } att->setAttack(attack); //攻击范围 Vec2 pos=this->getPosition(); float attStartPos=getPositionX(); if (!getFacing()) { attStartPos-=attDist; } Rect attRect=Rect(attStartPos,getPositionY(),attDist, 200); att->setAttRange(attRect); return att; }
void MonsterProperties::changeSpriteValue() { if (targetSprite && this->isVisible() && targetSprite->isHasMonsterProperties()){ auto sprite = dynamic_cast<EntityImageSprite*>(targetSprite); sprite->setHp(hp->text().toInt()); sprite->setMp(mp->text().toInt()); sprite->setAttack(attack->text().toInt()); sprite->setDefense(attack->text().toInt()); sprite->setMagic_Attack(magic_attack->text().toInt()); sprite->setMagic_Defense(magic_defense->text().toInt()); sprite->setSpeed(speed->text().toFloat()); sprite->setHardFactor(hardFactor->text().toFloat()); } }
Player::Player(Device* dev, SceneManager* scn, SceneNode* parent, std::string const& name, std::string const& shader, std::string const& path) :Entity(scn, parent, name, shader, path), dev(dev) { LOG(L_DEBUG, "Creating Player..."); setHp(9); setLife(3); setAttack(3); if (!static_cast<event::EventPlayer*>(this->dev->getEventManager()->getEventFromName("EventPlayer"))->getPlayer()) static_cast<event::EventPlayer*>(this->dev->getEventManager()->getEventFromName("EventPlayer"))->setPlayer(this); LOG(L_DEBUG, "Player has been created."); }
//------------------------------------------------------------- SimpleLimit::SimpleLimit() : threshdB_( 0.0 ) , thresh_( 1.0 ) , peakHold_( 0 ) , peakTimer_( 0 ) , maxPeak_( 1.0 ) , att_( 1.0 ) , rel_( 10.0 ) , env_( 1.0 ) , mask_( BUFFER_SIZE - 1 ) , cur_( 0 ) { setAttack( 1.0 ); outBuffer_[ 0 ].resize( BUFFER_SIZE, 0.0 ); outBuffer_[ 1 ].resize( BUFFER_SIZE, 0.0 ); }
audio::algo::chunkware::Limiter::Limiter() : m_isConfigured(false), m_thresholddB(0.0), m_threshold(1.0), m_peakHold(0), m_peakTimer(0), m_maxPeak(1.0), m_attack(1.0), m_release(10.0), m_overThresholdEnvelope(1.0), m_bufferMask(BUFFER_SIZE-1), m_cursor(0) { setAttack(1.0); m_outputBuffer.resize(1); m_outputBuffer[0].resize(BUFFER_SIZE, 0.0); }
QAGC::QAGC(QObject *parent, int size) : QObject(parent) , set(Settings::instance()) , m_size(size) , m_mask(size * 2) , m_index(0) , m_sndex(0) , m_hangIndex(0) , m_fastIndex(FASTLEAD) , m_fastHang(0) , m_samplerate(set->getSampleRate()) //, m_agcMode(agcMED) , m_gainTop(qPow(10.0f, 120.0f/20.0f)) , m_gainNow(1.0f) , m_gainFastNow(1.0f) , m_gainBottom(.001f) , m_gainLimit(1.0f) //, m_gainFix(pow(10.0, 60.0/20.0)) , m_gainFix(qPow(10.0f, 80.0f/20.0f)) , m_attack(0.0f) , m_oneMAttack(0.0f) , m_decay(0.0f) , m_oneMDecay(0.0f) , m_slope(1.0f) , m_fastAttack(0.0f) , m_oneMFastAttack(0.0f) , m_fastDecay(0.0f) , m_oneMFastDecay(0.0f) , m_hangTime(480.0f * 0.001f) , m_hangThresh(0.001f) , m_fastHangTime(48.0f * 0.001f) { setAttack(1.0); setDecay(1.0); setMode(agcMED); m_fastAttack = 1.0 - qExp(-1000.0 / (0.2f * m_samplerate)); m_oneMFastAttack = qExp(-1000.0 / (0.2 * m_samplerate)); m_fastDecay = 1.0 - qExp(-1000.0 / (3.0 * m_samplerate)); m_oneMFastDecay = qExp(-1000.0 / (3.0 * m_samplerate)); InitCPX(G, m_mask, 0.0f); m_mask -= 1; }
//Spider class Spider::Spider() { setName("spider"); setHealth(100); setAttack(10); setDefence(5); setMoney(10); facingRight = false; attackingRight = false; attackRect.x = 1000; attackRect.y = 0; entityRect.x = 0; entityRect.y = 0; entityRect.h = 100; entityRect.w = 100; }
AIWizard::AIWizard(bool bIsAttacking, int type, int race, Ogre::Vector2 position, Ogre::Vector2 orientation) { m_bIsAttacking = bIsAttacking; m_iType = type; m_iRace = race; m_vPos = position; m_vPrevPos = m_vPos; m_vOri = orientation; m_iVision = 100; m_dTotalHealth = 2000; m_dActualHealth = 2000; m_iAttackDistance = 20; m_MaxForce = 0.05; m_MaxSpeed = 0.5; m_dMass = 2.0; m_iCollisionType = circle1; m_iAnimation = WALK; setAttack(1); MessageSystem::getSingletonPtr()->DispatchMessageToGraphFactory(this->ID(), factoryGraph, SMSG_AICreateGraphUnit, position, m_vOri, type, race, Vector2(this->getActualHealth(), this->getTotalHealth())); m_pStateMachine = new AIStateSystem<AIWizard>(this); m_pStateMachine->SetCurrentState(SeekToFlagWizard::Instance()); }
bool ArtilleryTower::init() { if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错 { return false; } setScope(300); setAttack(2); setRate(2); setIsSelected(false); setTowerType(1); setGrade(0);//开始没有等级 setPower(0);//塔消耗电力 setMove(false);//开始不处于移动状态 setIsPowerEnough(true);//开始状态电力足够 setIsPowerConsumption(false);//该塔耗电 basePlate = Sprite::createWithSpriteFrameName("fort1.png"); //塔的基座 addChild(basePlate,2); //log("111111111111111"); rotateArtillery = Sprite::createWithSpriteFrameName("fort2.png"); //塔的弓箭 rotateArtillery->setPosition(0, 0); rotateArtillery->setRotation(270); addChild(rotateArtillery,3); //这个不能少,虽然不显示,这是因为这个炮塔比较特殊,是由2个sprite拼接而成的 towerSprite = Sprite::create("towerItem/Item2.png"); addChild(towerSprite); towerSprite->setVisible(false); gradeSprite = Sprite::create("level1.png"); gradeSprite->setScale(2); gradeSprite->setAnchorPoint(Point(0, 0)); gradeSprite->setPosition(this->getPosition().x + 60, -towerSprite->getBoundingBox().size.height / 2-10); gradeSprite->setOpacity(0);//开始让其不可见 addChild(gradeSprite, 6); //沉默图片 noAttackSprite = Sprite::create("noSpeak.png"); noAttackSprite->setScale(0.9); noAttackSprite->setAnchorPoint(Point(0.5, 0)); noAttackSprite->setPosition(towerSprite->getBoundingBox().size.width / 2 - 70, towerSprite->getBoundingBox().size.height - 60); addChild(noAttackSprite, 8); noAttackSprite->setVisible(false); //血量条背景图片 towerHpSprite = Sprite::create("manaBarBg.png"); towerHpSprite->setPosition(towerSprite->getPosition() + Point(0, 100)); towerHpSprite->setScale(0.8); addChild(towerHpSprite, 10); //炮塔血量 hp = 2; maxHp = 2; //炮塔血量进度条 towerHp = ProgressTimer::create(Sprite::create("soldierProduceTimeBar.png")); //参数是一个图片sprite towerHp->setScaleX(2); towerHp->setScaleY(5.2); towerHp->setType(ProgressTimer::Type::BAR); towerHp->setMidpoint(Point(0, 0.5f)); towerHp->setBarChangeRate(Point(1, 0)); towerHp->setPercentage(100); towerHp->setPosition(Point(towerHpSprite->getContentSize().width / 2, towerHpSprite->getContentSize().height / 3 * 2 - 10)); towerHpSprite->addChild(towerHp, 5); //初始化不可见 towerHp->setVisible(false); towerHpSprite->setVisible(false); schedule(schedule_selector(ArtilleryTower::rotateAndShoot), 0.5f); //别忘了调用函数,时间间隔越小,炮塔旋转越平滑 schedule(schedule_selector(ArtilleryTower::shoot), 2.5f); addTouch(); return true; }
//============================================================================== ADSRComponent::ADSRComponent () { addAndMakeVisible (attackSlider = new Slider ("Attack slider")); attackSlider->setTooltip (TRANS("Attack")); attackSlider->setRange (5, 15000, 0); attackSlider->setSliderStyle (Slider::LinearVertical); attackSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); attackSlider->addListener (this); attackSlider->setSkewFactor (0.4); addAndMakeVisible (decaySlider = new Slider (String::empty)); decaySlider->setTooltip (TRANS("Decay")); decaySlider->setRange (5, 15000, 0); decaySlider->setSliderStyle (Slider::LinearVertical); decaySlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); decaySlider->addListener (this); decaySlider->setSkewFactor (0.4); addAndMakeVisible (sustainSlider = new Slider (String::empty)); sustainSlider->setTooltip (TRANS("Sustain")); sustainSlider->setRange (0, 1, 0); sustainSlider->setSliderStyle (Slider::LinearVertical); sustainSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); sustainSlider->addListener (this); addAndMakeVisible (releaseSlider = new Slider (String::empty)); releaseSlider->setTooltip (TRANS("Release")); releaseSlider->setRange (5, 15000, 0); releaseSlider->setSliderStyle (Slider::LinearVertical); releaseSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); releaseSlider->addListener (this); releaseSlider->setSkewFactor (0.4); addAndMakeVisible (attackLabel = new Label (String::empty, TRANS("A"))); attackLabel->setFont (Font (15.00f, Font::bold)); attackLabel->setJustificationType (Justification::centred); attackLabel->setEditable (false, false, false); attackLabel->setColour (TextEditor::textColourId, Colours::black); attackLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (decayLabel = new Label (String::empty, TRANS("D"))); decayLabel->setFont (Font (15.00f, Font::bold)); decayLabel->setJustificationType (Justification::centred); decayLabel->setEditable (false, false, false); decayLabel->setColour (TextEditor::textColourId, Colours::black); decayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (sustainLabel = new Label (String::empty, TRANS("S"))); sustainLabel->setFont (Font (15.00f, Font::bold)); sustainLabel->setJustificationType (Justification::centred); sustainLabel->setEditable (false, false, false); sustainLabel->setColour (TextEditor::textColourId, Colours::black); sustainLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (releaseLabel = new Label (String::empty, TRANS("R"))); releaseLabel->setFont (Font (15.00f, Font::bold)); releaseLabel->setJustificationType (Justification::centred); releaseLabel->setEditable (false, false, false); releaseLabel->setColour (TextEditor::textColourId, Colours::black); releaseLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); //[UserPreSize] //[/UserPreSize] setSize (600, 400); //[Constructor] You can add your own custom stuff here.. setAttack(5); setDecay(5); setSustain(1); setRelease(5); //[/Constructor] }
bool AntiVisibleTower::init() { if (!Sprite::init()) //如果忘记了这句话则会在runApplication报错 { return false; } instance = GameManager::getInstance(); setScope(300); setAttack(0); setRate(5);//4秒钟开火一次 setTowerType(3); setIsSelected(false); setGrade(0);//开始没有等级 setPower(40);//塔消耗电力 setMove(false);//开始不处于移动状态 setIsPowerEnough(true);//开始状态电力足够 setIsPowerConsumption(true);//该塔耗电 nearestEnemy = nullptr; towerSprite = Sprite::create("towerItem/Item99.png"); addChild(towerSprite, 5); gradeSprite = Sprite::create("level1.png"); gradeSprite->setAnchorPoint(Point(0, 0)); gradeSprite->setPosition(this->getPosition().x + 10, -towerSprite->getBoundingBox().size.height / 2); gradeSprite->setOpacity(0);//开始让其不可见 addChild(gradeSprite, 6); noPowerSprite = Sprite::create("noPower.png"); noPowerSprite->setAnchorPoint(Point(0.5, 0)); noPowerSprite->setScale(1.4); noPowerSprite->setPosition(towerSprite->getBoundingBox().size.width / 2 - 70, towerSprite->getBoundingBox().size.height - 40); noPowerSprite->setVisible(false); addChild(noPowerSprite, 7); //血量条背景图片 towerHpSprite = Sprite::create("manaBarBg.png"); towerHpSprite->setPosition(noPowerSprite->getPosition()-Point(0,25)); towerHpSprite->setScale(0.8); addChild(towerHpSprite, 10); //炮塔血量 hp = 4; //炮塔血量进度条 towerHp = ProgressTimer::create(Sprite::create("soldierProduceTimeBar.png")); //参数是一个图片sprite towerHp->setScaleX(2); towerHp->setScaleY(5.2); towerHp->setType(ProgressTimer::Type::BAR); towerHp->setMidpoint(Point(0, 0.5f)); towerHp->setBarChangeRate(Point(1, 0)); towerHp->setPercentage(100); towerHp->setPosition(Point(towerHpSprite->getContentSize().width / 2, towerHpSprite->getContentSize().height / 3 * 2 - 10)); towerHpSprite->addChild(towerHp, 5); //初始化不可见 towerHp->setVisible(false); towerHpSprite->setVisible(false); schedule(schedule_selector(AntiVisibleTower::shoot), 0.1f); schedule(schedule_selector(AntiVisibleTower::checkNearestEnemy), 0.2); addTouch();//添加触摸事件 return true; }
AttackAction::AttackAction(Pokemon *attackingPokemon, Trainer *defendingTrainer, int attackIndex) { setAttackingPokemon(attackingPokemon); setDefendingTrainer(defendingTrainer); setAttack(attackIndex); }
AttackObject* HeroBow::createAttackObject() { std::string strAttID=getArmature()->getAnimation()->getCurrentMovementID(); auto actionMode=getActionFileMode(); //获取方向 bool facing=getFacing(); float attackDist=getHeroModel()->AttackDist; //攻击距离 //创建子弹 auto bullet=BulletObject::create(); bullet->setAttackType(1); bullet->setAttackObject(this); if (strAttID==actionMode->ActionAttackName1 || strAttID==actionMode->ActionAttackName2 || strAttID==actionMode->ActionAttackName3 || strAttID==actionMode->ActionAttackName4) { bullet->setRepelPower(8.0); float bulletX=GameBLL::instance()->getMaxMapWidth(); if(!facing){ bulletX*=-1; } auto b=Sprite::createWithSpriteFrameName("v_arrow_1.png"); b->setFlippedX(!facing); bullet->setSprite(b); bullet->setPosition(getPosition()+vShootPos); bullet->setTargetPos(getPosition()+Vec2(bulletX,vShootPos.y), 3000); bullet->setAttack(getHeroModel()->Attack); BulletBLL::getInstance()->addBullet(bullet); } //技能1 if (strAttID==actionMode->SkillName1) { bullet->setPenetrateAttack(true); bullet->setRepelPower(32); attackDist=skills[0].AttackDist; float width=1280.0; float rota=21.24; //旋转角度 if(!facing){ attackDist*=-1; rota*=-1; width*=-1; } auto bulletStartPos=getPosition() + Vec2(0, 255); auto b=Sprite::createWithSpriteFrameName("v_arrow_2.png"); b->setFlippedX(!facing); bullet->setSprite(b); bullet->setPosition(bulletStartPos); //bullet->setTargetPos(pos+Vec2(attackDist,0), 2000); bullet->setIsDone(true); bullet->setRotation(rota); int attack=skills[0].CurrAttack + getHeroModel()->Attack / 4; bullet->setAttack(attack); BulletBLL::getInstance()->addBullet(bullet); auto call=CallFunc::create(CC_CALLBACK_0(HeroBow::bulletCallback, this, bullet)); ccBezierConfig bc; bc.endPosition=Vec2(bulletStartPos.x + width, bulletStartPos.y); if(!facing){ bc.controlPoint_1 = Vec2(bulletStartPos.x - width * 0.2, bulletStartPos.y - 300); bc.controlPoint_2 = Vec2(bc.endPosition.x + width * 0.2, bulletStartPos.y - 300); }else{ bc.controlPoint_1 = Vec2(bulletStartPos.x + width * 0.2, bulletStartPos.y - 300); bc.controlPoint_2 = Vec2(bc.endPosition.x - width * 0.2, bulletStartPos.y - 300); } //子弹动作 auto bez=BezierTo::create(0.5, bc); auto seq=Sequence::create(bez,call, NULL); bullet->runAction(APRotateWithAction::create(seq)); }else if (strAttID==actionMode->SkillName2){ float bAngle=345; if(!facing){ bAngle=215; } auto bulletPos=getPosition() + Vec2(0, 272); int attack=skills[1].CurrAttack + getHeroModel()->Attack / 4; for (int i=0; i<3; i++) { auto targetPos=APTools::getRoundPoint(bulletPos, bAngle - (i * 10), 1700); float rotation=APTools::getAngle(bulletPos, targetPos); auto b=Sprite::createWithSpriteFrameName("v_arrow_3.png"); b->setFlippedX(!facing); //创建子弹 auto newbullet=BulletObject::create(); newbullet->setRepelPower(8.0); newbullet->setAttackType(1); newbullet->setPenetrateAttack(true); newbullet->setAttackObject(this); newbullet->setSprite(b); newbullet->setPosition(bulletPos); newbullet->setTargetPos(targetPos, 2000); newbullet->setRotation(rotation); newbullet->setAttack(attack); BulletBLL::getInstance()->addBullet(newbullet); } }else if (strAttID==actionMode->SkillName3){ attackDist=skills[2].AttackDist; //创建攻击对象 int attack=skills[2].CurrAttack + getHeroModel()->Attack / 4; auto att=AttackObject::create(); att->setAttack(attack); att->setRepelPower(280); att->setAttackObject(this); //是否被击倒 att->setIsHitDown(true); //攻击范围 Vec2 pos=this->getPosition(); float attStartPosX=getPositionX(); if (!facing) { attStartPosX-=attackDist; } Rect attRect=Rect(attStartPosX,getPositionY(),attackDist, 100); att->setAttRange(attRect); return att; }else if (strAttID==actionMode->SkillName4){ attackDist=skills[3].AttackDist; //创建攻击对象 int attack=skills[3].CurrAttack + getHeroModel()->Attack / 4; auto att=AttackObject::create(); att->setAttack(attack); att->setRepelPower(120); att->setAttackObject(this); //是否被击倒 att->setIsHitDown(false); //攻击范围 Vec2 pos=this->getPosition(); auto worldPos=this->getParent()->convertToWorldSpace(pos); float attDist=1280-worldPos.x; float attStartPosX=pos.x; if (!facing) { attDist=worldPos.x; attStartPosX-=attDist; } Rect attRect=Rect(attStartPosX,getPositionY(),attDist, 100); att->setAttRange(attRect); return att; } return nullptr; }