Example #1
0
void Viewport::beginZoom(const Vec2& point1, const Vec2& point2)
{
    CC_ASSERT(this->m_TargetNode);
    mZoomFingersDistance = point1.getDistance(point2);
    if (mForceStopScroll || !mMovable) {
        mWSZoomCenter = Vec2(Director::getInstance()->getWinSize().width/2, Director::getInstance()->getWinSize().height/2);
    }
    else {
        mWSZoomCenter = point1.getMidpoint(point2);
    }
    mNSZoomCenter = this->m_TargetNode->convertToNodeSpace(mWSZoomCenter);
    
    mZoomOldScale = this->m_TargetNode->getScale();
    mOperationStartPostition = this->m_TargetNode->getPosition();
    
    if (mBeginZoomHandler) {
        pushValueToLua(mBeginZoomHandler, point1, point2);
    }
}
Example #2
0
NS_CC_BEGIN

#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)

int PhysicsWorld::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data)
{
    PhysicsWorld* world = static_cast<PhysicsWorld*>(data);
    
    CP_ARBITER_GET_SHAPES(arb, a, b);
    
    auto ita = PhysicsShapeInfo::map.find(a);
    auto itb = PhysicsShapeInfo::map.find(b);
    CC_ASSERT(ita != PhysicsShapeInfo::map.end() && itb != PhysicsShapeInfo::map.end());
    
    PhysicsContact* contact = PhysicsContact::create(ita->second->shape, itb->second->shape);
    arb->data = contact;
    
    return world->collisionBeginCallback(*static_cast<PhysicsContact*>(arb->data));
}
 void TitleBarLayer::onEnter() {
     CCLayer::onEnter();
     
     Game* game = UserProfile::sharedUserProfile()->findGame(GlobalData::sharedGlobalData()->currentGameId());
     CC_ASSERT(game != NULL);
     const Question& question = game->question();
     const Question::Word& word = question.word(GlobalData::sharedGlobalData()->currentDifficult());
     std::ostringstream oss;
     oss << game->otherPlayerName() << "正在为你绘制" << word.word;
     
     CCLabelTTF* desc = static_cast<CCLabelTTF*>(getChildByTag(kTagDescriptLabel));
     desc->setString(oss.str().c_str());
     
     oss.str("");
     oss << std::setw(2) << std::setfill('0') << (game->turn());
     
     CCLabelTTF* turn = static_cast<CCLabelTTF*>(getChildByTag(kTagTurnLabel));
     turn->setString(oss.str().c_str());
 }
