char MessageBuilder::decodeFlags(String message){
	return base36ToInt(String(message.charAt(1)));
}
Пример #2
0
	void GameScene::start(float dt)
	{
		bool autoPlay = true;

		// apply loaded image
		for(auto it = mImageDictionary.begin(); it != mImageDictionary.end(); it++)
		{
			CCTexture2D* texture = new CCTexture2D();
			if(false == texture->initWithImage(it->second))
			{
				delete texture;
				continue;
			}

			mBgaDictionary[it->first] = texture;
		}

		for(auto it = mBmsDocument.channel().begin(); it != mBmsDocument.channel().end(); it++)
		{
			const std::string& channel = it->first;
			if(channel.find("01") != std::string::npos)
			{
				mChannelPlayers[channel] = new WaveChannelPlayer(it->second, mWavDictionary);
			}
			else if(channel.find("02") != std::string::npos)
			{
				//mChannelPlayers[channel] = new BarScaleChannelPlayer(it->second);
			}
			else if(channel.find("03") != std::string::npos)
			{
				mChannelPlayers[channel] = new BpmChannelPlayer(it->second);
			}
			else 
			{
				int iChannel = base36ToInt(channel.c_str());
				if(base36ToInt("10") < iChannel && iChannel < base36ToInt("70") && channel[1] != '0'/*exclude 20, 30, 40, ...*/)
				{
					int mappedKey = -1;
					for(int i=0; i<sizeof(keyChannelMap)/sizeof(keyChannelMap[0]); i++)
					{
						if(channel == keyChannelMap[i])
						{
							mappedKey = i;
							break;
						}
					}
					if(mappedKey < 0)
					{
						mChannelPlayers[channel] = new WaveChannelPlayer(it->second, mWavDictionary);
					}
					else
					{
						mChannelPlayers[channel] = new PlayChannelPlayer(it->second, mWavDictionary, Key::MappedKey(mappedKey), autoPlay);
					}
				}
				else if(
					base36ToInt(ChannelType::BGA_BASE) == iChannel ||
					base36ToInt(ChannelType::BGA_LAYER) == iChannel ||
					base36ToInt(ChannelType::BGA_LAYER2) == iChannel
					)
				{
					BgaChannelPlayer* bgaPlayer = new BgaChannelPlayer(it->second, mBgaDictionary, base36ToInt(ChannelType::BGA_POOR) == iChannel);
					mChannelPlayers[channel] = bgaPlayer;
					bgaPlayer->getSprite()->setContentSize(Size(640, 480));
					bgaPlayer->getSprite()->setPosition(Point(640, 480));
					addChild(bgaPlayer->getSprite());
				}
			}
		}

		{//panel
			// load skin
			CCTexture2D* skinTexture = CCTextureCache::sharedTextureCache()->addImage(Panel::SKIN_PATH);
			// no antialias
			skinTexture->setAliasTexParameters();

			CCNode* panel = CCNode::create();
			addChild(panel);

			Panel* frontPanel = new FrontPanel;
			Panel* backPanel = new BackPanel(mChannelPlayers);
			Panel* controlPanel = new ControlPanel;

			panel->addChild(backPanel);
			panel->addChild(frontPanel);
			panel->addChild(controlPanel);

			// fit panel to screen
			panel->setScale(CCDirector::sharedDirector()->getOpenGLView()->getDesignResolutionSize().height / 480);
		}

		mCurrentBpm = mBmsDocument.header().getBpm();

		//끝낼 마디 설정
		mEndPosition = 0;
		for(auto it = mBmsDocument.channel().begin(); it != mBmsDocument.channel().end(); it++)
		{
			if(it->second->endPosition() > mEndPosition)
				mEndPosition = it->second->endPosition();
		}
		mEndPosition += 1;

		// 시간 관련 초기화
		mLastBpmTime = mStartTime = currentTime();
		mLastBpmMeter = 0;
		origTime = mStartTime;// - 60000;
		origMadi = origPosit = 0;
		mBarScale = 1.0f;
		nowMadi = -1;

		// TODO 플레이노트 초기화(시간, 키 수 등)

		bMiss = false;
		bAuto = true;
		mScore = 0;
		mCombo = 0;

		// emit reset
		Event::GameConfigEvent configEvent(*mSong, 1, autoPlay, mStartTime);
		Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(Event::GameConfigEvent::RESET, &configEvent);
	}