Example #1
0
////////////////////////////////////////////////////////////////////////////////
/// \brief      Rangking 값을 읽어와 표시
////////////////////////////////////////////////////////////////////////////////
void JS_Result::displayRanking(float dt)
{
	// CCUserDefault 에서 key값으로 랭킹값을 읽어서 순위를 표시한다.
	SANG_GAME_RANK rank[JS_MAX_RANK];

	SANG_RANK_KEY key[JS_MAX_RANK];
	
	for ( int k = 0; k < JS_MAX_RANK; k++ )
	{
		if ( EASY == m_nGameLevel )
		{
			sprintf(key[k].rank_key, "js_easy_rank%d", k+1);
			sprintf(key[k].time_key, "js_easy_time%d", k+1);
			sprintf(key[k].date_key, "js_easy_date%d", k+1);
		}
		else
		{
			sprintf(key[k].rank_key, "js_hard_rank%d", k+1);
			sprintf(key[k].time_key, "js_hard_time%d", k+1);
			sprintf(key[k].date_key, "js_hard_date%d", k+1);
		}
	}

	int nTime = 0;
	std::string strZero = "0";
	// Get Rank data
	for ( int r = 0; r < JS_MAX_RANK; r++ )
	{
		sprintf(rank[r].rank, "%d", r+1);
		nTime = CCUserDefault::sharedUserDefault()->getIntegerForKey(key[r].time_key);
		sprintf(rank[r].time, "%d", nTime);
		sprintf(rank[r].date, "%d", nTime);//CCUserDefault::sharedUserDefault()->getStringForKey(key[r].date_key, strZero.c_str()).c_str());
	}

	int nTemp = 0;
	for ( int i = 0; i < JS_MAX_RANK; i++ )
	{
		nTemp = atof(rank[i].time);
		if ( nTemp != 0 && nTemp >= m_nPlayTime || nTemp == 0)
		{
			//int nRet = 0;
			if (nTemp != 0 && nTemp != m_nPlayTime)
			{
				for ( int k = JS_MAX_RANK-1; k > i; k-- )
				{
					sprintf(rank[k].date, "%s", rank[k-1].date);
					sprintf(rank[k].time, "%s", rank[k-1].time);
				}
			}

			time_t t = time(0);
			struct tm *aTime = localtime(&t);

			// Month is 0 - 11, add 1 to get a jan-dec 1-12 concept
			// Year is # years since 1900
			sprintf(rank[i].date, "%04d-%02d-%02d", aTime->tm_year + 1900, aTime->tm_mon + 1 , aTime->tm_mday);
			sprintf(rank[i].time, "%d", m_nPlayTime);
			m_nRank = i + 1;

			// Update Rank Data
			for ( int u = 0; u < JS_MAX_RANK; u++ )
			{
				CCUserDefault::sharedUserDefault()->setIntegerForKey(key[u].rank_key, u+1);
				CCUserDefault::sharedUserDefault()->setStringForKey(key[u].time_key, rank[u].time);
				CCUserDefault::sharedUserDefault()->setStringForKey(key[u].date_key, rank[u].date);
			}
			CCUserDefault::sharedUserDefault()->flush();
			break;
		}
		m_nRank = -1;	// 순위 밖
	}
	
	char cRankData[100];
	for ( int i = 0; i < JS_MAX_RANK; i++ )
	{
		// 랭킹 데이터 출력
		CCLabelAtlas *pRankLabel = new CCLabelAtlas();
		if ( atof(rank[i].rank) < 10 && atof(rank[i].time) < 10 )
			sprintf(cRankData,"%s		       %s		     %s",rank[i].rank, rank[i].time, rank[i].date);
		else if ( atof(rank[i].rank) < 10 && atof(rank[i].time) >= 10 )
			sprintf(cRankData,"%s		       %s		    %s",rank[i].rank, rank[i].time, rank[i].date);
		else if ( atof(rank[i].rank) >= 10 && atof(rank[i].time) < 10 )
			sprintf(cRankData,"%s		      %s		     %s",rank[i].rank, rank[i].time, rank[i].date);
		else
			sprintf(cRankData,"%s		      %s		    %s",rank[i].rank, rank[i].time, rank[i].date);

		if ( m_nRank == i + 1 )
			pRankLabel->initWithString(cRankData, "common/game/num_font_red.png", 24, 32, '0');
		else
			pRankLabel->initWithString(cRankData, "common/game/num_font_white.png", 24, 32, '0');

		CCPoint ptRankData;
		ptRankData.x = RANK_X;
		ptRankData.y = RANK_Y - (pRankLabel->getContentSize().height * i);
		pRankLabel->setPosition(ptRankData);

		this->addChild(pRankLabel, 400+i);
	}
}
CCNode* DamageValueEffect::CreateCritDamageLable(unsigned int damage,CCPoint parentPos,bool isHarmFul)
{
	CCPoint uiPos = parentPos;
	CCSprite* critNode = CCSprite::create();
	critNode->setPosition(ccp(uiPos.x,uiPos.y));
	critNode->setAnchorPoint(ccp(0.5,0.5));

	ASprite *as = AspriteManager::getInstance()->getAsprite("UI/ui_inbattle.bin"); 
	CCPoint pt;
	int iFrameID = TXGUI::getResourceIDByName("map_ui_inbattle_FRAME_CRITICALBACK");
	CCSprite* critSprite = as->getSpriteFromFrame_Middle(iFrameID,0,pt);
	if(critSprite)
	{
		critSprite->setPosition(CCPointZero);
		critNode->addChild(critSprite,0);
	}

	char damageString[10];
	sprintf(damageString,"%d",damage);
	CCLabelAtlas* label;
	if(isHarmFul)
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_2.png",43,54,48);
	}
	else
	{
		label = CCLabelAtlas::create(damageString,"UI/ui_numble_3.png",41,43,48);
	}

	if(label)
	{
		label->setAnchorPoint(ccp(0.5f,0.5f));
		label->setPosition(CCPointZero);
		critNode->addChild(label,1);
		if(critSprite)
		{
			float scale_x = label->getContentSize().width / (0.8f * critSprite->getContentSize().width);
			float scale_y = label->getContentSize().height / (0.8f * critSprite->getContentSize().height);
			float scale = (scale_x > scale_y) ? scale_x : scale_y; 
			critSprite->setScale(scale);
			critSprite->setPosition(CCPointZero);
			critSprite->setAnchorPoint(ccp(0.5f,0.5f));
		}
	}

	critNode->setScale(0);
	critNode->runAction(getBattleUIAction());
	if(m_pDamageLabels->find(critNode) == m_pDamageLabels->end())
	{
		m_pDamageLabels->insert(make_pair(critNode,1.3f));
		//this->addChild(critNode);
		if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL
			&& GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer())
		{
			GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(critNode,MAP_Z_OBJ_TOP);
		}
	}

	/*if(isHarmFul)
	{
		HandleCritBurst(uiPos,0);
	}*/

	return critNode;
}
void SectionItem::initButton(SectionItem* button,bool canChoose)
{
	button->canChoose = canChoose;
	ResManager* resMgr = ResManager::getManager();
	
	if (!canChoose)
	{
		initWithFile(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_lock_bg.png").c_str());
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data))
		{
			CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
			addChild(img);
			img->setPosition(ccp(getContentSize().width-7, getContentSize().height));
		}
*/
	}else
	{
		char fileName[128];
		sprintf(fileName, (resMgr->getSharedFilePath()+g_seasonlayerPath+"sectionItem_%d_bg.png").c_str(),button->currentScore);
		initWithFile(fileName);
		if (button->currentScore == 0)
		{
			CCSprite *ef = CCSprite::create(resMgr->getSharedFilePath(g_seasonlayerPath+"sectionItem_new_bg.png").c_str());
			addChild(ef);
			ef->setPosition(ccp(ef->getContentSize().width/2, ef->getContentSize().height/2 - 3));
			ef->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.5f), CCFadeIn::create(1.5f), NULL)));
		}
		//屏蔽剧情道具相关
