TaskPtr PvPActive::ReduceResistance(CCLayer* layer, HeroControl* caster, PlayerControlPtr defender, GemUtils::GemColor color, float value, int turn) { auto buff = FloatBuff::make(color, turn, "弱防", value); std::vector<GemUtils::GemColor> colVec; if( color != GemUtils::AllColor ) colVec.push_back(color); else { for(int i=GemUtils::Fire; i<=GemUtils::Light; i++) { colVec.push_back(static_cast<GemUtils::GemColor>(i)); } } return TaskSequence::make() << createOrb(layer, caster->center(), defender->center(), 0.f) << defender->buffGroup.attachBuff(PlayerControl::kGroup_PreTurn, "active.reduce.resistance", layer, buff) << TaskLambda::make([=]() { for(auto col : colVec) { int mid = (int)((defender->resist.val[col]-value)*100 + 100); defender->resist.label[col]->setString(toStr(mid).c_str()); } }); }
TaskPtr PvPActive::DamageByFactorAndEnemyHealth(cocos2d::CCLayer *layer, PH::HeroControl *hc, PlayerControlPtr attacker, PlayerControlPtr defender, float factor, float healthRatio, float damageFactor) { TaskBatchPtr batch = TaskBatch::make(); float skillMod; batch << attacker->getAttackFactor(hc, skillMod, [](){return PvPRand::rand();}); if( defender->healthRatio() < healthRatio ) skillMod *= damageFactor; float totalDamage = hc->attack * ( skillMod * factor ); batch << createOrb(layer, hc->center(), defender->center(), 0.0f); batch << createFloatText(layer, -totalDamage, defender->center(), GemUtils::Health, 0.1f); batch << defender->hit(totalDamage, layer); return batch; }
//--------------------------------------------- //------------- Damage Skills ----------------- //--------------------------------------------- static TaskPtr DamageCommon(CCLayer* layer, HeroControl* hc, PlayerControlPtr defender, float attack, bool isArea, float& totalDamage) { PVPBoardLayer* cast = dynamic_cast<PVPBoardLayer*>(layer); if(!cast) return TaskIgnore::make(); TaskBatchPtr batch = TaskBatch::make(); totalDamage = 0.0f; batch << cast->calcDamageWithReflect(attack, hc->getColor(), cast->getAttacker(), cast->getDefender(), 0.f, totalDamage); batch << createOrb(layer, hc->center(), defender->center(), 0.0f); batch << createFloatText(layer, -totalDamage, defender->center(), GemUtils::Health, 0.1f); batch << defender->hit(totalDamage, layer); return batch; }
TaskPtr PvPActive::DamageByFactorWithoutResistence(CCLayer * layer, HeroControl * hc, PlayerControlPtr attacker, PlayerControlPtr defender, GemUtils::GemColor color, float factor) { TaskBatchPtr batch = TaskBatch::make(); float skillMod; batch << attacker->getAttackFactor(hc, skillMod, [](){return PvPRand::rand();}); float totalDamage = hc->attack * ( skillMod * factor ); batch << createOrb(layer, hc->center(), defender->center(), 0.0f); batch << createFloatText(layer, -totalDamage, defender->center(), GemUtils::Health, 0.1f); batch << defender->hit(totalDamage, layer); return batch; }
AvatarManager::AvatarManager(QObject* parent) : _myAvatar(new MyAvatar(qApp->thread()), [](MyAvatar* ptr) { ptr->deleteLater(); }) { // register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer"); auto nodeList = DependencyManager::get<NodeList>(); // when we hear that the user has ignored an avatar by session UUID // immediately remove that avatar instead of waiting for the absence of packets from avatar mixer connect(nodeList.data(), &NodeList::ignoredNode, this, [this](const QUuid& nodeID, bool enabled) { if (enabled) { removeAvatar(nodeID, KillAvatarReason::AvatarIgnored); } else { auto avatar = std::static_pointer_cast<Avatar>(getAvatarBySessionID(nodeID)); if (avatar) { avatar->createOrb(); } } }); _transitConfig._totalFrames = AVATAR_TRANSIT_FRAME_COUNT; _transitConfig._minTriggerDistance = AVATAR_TRANSIT_MIN_TRIGGER_DISTANCE; _transitConfig._maxTriggerDistance = AVATAR_TRANSIT_MAX_TRIGGER_DISTANCE; _transitConfig._framesPerMeter = AVATAR_TRANSIT_FRAMES_PER_METER; _transitConfig._isDistanceBased = AVATAR_TRANSIT_DISTANCE_BASED; _transitConfig._abortDistance = AVATAR_TRANSIT_ABORT_DISTANCE; }
AvatarSharedPointer AvatarManager::newSharedAvatar(const QUuid& sessionUUID) { auto otherAvatar = new OtherAvatar(qApp->thread()); otherAvatar->setSessionUUID(sessionUUID); auto nodeList = DependencyManager::get<NodeList>(); if (!nodeList || !nodeList->isIgnoringNode(sessionUUID)) { otherAvatar->createOrb(); } return AvatarSharedPointer(otherAvatar, [](OtherAvatar* ptr) { ptr->deleteLater(); }); }
TaskPtr PvEActive::ReduceEnemyArmorByFactor(PH::BoardLayer *layer, PH::HeroControl *hc, int duration, float factor) { return CastTurnBasedSkill(layer, hc, [=](EnemyControlPtr ec) -> TaskPtr { TaskSequencePtr seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), ec->center()); FloatBuffPtr buff = FloatBuff::make(GemUtils::AllColor, duration, "弱防", factor); seq << ec->buffGroup.attachBuff(EnemyControl::kGroup_PostTurn, "armorFactor", layer, buff); return seq; }); }
TaskPtr PvEActive::Silence(BoardLayer* layer, HeroControl* hc, int duration, bool toAll) { return CastTurnBasedSkill(layer, hc, [=](EnemyControlPtr ec) -> TaskPtr { TaskSequencePtr seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), ec->center()); BuffPtr buff = IBuff::make(GemUtils::AllColor, duration, "封印"); seq << ec->buffGroup.attachBuff(EnemyControl::kGroup_PostTurn, "silence", layer, buff); return seq; }, toAll); }
TaskPtr PvEActive::PoisonByValue(BoardLayer* layer, HeroControl* hc, int duration, float val) { return CastTurnBasedSkill(layer, hc, [=](EnemyControlPtr ec) -> TaskPtr { TaskSequencePtr seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), ec->center()); FloatBuffPtr buff = FloatBuff::make(GemUtils::Dark, duration, "蛊毒", val); seq << ec->buffGroup.attachBuff(EnemyControl::kGroup_PostTurn, "poison", layer, buff); return seq; }); }
TaskPtr PvPActive::SlowByValue(CCLayer* layer, PH::HeroControl *caster, PlayerControlPtr defender, float val, int duration) { auto buff = FloatBuff::make(GemUtils::AllColor, duration, "迟缓", val); return TaskSequence::make() << createOrb(layer, caster->center(), defender->center(), 0.f) << defender->buffGroup.attachBuff(PlayerControl::kGroup_PreTurn, "active.slow.val", layer, buff); }
TaskPtr PvPActive::AmplifyDamageByFactor(CCLayer *layer, PH::HeroControl *hc, PlayerControlPtr defender, int duration, float factor, GemUtils::GemColor color) { FloatBuffPtr buff = FloatBuff::make(color, duration, "加深", factor); return TaskSequence::make() << createOrb(layer, hc->center(), defender->center()) << defender->buffGroup.attachBuff(PlayerControl::kGroup_PreTurn, "amplifyDamage", layer, buff); }
TaskPtr PvPActive::PoisonByValue(CCLayer* layer, HeroControl* hc, PlayerControlPtr defender, int duration, float val) { TaskSequencePtr seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), defender->center(), 0.0f); auto buff = FloatBuff::make(GemUtils::AllColor, duration, "蛊毒", val); return defender->buffGroup.attachBuff(PlayerControl::kGroup_PreTurn, "poison", layer, buff); }
TaskPtr PvEActive::ReduceAttackFactorByColor(PH::BoardLayer *layer, PH::HeroControl *hc, int duration, float factor, GemUtils::GemColor color) { return CastTurnBasedSkillByColor(layer, hc, [=](EnemyControlPtr ec) -> TaskPtr { auto seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), ec->center(), 0.f); auto buff = FloatBuff::make(GemUtils::AllColor, duration, "弱攻", factor); seq << ec->buffGroup.attachBuff(EnemyControl::kGroup_PostTurn, "attackFactor", layer, buff); return seq; }, color); }
TaskPtr PvEActive::WeakenEnemyAttackByFactor(PH::BoardLayer * layer, PH::HeroControl * hc, int duration, float factor, bool isArea) { // set property only to display a label, return CastTurnBasedSkill(layer, hc, [=](EnemyControlPtr ec) -> TaskPtr { TaskSequencePtr seq = TaskSequence::make(); seq << createOrb(layer, hc->center(), ec->center(), 0.0f); FloatBuffPtr buff = FloatBuff::make(GemUtils::AllColor, duration, "弱攻", factor); seq << ec->buffGroup.attachBuff(EnemyControl::kGroup_PostTurn, "attackFactor", layer, buff); return seq; }, isArea); }
TaskPtr PvPActive::ReduceAttackByFactor(CCLayer* layer, HeroControl* caster, PlayerControlPtr defender, float factor, GemUtils::GemColor color, int turn) { auto batch = TaskBatch::make(); for( auto hc : defender->team ) { if(hc->getColor() == color) { batch << createOrb(layer, caster->center(), hc->center(), 0.f); auto buff = FloatBuff::make(color, turn, "弱攻", factor); batch << hc->buffGroup.attachBuff(HeroControl::kGroup_onTurn, "active.reduce.attack.factor", layer, buff); } } return TaskIgnore::make(); }
TaskPtr PvPActive::BlindHeroByColor(CCLayer *layer, HeroControl* caster, PlayerControlPtr defender, GemUtils::GemColor color, int turn) { TaskBatchPtr batch = TaskBatch::make(); for(HeroControl* hc : defender->team) { if(hc->getColor() == color) { batch << createOrb(layer, caster->center(), hc->center(), 0.0f); auto buff = IBuff::make(GemUtils::AllColor, turn, "致盲"); batch << hc->buffGroup.attachBuff(HeroControl::kGroup_onTurn, "active.blind", layer, buff); } } return batch; }
TaskPtr PvPActive::BlindHeroRandom(CCLayer* layer, HeroControl* caster, PlayerControlPtr defender, int count, int turn) { TaskBatchPtr batch = TaskBatch::make(); HeroControlList team = defender->team; std::random_shuffle(team.begin(), team.end()); for(int i=0; i<count && team.size(); i++) { HeroControl* hc = team[i]; batch << createOrb(layer, caster->center(), hc->center(), 0.0f); auto buff = IBuff::make(GemUtils::AllColor, turn, "致盲"); batch << hc->buffGroup.attachBuff(HeroControl::kGroup_onTurn, "active.blind", layer, buff); } return batch; }