예제 #1
0
void StarMatrix::deleteSelectedList()
{
	if(selectedList.size() <= 1)
	{
		m_layer->hideLinkNum();
		selectedList.at(0)->setSelected(false);
		return;
	}

	for(auto it = selectedList.begin();it != selectedList.end();it++)
	{
		Star* star = *it;

		showStarParticleEffect(star->getColor(),star->getPosition(),this);
		stars[star->getIndexI()][star->getIndexJ()] = nullptr;
		star->removeFromParentAndCleanup(true);

		Audio::getInstance()->playPop();
	}

	showComboEffect(selectedList.size(),this);
	Audio::getInstance()->playCombo(selectedList.size());

	refreshScore();
	m_layer->showLinkNum(selectedList.size());
	adjustMatrix();

	if(isEnded())
	{
		m_layer->floatLeftStarMsg(getLeftStarNum());
		CCLOG("ENDED");
	}

}
예제 #2
0
void StarMatrix::deleteSelectedList(){
	//播放消除音效
	Audio::getInstance()->playPop();

	for(auto it = selectedList.begin();it != selectedList.end();it++){
		Star* star = *it;
		m_layer->showEveryScore(selectedListSize,5+(selectedListSize-selectedList.size())*5,selectedListSize-selectedList.size(),star->getPosition(),touchLeft);
		selectedList.pop_front();
		//粒子效果
		showStarParticleEffect(star->getColor(),star->getPosition(),this);
		stars[star->getIndexI()][star->getIndexJ()] = nullptr;
		star->removeFromParentAndCleanup(true);
		return;
	}
	clearOneByOne =false;
	//COMBO效果
	showComboEffect(selectedListSize,this);
	m_layer->showLinkNum(selectedListSize);
	selectedListSize=0;
	acceptTouch =true;
	adjustMatrix();
	if(isEnded()){
		acceptTouch=false;
		m_layer->hideProps();
		m_layer->floatLeftStarMsg(getLeftStarNum());//通知layer弹出剩余星星的信息
		CCLOG("ENDED");
	}
}
예제 #3
0
void StarMatrix::deleteBombList(){
	//播放消除音效
	Audio::getInstance()->playPropBomb();
	for(auto it = selectedList.begin();it != selectedList.end();it++){
		Star* star = *it;
		//粒子效果
		showStarParticleEffect(star->getColor(),star->getPosition(),this);
		stars[star->getIndexI()][star->getIndexJ()] = nullptr;
		star->removeFromParentAndCleanup(true);
	}
	selectedList.clear();
	//COMBO效果
	selectedListSize=0;
	acceptTouch =true;
	adjustMatrix();
	if(isEnded()){
		acceptTouch=false;
		m_layer->hideProps();
		m_layer->floatLeftStarMsg(getLeftStarNum());
	}
}
예제 #4
0
void StarMatrix::doHammer(Star* s){
	selectedList.clear();
	selectedList.push_back(s);
	//播放消除音效
	Audio::getInstance()->playPropBomb();
	selectedList.pop_front();
	m_layer->showEveryScore(selectedListSize,5+(selectedListSize-selectedList.size())*5,selectedListSize-selectedList.size(),s->getPosition(),touchLeft);
	//粒子效果
	showStarParticleEffect(s->getColor(),s->getPosition(),this);
	stars[s->getIndexI()][s->getIndexJ()] = nullptr;
	s->removeFromParentAndCleanup(true);
	m_layer->showLinkNum(selectedListSize);

	selectedListSize=0;
	acceptTouch =true;
	adjustMatrix();
	if(isEnded()){
		acceptTouch=false;
		m_layer->hideProps();
		m_layer->floatLeftStarMsg(getLeftStarNum());//通知layer弹出剩余星星的信息
		CCLOG("ENDED");
	}
}
예제 #5
0
void PopStar::onReduce()
{
	if (!gameLayer)
	{
		return;
	}

	int num = selectStars.size();
	int score = getPopStarDataMgr().getScore() + getPopStarDataMgr().getScoreByReduceNum(num);
	setScore(score);
	
	StarListIter iter;
	for (iter = selectStars.begin(); iter != selectStars.end(); ++iter)
	{
		gameLayer->removeChild(iter->star);
		stars[iter->row][iter->col] = NULL;
	}
	selectStars.clear();


	// 竖直调整
	for (int row = 0; row < ROW_NUM; ++row)
	{
		for (int col = 0; col < COL_NUM; ++col)
		{
			int tempRow = row;
			Star* star = stars[row][col];
			if (star)
			{
				continue;
			}
			else
			{
				while (!star && (tempRow < ROW_NUM))
				{
					star = stars[tempRow][col];
					if (star)
					{
						break;
					}
					++tempRow;
				}

				if (star)
				{
					stars[row][col] = stars[tempRow][col];
					stars[tempRow][col] = NULL;
				}
			}
		}
	}

	while (isNeedHoriAdjust())
	{
		int endCol = getCheckEndCol();
		for (int col = 0; col <= endCol; ++col)
		{
			if (!stars[0][col])
			{
				for (int i = col; i < endCol; ++i)
				{
					for (int row = 0; row < ROW_NUM; ++row)
					{
						stars[row][i] = stars[row][i+1];
					}
				}

				for (int row = 0; row < ROW_NUM; ++row)
				{
					stars[row][endCol] = NULL;
				}
				
				break;
			}
		}
	}


	// 刷新位置
	for (int row = 0; row < ROW_NUM; ++row)
	{
		for (int col = 0; col < COL_NUM; ++col)
		{
			Star* star = stars[row][col];
			if (star)
			{
				star->setDestPos(ccp(STAR_WIDTH*col + STAR_WIDTH/2, STAR_HEIGHT*row + STAR_HEIGHT/2));
			}
		}
	}

	if (isLevelEnd())
	{
		int num = getLeftStarNum();
		int score = getPopStarDataMgr().getScore() + getPopStarDataMgr().getScoreByLeftNum(num);
		setScore(score);

		int historyScore = getPopStarDataMgr().getHistoryScore();
		if (score > historyScore)
		{
			setHistoryScore(score);
		}

		int level = getPopStarDataMgr().getLevel();
		int historyLevelScore = getPopStarDataMgr().getHistoryLevelScoreByLevel(level);
		if (score > historyLevelScore)
		{
			setHistoryLevelScore(score);
		}
		

		if (isGameOver()) // 游戏结束
		{
			changeState( new GameOverState(this) );
		}
		else // 下一等级
		{
			changeState( new GamePassLevelState(this) );
		}
	}
}