Exemple #1
0
inline
void CNpc::animation_reBack()
{
    CGameElement::setCurrentAnimation(ARMATURE_GUARD_DIE_REVIVE);
    getArmature()->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CNpc::movementCallback));
    getArmature()->getAnimation()->play(PLAYLAB_GUARD_REVIVE);
}
Exemple #2
0
void CDragon::onEnter()
{
    CBoss::onEnter();

    //---------------------------------------------

    //风魔龙闪电云技能
    T_SkillDragonLighing* skilllight    = new T_SkillDragonLighing();
    skilllight->m_fMaxTime              = 10; //   
    skilllight->init();

    //风魔龙 龙卷风技能
    T_SkillDrogTornado* pSkillTornado   = new T_SkillDrogTornado();
    pSkillTornado->m_fMaxTime           = 120;
    pSkillTornado->m_fMAXWhiteTime      = 3;
    pSkillTornado->m_fMAXBlackTime      = 4;
    pSkillTornado->init();

    //风魔龙 龙卷风技能
    T_RandSkill allRandSkill[] = 
    {
        //{ 3, 0, Skill::SKILL_T_LIGHTING, RandSkill_State::RANDSKILL_STATE_CD, (T_SkillData*)skilllight },
        { 3, 0, Skill::SKILL_T_TORNADO, RandSkill_State::RANDSKILL_STATE_CD, (T_SkillData*)pSkillTornado }
    
    };
    
    int size = sizeof(allRandSkill) / sizeof(allRandSkill[0]);
    for (int i = 0; i < size;i++)
    {
        T_RandSkill* randskill      = new T_RandSkill();

        randskill->m_iMaxCD         = allRandSkill[i].m_iMaxCD;
        randskill->m_iSkillCd       = allRandSkill[i].m_iSkillCd;
        randskill->m_iSkillId       = allRandSkill[i].m_iSkillId;
        randskill->m_iSkillState    = allRandSkill[i].m_iSkillState;
        randskill->m_pSkill         = allRandSkill[i].m_pSkill;

        randskill->init();

        m_oAllRandSkill.push_back(randskill);
    }

    createSkillTimer();
    
    //======================================

    clearCurrentAnimation();    
    setCurrentAnimation(ARMATURE_DRAGON);
    getArmature()->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CDragon::movementCallback));
    getArmature()->getAnimation()->playByIndex(0);

    //-------------------------------------

    int t_direct    = CPath::DIRECT[CMath::getRandom(0, 3)][0];
    m_iDirect       = t_direct + CMath::getRandom(-30, 30);
    changeDirect(t_direct);
}
Exemple #3
0
void CDragon::startRandSkill()
{
    log("tpSkilllight->state+++");

    switch (m_pRandSkill->m_iSkillId)
    {
    case Skill::SKILL_T_LIGHTING:
        getArmature()->getAnimation()->play(PLAYLAB_DRAGON_MAGIC_SDY);
    break;
    case Skill::SKILL_T_TORNADO:
        getArmature()->getAnimation()->play(PLAYLAB_DRAGON_MAGIC_TORNADO);
    break;

    }
}
Exemple #4
0
void CDragon::changeDirect(int direct)
{
    std::map<int, const char*>::iterator it = m_oAngleTable.find(direct);
    if (it != m_oAngleTable.end())
    {
        const std::string& t_str = getArmature()->getAnimation()->getCurrentMovementID();
        if (strcmp(t_str.c_str(), PLAYLAB_DRAGON_MAGIC_SDY) == 0 
            || 
            strcmp(t_str.c_str(), PLAYLAB_DRAGON_MAGIC_TORNADO) == 0)
        {
            return;
        }
        getArmature()->getAnimation()->play(it->second);
    }
}
Exemple #5
0
//加载数据模型
void HeroBase::loadData(HeroModel* arg1)
{
    memcpy(m_HeroModel,arg1,sizeof(HeroModel));
    //加载动作文件
    loadActionFile(m_HeroModel->ActionFileModelID);
    //计算英雄数据
    UpgradeSystem::calculationHeroData(m_HeroModel);
    //计算英雄战力
    UpgradeSystem::calculationHeroPower(m_HeroModel, skills);
    
    //血条
    auto hpPos=PointFromString(m_HeroModel->HpPosition);
    m_HealthBar=HealthBarCompoment::create("imgs/xuetiao_beijing.png", "imgs/hero_xuetiao.png", "imgs/hero_xuetiao_2.png");
    m_HealthBar->setPosition(hpPos);
    m_HealthBar->setVisible(true);
    getArmature()->addChild(m_HealthBar,100);
    
    //加载阴影
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("guge/anxt_effect_10.plist");
    m_Shadow=Sprite::createWithSpriteFrameName("n_shadow_1.png");
    m_Shadow->setPosition(Vec2(0,-10));
    this->addChild(m_Shadow);
    
    auto hpSize=m_HealthBar->getContentSize();
    m_HealthBar->setScaleX(m_HeroModel->HpBarWidth / hpSize.width);
    
    heroAI->createBevTree();
}
Exemple #6
0
//普通攻击
std::string HeroKnight::commonAttack()
{
    m_vVelocity*=0.1;
    
    Vec2 diff=Vec2::ZERO;
    
    auto m_Armature=getArmature();
    std::string strAnimateName= m_Armature->getAnimation()->getCurrentMovementID();
    
    std::string strPlayName="";
    if (getAnimateState(getActionFileMode()->ActionAttackName1)==BaseActionObject::AnimateState::Runing) {
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.96) return getActionFileMode()->ActionAttackName1;
        strPlayName=getActionFileMode()->ActionAttackName2;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName2)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.94) return getActionFileMode()->ActionAttackName2;
        strPlayName=getActionFileMode()->ActionAttackName3;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName3)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.65) return getActionFileMode()->ActionAttackName3;
        strPlayName=getActionFileMode()->ActionAttackName4;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName4)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.99) return getActionFileMode()->ActionAttackName4;
        strPlayName=getActionFileMode()->ActionAttackName1;
    }else{
        strPlayName=getActionFileMode()->ActionAttackName1;
    }
    //log("strPlayName:%s",strPlayName.c_str());
    playAnimate(strPlayName);
    m_BodyState=GameEnum::BodyState::Attack;
    return strPlayName;
}
Exemple #7
0
void CDragon::movementCallback(Armature * armature, MovementEventType type, const std::string& name)
{
    if (type == MovementEventType::COMPLETE)
    {
        if (strcmp(name.c_str(), PLAYLAB_DRAGON_MAGIC_SDY) == 0)
        {
            CBoss::startRandSkill();
            getArmature()->getAnimation()->play(PLAYLAB_DRAGON_UP_WALK);
        }
        else if (strcmp(name.c_str(), PLAYLAB_DRAGON_MAGIC_TORNADO) == 0)
        {
            //释放龙卷风技能
            CBoss::startRandSkill();           
            getArmature()->getAnimation()->play(PLAYLAB_DRAGON_UP_WALK);
        }
    }
}
Exemple #8
0
//动画播放完成
void HeroBase::animateFinish(const std::string& name)
{
    BaseActionObject::animateFinish(name);
    
    if (name==getActionFileMode()->ActionDie) {
        m_BodyState=GameEnum::BodyState::Die;
        getArmature()->getAnimation()->stop();
        GameBLL::instance()->removeHero(this);
    }
}
    void CCDragonBones::setBoneTexture(const char* boneName, const char* textureName, const char* textureAtlasName)
    {

        Cocos2dxFactory* fac = Cocos2dxFactory::getInstance();
        Object* clothesObj = fac->getTextureDisplay(textureName, textureAtlasName);

        //CCLOG("CLOSE %d", clothesObj);

        Bone* bone = getArmature()->getBone(boneName);
        CocosNode* oldClothesObj = static_cast<CocosNode*>(bone->getDisplay());
        bone->setDisplay(clothesObj);
    }