Example #4
0
void Ref::printLeaks()
{
    // Dump Ref object memory leaks
    if (__refAllocationList.empty())
    {
        log("[memory] All Ref objects successfully cleaned up (no leaks detected).\n");
    }
    else
    {
        log("[memory] WARNING: %d Ref objects still active in memory.\n", (int)__refAllocationList.size());

        for (const auto& ref : __refAllocationList)
        {
            CC_ASSERT(ref);
            const char* type = typeid(*ref).name();
            log("[memory] LEAK: Ref object '%s' still active with reference count %d.\n", (type ? type : ""), ref->getReferenceCount());
        }
    }
}
Example #5
0
bool CBackgroundManager::isRoleCanBePlacedOnPos(IGridRole* role, const Point& gridPos, bool lock)
{
    CC_ASSERT(role);
    int width = role->getGridWidth();
    int height = role->getGridHeight();

    Point pt;
    int x, y;
    for (y = 0; y < height; ++y)
    {
        for (x = 0; x < width; ++x)
        {
            pt.x = gridPos.x + x;
            pt.y = gridPos.y + y;
            CLogicGrid* g = getLogicGrid(pt);

            bool condi = (g == nullptr);
            condi = (condi || g->m_locked == true || (g != nullptr && g->m_unit != nullptr && g->m_unit != role));
            if (condi)
            {
                return false;
            }
        }
    }

    if (lock)
    {
        for (y = 0; y < height; ++y)
        {
            for (x = 0; x < width; ++x)
            {
                pt.x = gridPos.x + x;
                pt.y = gridPos.y + y;
                CLogicGrid* g = getLogicGrid(pt);
                
                g->setLock(true);
            }
        }
    }
    
	return true;
}
Example #6
0
void BattleData::PetsPlayCard(int side, int index, bool combine, CallBackWithVoid callback) //positino
{
	CC_ASSERT((side == 0 || side == 1) && (index >=0 && index < 5), "Side, index is wrong");
	if (!m_bPets[side][index] || m_bPets[side][index]->IsDead() || m_bPets[side][index]->moved() || !m_bPets[side][index]->canPlayCard())
	{
		return;
	}
	const ATTRIBUTIONS ccard = m_bPets[side][index]->m_handCard;
	BattlePet * target = GetCurrentTarget(m_bPets[side][index]);
	if (combine)
	{
		std::vector<int> combines = GetCombinePets(side, index);
		const int clength = combines.size();
		int cindex = 0;
		for (int j = 0; j < clength; ++j)
		{
			cindex = combines[j];
			m_bPets[side][cindex]->AttackByCombineSkill(target, clength);
			m_bPets[side][cindex]->m_handCard = ATTRIBUTE_RELATIONS_Empty;
			m_bPets[side][cindex]->moved(1);
		}
	}
	else
	{
		m_bPets[side][index]->AttackBySkill(target);
		m_bPets[side][index]->m_handCard = ATTRIBUTE_RELATIONS_Empty;
		m_bPets[side][index]->moved(1);
	}

	if (ccard != ATTRIBUTE_RELATIONS_ALL)
	{
		m_TableCard = ccard;
		BattleEngine::GetInstance()->dispatchEventWithType(BattleMessage_TableCardUpdate, nullptr);
	}

	PetCarsEvent e(callback);
	e.index = -1;
	e.side = -1;
	BattleEngine::GetInstance()->dispatchEvent(&e);

	SetTarget(m_bPets[side][index]->m_attackSide, -1, true, m_bPets[side][index]);
}
Example #7
0
	void ScoresController::SetSearchCriteria(ScoresController* self, SearchCriteria::Enum criteria)
	{
		char method_name[256] = "";
		switch (criteria)
		{
		case SearchCriteria::Global:
			strcpy(method_name, "getGlobalScoreSearchList");
			break;
		case SearchCriteria::TwentyFourHour:
			strcpy(method_name, "getTwentyFourHourScoreSearchList");
			break;
		case SearchCriteria::UserCountry:
			strcpy(method_name, "getUserCountryLocationScoreSearchList");
			break;
		case SearchCriteria::BuddyhoodOnly:
			strcpy(method_name, "getBuddiesScoreSearchList");
			break;
		}

		CC_ASSERT(strlen(method_name) > 0);
		
		jobject search_list = NULL;
		JniMethodInfo t;
        if (JniHelper::getStaticMethodInfo(t,
            "com.scoreloop.client.android.core.model.SearchList",
            method_name,
            "()Lcom/scoreloop/client/android/core/model/SearchList;"))
		{
			search_list = t.env->CallStaticObjectMethod(t.classID, t.methodID);
			t.env->DeleteLocalRef(t.classID);
		}

		if (search_list != NULL &&
			JniHelper::getMethodInfo(t,
					"com.scoreloop.client.android.core.controller.ScoresController",
					"setSearchList",
					"(Lcom/scoreloop/client/android/core/model/SearchList;)V"))
		{
			t.env->CallVoidMethod((jobject)self, t.methodID, search_list);
			t.env->DeleteLocalRef(t.classID);
		}
	}
