Example #1
0
void CSector::Restock()
{
    ADDTOCALLSTACK("CSector::Restock");
    // ARGS: iTime = time in seconds
    // set restock time of all vendors in Sector.
    // set the respawn time of all spawns in Sector.

    CChar * pCharNext;
    CChar * pChar = dynamic_cast <CChar*>(m_Chars_Active.GetHead());
    for (; pChar; pChar = pCharNext)
    {
        pCharNext = pChar->GetNext();
        if (pChar->m_pNPC)
        {
            pChar->NPC_Vendor_Restock(true);
        }
    }

    CItem * pItemNext;
    CItem * pItem = dynamic_cast <CItem*>(m_Items_Timer.GetHead());
    for (; pItem; pItem = pItemNext)
    {
        pItemNext = pItem->GetNext();
        if (pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR) || pItem->IsType(IT_SPAWN_CHAMPION))
        {
            CCSpawn *pSpawn = pItem->GetSpawn();
            if (pSpawn)
            {
                pSpawn->OnTickComponent();
            }
        }
    }
}
Example #2
0
void ProgressBar::progressBy(float delta)
{
    float maxPercentage = 100.0f;

    bool isFinished = false;
    float nextPercentage = delta + this->getPercentage();
    if(nextPercentage >= maxPercentage){
        nextPercentage = maxPercentage;
        isFinished = true;
    }
    this->stopActionByTag(k_Progress_Action);
    CCArray *actions = CCArray::createWithCapacity(2);
    float duration = delta/this->getSpeed();
    CCProgressTo* to = CCProgressTo::create(duration, nextPercentage);
    actions->addObject(to);
    if(isFinished){
        CCCallFunc* callfunc = CCCallFunc::create(this, callfunc_selector(ProgressBar::loadingFinished));
        actions->addObject(callfunc);
    }
    CCFiniteTimeAction* seq = CCSequence::create(actions);
    
    CCCallFunc* updatePercentage = CCCallFunc::create(this, callfunc_selector(ProgressBar::updatePercentage));
    updatePercentage->setDuration(duration);

    CCSpawn* spawn = CCSpawn::createWithTwoActions(seq, updatePercentage);
    spawn->setTag(k_Progress_Action);
    
    this->runAction(spawn);
}
CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2)
{
	CCSpawn *pSpawn = new CCSpawn();
	pSpawn->initOneTwo(pAction1, pAction2);
	pSpawn->autorelease();

	return pSpawn;
}
CCSpawn* CCSpawn::createWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2)
{
	CCSpawn *pSpawn = new CCSpawn();
	pSpawn->initWithTwoActions(pAction1, pAction2);
	pSpawn->autorelease();

	return pSpawn;
}
Example #5
0
void GameScene::raisePig()
{
    if (!m_Crashed)
    {
        const float tapRaiseHeight = 80;
        float raiseHeight = MIN(tapRaiseHeight, m_VisibleOrigin.y + m_VisibleSize.height - m_pPig->getPositionY() - m_pPig->getContentSize().height / 2);

        CCActionInterval* raiseEaseOut = CCEaseSineOut::create(CCMoveBy::create(0.4f * raiseHeight / tapRaiseHeight, ccp(0, raiseHeight)));
        CCSpawn *action = CCSpawn::createWithTwoActions(raiseEaseOut, CCRotateTo::create(0.1f, -25));
        action->setTag(kTagRaise);

        m_pPig->stopActionByTag(kTagRaise);
        m_pPig->runAction(action);

        m_fFallVelocity = 0;
    }
}
CCObject* CCSpawn::copyWithZone(CCZone *pZone)
{
	CCZone* pNewZone = NULL;
	CCSpawn* pCopy = NULL;

	if(pZone && pZone->m_pCopyObject) 
	{
		//in case of being called at sub class
		pCopy = (CCSpawn*)(pZone->m_pCopyObject);
	}
	else
	{
		pCopy = new CCSpawn();
		pZone = pNewZone = new CCZone(pCopy);
	}

	CCActionInterval::copyWithZone(pZone);

	pCopy->initOneTwo((CCFiniteTimeAction*)(m_pOne->copy()->autorelease()), 
					(CCFiniteTimeAction*)(m_pTwo->copy()->autorelease()));

	CC_SAFE_DELETE(pNewZone);
	return pCopy;
}