Exemple #10
0
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;
}
Exemple #11
0
//普通攻击
std::string HeroBow::commonAttack()
{
    m_vVelocity*=0.1;
    
    Vec2 diff=Vec2::ZERO;
    
    auto m_Armature=getArmature();
    std::string strAnimateName= m_Armature->getAnimation()->getCurrentMovementID();
    
    std::string strPlayName="";
    if (getAnimateState(getActionFileMode()->ActionAttackName1)==BaseActionObject::AnimateState::Runing) {
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.6) return getActionFileMode()->ActionAttackName1;
        strPlayName=getActionFileMode()->ActionAttackName2;
        vShootPos.y=kDownShootPosY;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName2)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.6) return getActionFileMode()->ActionAttackName2;
        strPlayName=getActionFileMode()->ActionAttackName3;
        vShootPos.y=kShootPosY;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName3)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.6) return getActionFileMode()->ActionAttackName3;
        strPlayName=getActionFileMode()->ActionAttackName4;
        vShootPos.y=kFinishShootPosY;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName4)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.99) return getActionFileMode()->ActionAttackName4;
        strPlayName=getActionFileMode()->ActionAttackName1;
        vShootPos.y=kShootPosY;
    }else{
        strPlayName=getActionFileMode()->ActionAttackName1;
        vShootPos.y=kShootPosY;
    }
    playAnimate(strPlayName);
    m_BodyState=GameEnum::BodyState::Attack;
    return strPlayName;
}
Exemple #12
0
//减速效果
void HeroBase::animateSpeed(float ft)
{
    auto seq=Sequence::create(APArmSpeedAction::create(0.5*CCRANDOM_0_1(), 0.5*CCRANDOM_0_1()),APArmSpeedAction::create(0.5*CCRANDOM_0_1(), 1), NULL);
    getArmature()->runAction(seq);
}
Exemple #13
0
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;
}