Example #8
0
void VM_GetNibblePort(void)
{
    uint8 port, data;

    port = LOBYTE(VM_PopW()) & NIBBLE_PORT_MASK;

    switch (port) {
        case 0: case 1:
            data = HAL_BYTE_PORT0;
            break;
        case 2: case 3:
            data = HAL_BYTE_PORT1;
            break;
        default:
            CC_ASSERT(FALSE, ERROR_ILLOPA);
    }

    if ((port & ((uint8)0x01)) == ((uint8)0x1)) {
        data >>= 4;
    }
Example #9
0
void ButtonEx::updateTexture() {
    int counter = 0;

    if (_normalTextureAdaptDirty && isBright() &&
        _brightStyle == BrightStyle::NORMAL) {
        onPressStateChangedToNormal();
        ++counter;
    }
    if (_pressedTextureAdaptDirty && isBright() &&
        _brightStyle == BrightStyle::HIGHLIGHT) {
        onPressStateChangedToPressed();
        ++counter;
    }
    if (_disabledTextureAdaptDirty && not isBright()) {
        onPressStateChangedToDisabled();
        ++counter;
    }

    CC_ASSERT(counter <= 1);
}
Example #10
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    CC_ASSERT(GameScene::sharedGameScene());

    // run
    pDirector->runWithScene(GameScene::sharedGameScene());

    return true;
}
Example #11
0
void BattleData::PetsNomalAtt(int side, int index, CallBackWithVoid callback)
{
	CC_ASSERT((side == 0 || side == 1) && (index >= 0 && index < 5), "Side, index is wrong");
	if (!m_bPets[side][index] || m_bPets[side][index]->IsDead() || m_bPets[side][index]->moved())
	{
		return;
	}

	BattlePet * target = GetCurrentTarget(m_bPets[side][index]);
	m_bPets[side][index]->Attack(target);
	m_bPets[side][index]->m_handCard = ATTRIBUTE_RELATIONS_Empty;
	m_bPets[side][index]->moved(1);

	PetCarsEvent e(callback);
	e.index = -1;
	e.side = -1;
	BattleEngine::GetInstance()->dispatchEvent(&e);

	SetTarget(m_bPets[side][index]->m_attackSide, -1, true, m_bPets[side][index]);
}
Example #12
0
	bool CCScrollLayer::initWithLayers(CCArray* layers, int widthOffset)
	{
		if (!CCLayer::init())
			return false;
		CC_ASSERT(layers && layers->count());
		
		setTouchEnabled(true);
        
		m_bStealTouches = true;
		
		// Set default minimum touch length to scroll.
		m_fMinimumTouchLengthToSlide = 30.0f;
		m_fMinimumTouchLengthToChangePage = 100.0f;
		
		m_fMarginOffset = CCDirector::sharedDirector()->getWinSize().width;
        
		// Show indicator by default.
		m_bShowPagesIndicator = true;
		m_tPagesIndicatorPosition = ccp(0.5f * m_obContentSize.width, ceilf(m_obContentSize.height / 8.0f));
        
		// Set up the starting variables
		m_uCurrentScreen = 0;
        
		// Save offset.
		m_fPagesWidthOffset = (CGFloat)widthOffset;
        
		// Save array of layers.
        // Can't use createWithArray because layer does not implemnt CCCopying
		// m_pLayers = CCArray::createWithArray(layers);
        m_pLayers = CCArray::create();
        m_pLayers->addObjectsFromArray(layers);
		layers->release();
		m_pLayers->retain();
        
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        this->setRectLayer(CCRect(0, 0, size.width, size.height));
        
		updatePages();
        
		return true;
	}