/*		JuqingDaoJu data;
		if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state != DJS_NotGetted)
		{
			CCSprite *img = CCSprite::create(resMgr->getSharedFilePath(g_daojuPath+data.fileName).c_str());
			addChild(img);
			img->setPosition(ccp(getContentSize().width/2, 120));
			img->setScale(0.75f);
		}
		*/
		if (false)
		{
		}
		else 
		{
	
			CCLabelAtlas* lable = CCLabelAtlas::create(
				"0123456789",
				resMgr->getSharedFilePath(g_seasonlayerPath+"season_section_num.png").c_str(),
				40, 49,//24
				'0');
			addChild(lable);
			char id[5];
			sprintf(id,"%d",button->sectionId);
			lable->setString(id);
			lable->setPosition(ccp(getContentSize().width/2 - lable->getContentSize().width/2,90));
			
			//屏蔽剧情道具相关
/*			if (JuqingDaoJuManager::getManager()->getItemInSection(seasonId, sectionId, data) && data.state == DJS_NotGetted)
			{
				CCSprite *img = CCSprite::create("sectionItem_daoju_weihuode.png");
				addChild(img);
				img->setPosition(ccp(getContentSize().width-5, getContentSize().height+10));

				CCAnimation *animation = CCAnimation::create();
				for (int idx=1; idx<=16; ++idx){
					animation->addSpriteFrameWithFileName(CCString::createWithFormat("sectionItem_daoju_weihuode_%d.png", idx)->getCString());
				}
				animation->setDelayPerUnit(0.02f);
				img->runAction(CCRepeatForever::create(CCSequence::create(CCAnimate::create(animation), CCDelayTime::create(1), NULL)));
			}
*/
		}
	}
}
Example #4
0
void IOSStoreLayer::showItemsNode()
{
	int iTotalCount = 1;
	int iPrice = 10;
	int xcount = 1;
	int ycount = 1;
	CCSize size = CCSizeMake(120, 190);

	if (m_bBaoxiangBuyTenTimes)
	{
		iTotalCount = 10;
		size.width = 820;
		size.height = 350;
		xcount = 5;
		ycount = 2;
		iPrice = 95;
	}

	iTotalCount = this->getKaiBaoxiangRsqData().size();
	if (iTotalCount >= 11)
	{
		xcount = 6;
	}

	if (iTotalCount == 2)
	{
		xcount = 2;
		size = CCSizeMake(140*2, 190);
	}

	IOSStoreLayerScrollView* pView = IOSStoreLayerScrollView::createView(size, iTotalCount, xcount, ycount);
	m_pGetItemNode->addChild(pView);
	pView->ignoreAnchorPointForPosition(false);
	pView->setAnchorPoint(ccp(0.5f, 0.5f));
	pView->setPosition(ccp(this->getContentSize().width/2, this->getContentSize().height/2 - 60));
	pView->setClickableCreater(pView);
	pView->prepareToDisplay();
	pView->setTouchEnabled(false);
	pView->setTag(getitem_scrollview_tag);

	//显示
	CCSprite* pSmallbg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_anniu_zaikaishici_fujia.png").c_str());
	m_pGetItemNode->addChild(pSmallbg, 1);
	pSmallbg->setPosition(ccp(200, 100));

	//添加菜单
	CCMenu* pMenu = CCMenu::create();
	pMenu->setPosition(CCPointZero);
	m_pGetItemNode->addChild(pMenu, 2);
	
	//再开按钮
	CCMenuItemImage* pItem = NULL;
	int iStarCount = GameInforEditer::getGameInfor()->getTotalFreeScore();
	if (m_bBaoxiangBuyTenTimes)
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaishici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_ten_again);
	}
	else
	{
		pItem = CCMenuItemImage::create(
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici.png").c_str(),
			ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_zaikaiyici_select.png").c_str(),
			this, menu_selector(IOSStoreLayer::menuBtnCallBack));
		pItem->setTag(buy_one_again);
	}
	pItem->setPosition(ccp(pSmallbg->getPositionX() + pSmallbg->getContentSize().width/2 + pItem->getContentSize().width/2 - 30, 
		pSmallbg->getPositionY()));
	pMenu->addChild(pItem);

	//星星数量
	CCLabelAtlas* lable = CCLabelAtlas::create(
		"0123456789",
		ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"season_star_amount.png").c_str(),
		30, 47,//24
		'0');
	m_pGetItemNode->addChild(lable, 1, star_count_str_tag);
	lable->setAnchorPoint(ccp(0, 0.5));
	lable->setScale(0.6f);
	int iCount = 10;
	if (m_bBaoxiangBuyTenTimes)
	{
		iCount = 95;
	}
	char charStarCount[10] = {}; 
	sprintf(charStarCount, "%d", iCount);
	lable->setString(charStarCount);
	lable->setPosition(ccp(pItem->getPositionX()-pItem->getContentSize().width/2-lable->getContentSize().width/2 - 40, pSmallbg->getPositionY() - 3));

	//右边星星图标
	CCSprite* pXingxing = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_xiaogk+"YX_start.png").c_str());
	m_pGetItemNode->addChild(pXingxing, 1);
	pXingxing->setPosition(ccp(lable->getPositionX() - 30, pSmallbg->getPositionY()));

	//星星数不够时,只显示确定按钮
	//确定按钮
	CCMenuItemImage* pOKItem = CCMenuItemImage::create(
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi.png").c_str(),
		ResManager::getManager()->getFilePathByLanguageType(g_storelayerPath+"main_shangdian_anniu_quedingi_select.png").c_str(),
		this, menu_selector(IOSStoreLayer::menuBtnCallBack));
	pOKItem->setTag(ok_btn_tag);
	pOKItem->setPosition(ccp(this->getContentSize().width/2 + pOKItem->getContentSize().width, pSmallbg->getPositionY()));
	pMenu->addChild(pOKItem);

	if (iStarCount < iPrice)
	{
		lable->setVisible(false);
		pXingxing->setVisible(false);
		pSmallbg->setVisible(false);
		pItem->setVisible(false);

		pOKItem->setPosition(ccp(this->getContentSize().width/2, pSmallbg->getPositionY()));
	}
	pMenu->setTouchPriority(kCCMenuHandlerPriority-5);
}