예제 #1
0
 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());
         }
     });
 }
예제 #2
0
 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;
 }
예제 #3
0
 //---------------------------------------------
 //------------- 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;
 }
예제 #4
0
    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;
    }
예제 #5
0
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;
}
예제 #6
0
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(); });
}
예제 #7
0
 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;
     });
 }
예제 #8
0
 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);
 }
예제 #9
0
 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;
     });
 }
예제 #10
0
 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);
 }
예제 #11
0
 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);
 }
예제 #12
0
 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);
 }
예제 #13
0
 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);
 }
예제 #14
0
    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);
    }
예제 #15
0
 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();
 }
예제 #16
0
 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;
 }
예제 #17
0
 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;
 }