Example #13
0
//切换庄家
bool CDanShuangGame::OnSubChangeBanker(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	CC_ASSERT(wDataSize==sizeof(CMD_S_ChangeBanker));
	if (wDataSize!=sizeof(CMD_S_ChangeBanker)) return false;

	//消息处理
	CMD_S_ChangeBanker * pChangeBanker=(CMD_S_ChangeBanker *)pBuffer;

	WORD wPrevBanker = m_wCurrentBanker;	//备份上个庄家

	//自己判断
	if (m_wCurrentBanker == m_pDirector->m_nMeChairID && pChangeBanker->wBankerUser != m_pDirector->m_nMeChairID) 
	{
		m_bMeApplyBanker=false;
	}
	else if (pChangeBanker->wBankerUser == m_pDirector->m_nMeChairID)
	{
		m_bMeApplyBanker=true;
	}

	//庄家信息
	SetBankerInfo(pChangeBanker->wBankerUser, pChangeBanker->lBankerScore);

	//显示图片
	m_pDanShuangGameView->ShowChangeBanker(wPrevBanker != pChangeBanker->wBankerUser);
	m_pDanShuangGameView->SetBankerScore(0, 0);

	//删除上庄列表玩家
	if (m_wCurrentBanker!=INVALID_CHAIR)
	{
		tagApplyUser ApplyUser;
		ApplyUser.wChairID = m_wCurrentBanker;
		m_pDanShuangGameView->CancelApplyBanker(ApplyUser);
	}

	//更新控件
	UpdateButtonControl();

	return true;
}
Example #14
0
void CFBMatch::teamPositionAck(int side, const vector<float>& p, int ballPlayerId, unsigned int timeStamp)
{
    auto team = m_teams[side];
    
    int size = team->getPlayerNumber();
    
    if (timeStamp == 0)     // timeStamp为0表示暂停时候的强制同步
    {
        for (int i = 0; i < size; ++i)
        {
            Point pos(p[i * 4], p[i * 4 + 1]);
            Point vec(p[i * 4 + 2], p[i * 4 + 3]);
            auto player = team->getPlayer(i);
            
            player->loseBall();
            player->setPosition(pos);
            player->setMovingVector(vec);
        }
        
        if (ballPlayerId != -1)
        {
            team->getPlayer(ballPlayerId)->gainBall();
        }
    }
    else
    {
        float dt = m_proxy->getDeltaTime(timeStamp);
        
        for (int i = 0; i < size; ++i)
        {
            Point pos(p[i * 4], p[i * 4 + 1]);
            Point vec(p[i * 4 + 2], p[i * 4 + 3]);
            auto player = team->getPlayer(i);

            player->moveFromTo(pos, vec, dt, m_SYNC_TIME);
        }
        
        CC_ASSERT(team == m_teamsInMatch[(int)SIDE::OPP]);
        m_syncTime[(int)SIDE::OPP] = m_SYNC_TIME;
    }
}
Example #15
0
void Live2dXSprite::runAnimation(string name)
{
    map<string, Live2dX_Anims>::iterator iter = m_all_anims.find(name);
    CC_ASSERT(iter != m_all_anims.end());
    m_animNowTime = 0;
    m_nowVertex = m_orginVertex;
    m_animTime = 0;
    
    m_curAnims = &iter->second;
    for (Live2dX_Anims::iterator iter2 = m_curAnims->begin();
         iter2 != m_curAnims->end(); ++iter2)
    {
        float time = iter2->delay+iter2->time;
        if (time > m_animTime)
        {
            m_animTime = time;
        }
    }
    CCTime::gettimeofdayCocos2d(&m_nowTime, NULL);
    m_isAnimation = true;
}
Example #16
0
bool DataCenter::loadDamageFactorMap(void)
{
	m_mapDamageFactor.clear();

	std::string str = FileUtils::getInstance()->fullPathForFilename("damage_factor.xml");
	tinyxml2::XMLDocument doc;
	auto data = FileUtils::getInstance()->getDataFromFile(str);
	auto ret = doc.Parse((const char*)data.getBytes(), data.getSize());
	//auto ret = doc.LoadFile(str.c_str());
	if (ret != tinyxml2::XML_NO_ERROR)
	{
		return false;
	}

	const tinyxml2::XMLElement* e_root = nullptr;
	const tinyxml2::XMLElement* e_child_1 = nullptr;
	const tinyxml2::XMLElement* e_child_2 = nullptr;
	float factor = 0.0f;

	e_root = doc.RootElement();
	CC_ASSERT(e_root != nullptr);

	for (e_child_1 = e_root->FirstChildElement();
		e_child_1 != nullptr;
		e_child_1 = e_child_1->NextSiblingElement())
	{
		int armor_type = getCommonType(e_child_1->Value());

		for (e_child_2 = e_child_1->FirstChildElement();
			e_child_2 != nullptr;
			e_child_2 = e_child_2->NextSiblingElement())
		{
			int proj_type = getCommonType(e_child_2->Value());
			e_child_2->QueryFloatText(&factor);
			m_mapDamageFactor[armor_type][proj_type] = factor;
		}
	}

	return true;
}
jsval CFBFunctionsJS::callJSFunc(const char* name, const char* format, ...)
{
    int count = (int)strlen(format);
    jsval* argv = new jsval[count];
    va_list insvalist;
    va_start(insvalist, format);
    for (int i = 0; i < count; ++i)
    {
        switch (format[i])
        {
            case 'j': // jsval
                argv[i] = va_arg(insvalist, jsval);
                break;
            case 'b':   // bool
                argv[i] = BOOLEAN_TO_JSVAL(va_arg(insvalist, int));
                break;
            case 'd':   // int
                argv[i] = INT_TO_JSVAL(va_arg(insvalist, int));
                break;
            case 'f':   //float
                argv[i] = DOUBLE_TO_JSVAL(va_arg(insvalist, double));
                break;
            case 's':   // c style string
                argv[i] = c_string_to_jsval(_cx, va_arg(insvalist, const char*));
                break;
            default:
                CC_ASSERT(false);
        }
    }
    va_end(insvalist);
    
    
    jsval res;
    JSAutoCompartment ac(_cx, _go);
    JS_CallFunctionName(_cx, _go, name, count, argv, &res);
    
    auto sc = ScriptingCore::getInstance();
    sc->forceGC(_cx, 0, nullptr);
    return res ;
}
Example #18
0
std::vector<std::string> CCNativeKeyValueStorage::getEncryptedKeys() const {
    CCError* error = nullptr;
    std::vector<std::string> encryptedKeys;
    
    ValueMap params;
    params["method"] = "CCNativeKeyValueStorage::getEncryptedKeys";
    
    ValueMap&& retParams = CCNdkBridge::callNative(params, &error);

    if (error || retParams.size() == 0 || not retParams.count("return")) {
        CCSoomlaUtils::logException(TAG, error);
        CC_ASSERT(false);
        return encryptedKeys;
    }
    
    auto& retValue = retParams.at("return").asValueVector();
    for (auto value : retValue) {
        encryptedKeys.push_back(value.asString());
    }
    
    return encryptedKeys;
}
Example #19
0
void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info)
{
    if (!PhysicsWorldCallback::continues)
    {
        return;
    }
    
    auto it = PhysicsShapeInfo::getMap().find(shape);
    CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
    
    PhysicsRayCastInfo callbackInfo =
    {
        it->second->getShape(),
        info->p1,
        info->p2,
        Point(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t),
        Point(n.x, n.y),
        (float)t,
    };
    
    PhysicsWorldCallback::continues = info->func(*info->world, callbackInfo, info->data);
}
void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha, RayCastCallbackInfo *info)
{
    if (!PhysicsWorldCallback::continues)
    {
        return;
    }
    
    PhysicsShape *physicsShape = static_cast<PhysicsShape*>(cpShapeGetUserData(shape));
    CC_ASSERT(physicsShape != nullptr);
    
    PhysicsRayCastInfo callbackInfo =
    {
        physicsShape,
        info->p1,
        info->p2,
        PhysicsHelper::cpv2point(point),
        PhysicsHelper::cpv2point(normal),
        static_cast<float>(alpha),
    };
    
    PhysicsWorldCallback::continues = info->func(*info->world, callbackInfo, info->data);
}
Example #21
0
void DealCardsE::excute(CallBackWithVoid callback)
{
	CC_ASSERT(m_position >= 0 || m_position <= 2);
	if (m_position == 0)
	{
		BattleData::GetInstance()->DealTableCard(callback);
	}
	else if (m_position == 1 || m_position == 2)
	{
		BattleData::GetInstance()->DealPetsCards(m_position - 1, callback);
	}
	else if (m_position == 3 || m_position == 4)
	{
		BattleData::GetInstance()->ResetPetsCards(m_position - 3, callback);
	}
	else
	{
		callback();
	}
	//call callback() directly to avoid waiting for animation
	//callback();
}
void RenderState::StateBlock::cloneInto(StateBlock* state) const
{
    CC_ASSERT(state);

    state->_cullFaceEnabled = _cullFaceEnabled;
    state->_depthTestEnabled = _depthTestEnabled;
    state->_depthWriteEnabled = _depthWriteEnabled;
    state->_depthFunction = _depthFunction;
    state->_blendEnabled = _blendEnabled;
    state->_blendSrc = _blendSrc;
    state->_blendDst = _blendDst;
    state->_cullFaceSide = _cullFaceSide;
    state->_frontFace = _frontFace;
    state->_stencilTestEnabled = _stencilTestEnabled;
    state->_stencilWrite = _stencilWrite;
    state->_stencilFunction = _stencilFunction;
    state->_stencilFunctionRef = _stencilFunctionRef;
    state->_stencilFunctionMask = _stencilFunctionMask;
    state->_stencilOpSfail = _stencilOpSfail;
    state->_stencilOpDpfail = _stencilOpDpfail;
    state->_stencilOpDppass = _stencilOpDppass;
    state->_bits = _bits;
}
string EncryptionHandler::singleDecrypt(const string& cryptedMsg)
{
    DES des;
    des.SetKey(DES_KEY, 8);
    des.ProduceSubKey();
    
    CC_ASSERT(cryptedMsg.size() <= 8);
    for (int i = 0; i < cryptedMsg.size(); i++)
    {
        des.cryptedmsg[i] = cryptedMsg[i];
    }
    des.Char2Bit(des.cryptedmsg, des.bcryptedmsg, 8);
    
    des.Decipher();
    
    char msg[9] = {0};
    for (int i = 0; i < 8; i++)
    {
        msg[i] = des.decipher[i];
    }
    
    return string(msg);
}
Example #24
0
int BattleData::GetCombinePetsNum(int side, int index)
{
	CC_ASSERT((side == 0 || side == 1) && (index >= 0 && index < FIGHT_PETS_MAX_NUMBER), "Side, index is wrong");
	if (!m_bPets[side][index])
	{
		return 0;
	}
	int retNum = 0;
	const ATTRIBUTIONS ccard = m_bPets[side][index]->m_handCard;
	if (BATTLE_CARD_BEGOOD != CanPetPlayCard(side, index))
	{
		return retNum;
	}
	retNum = 1; //self
	for (int j = 0; j < FIGHT_PETS_MAX_NUMBER; ++j)
	{
		if (m_bPets[side][j] && j != index  && !(m_bPets[side][j]->IsDead() || m_bPets[side][j]->moved() || !m_bPets[side][j]->canPlayCard()) && CanCombineByNum(ccard, m_bPets[side][j]->m_handCard))
		{
			++retNum;
		}
	}
	return retNum;
}
Example #25
0
//取消做庄
bool CDanShuangGame::OnSubUserCancelBanker(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	CC_ASSERT(wDataSize==sizeof(CMD_S_CancelBanker));
	if (wDataSize!=sizeof(CMD_S_CancelBanker)) return false;

	//消息处理
	CMD_S_CancelBanker * pCancelBanker=(CMD_S_CancelBanker *)pBuffer;

	//删除玩家
	tagApplyUser ApplyUser;
	ApplyUser.wChairID = pCancelBanker->wCancelUser;
	m_pDanShuangGameView->CancelApplyBanker(ApplyUser);

	//自己判断
	if (m_pDirector->m_nMeChairID == pCancelBanker->wCancelUser)
		m_bMeApplyBanker = false;

	//更新控件
	UpdateButtonControl();

	return true;
}
Example #26
0
void COxCJ4UILayer::SetJettonValue(int nCount, LONGLONG lJetton[], bool bEnable[])
{
	if (nCount != CountArray(m_pBtnJetton))
	{
		CC_ASSERT(false);
		return ;
	}

	for (BYTE i = 0; i < nCount; ++i)
	{
		if (m_pJettonValue[i])
		{
			char szValue[64] = {0};
			snprintf(szValue, 64, "%lld", lJetton[i]);

			m_pJettonValue[i]->setString(szValue);
		}
		if(m_pBtnJetton[i])
		{
			m_pBtnJetton[i]->setEnabled(bEnable[i]);
		}
	}
}
Example #27
0
int BattleData::GetMaxPlayCardNum(int side, int index, ATTRIBUTIONS table, bool moved[FIGHT_PETS_MAX_NUMBER])
{
	CC_ASSERT((side == 0 || side == 1) && (index >= 0 && index < FIGHT_PETS_MAX_NUMBER), "Side, index is wrong");
	if (!m_bPets[side][index] || moved[index] || BATTLE_CARD_BEGOOD != CanPlayCardByNumber(m_bPets[side][index]->m_handCard, table))
	{
		return 0;
	}
	
	int ret = 1;
	moved[index] = true;
	table = m_bPets[side][index]->m_handCard;
	int num(0), maxNum(-1);
	for (int j = 0; j < FIGHT_PETS_MAX_NUMBER; ++j)
	{
		num = GetMaxPlayCardNum(side, j, table, moved);
		if (maxNum < num)
		{
			maxNum = num;
		}
	}

	ret += maxNum;
}
Example #28
0
//游戏抛币
bool CDanShuangGame::OnSubGameAnimation(const void * pBuffer, WORD wDataSize)
{
	//效验数据
	CC_ASSERT(wDataSize==sizeof(CMD_S_GameAnimation));
	if (wDataSize!=sizeof(CMD_S_GameAnimation)) return false;

	//消息处理
	CMD_S_GameAnimation * pGameAnimation=(CMD_S_GameAnimation *)pBuffer;

	//设置时间
	m_pDanShuangGameView->SetGameTime(pGameAnimation->cbTimeLeave, GS_GAME_ANIMATION);

	//设置状态
	m_nGameStatus = GS_GAME_ANIMATION;

	//进行抛币动画
	m_pDanShuangGameView->BeginThrowCoin(true);

	//更新控件
	UpdateButtonControl(false);

	return true;
}
 void CCEquippableVG::putEquippingModelToDict(CCDictionary *dict) {
     EquippingModel equippingModel = (EquippingModel) getEquippingModel()->getValue();
     CCString *strEquippingModel;
     switch (equippingModel) {
         case kLocal: {
             strEquippingModel = CCString::create(EQUIPPING_MODEL_LOCAL);
             break;
         }
         case kCategory: {
             strEquippingModel = CCString::create(EQUIPPING_MODEL_CATEGORY);
             break;
         }
         case kGlobal: {
             strEquippingModel = CCString::create(EQUIPPING_MODEL_GLOBAL);
             break;
         }
         default: {
             CC_ASSERT(false);
             strEquippingModel = CCString::create("ERROR");
         }
     }
     dict->setObject(strEquippingModel, JSON_EQUIPPABLE_EQUIPPING);
 }
int CCLuaStack::executeScriptFile(const char* filename)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    std::string code("require \"");
    code.append(filename);
    code.append("\"");
    return executeString(code.c_str());
#else
    ++m_callFromLua;
    int nRet = luaL_dofile(m_state, filename);
    --m_callFromLua;
    CC_ASSERT(m_callFromLua >= 0);
    // lua_gc(m_state, LUA_GCCOLLECT, 0);
    
    if (nRet != 0)
    {
        CCLOG("[LUA ERROR] %s", lua_tostring(m_state, -1));
        lua_pop(m_state, 1);
        return nRet;
    }
    return 0;
#endif
}