Beispiel #1
0
void CHandBookHeroLayer::initCellIconByData( AData *pAData, CLayout *pCell )
{
	//message AData{
	//	optional int32 type = 1;		//类型 1英雄,2装备,3怪物
	//	optional int32 thumb = 2;		
	//	optional int32 color = 3;		//边框颜色
	//	optional int32 process = 4;		//英雄、装备代表进阶数,怪物代表击杀数
	//	optional int32 max_process = 5;
	//	optional int32 param = 6;
	//}


	Prize *prize = new Prize; 
	//获取数据
	int iType = 1;
	if ( pAData->type()==1 || pAData->type()==3 )
	{
		iType = 2;
	}
	int iColor = pAData->color();
	int iIconId = pAData->thumb();
	int iRank = pAData->process();

	string str = GetImageName(iType, iColor, iIconId);

	//图标
	CImageView* pBgRect = (CImageView *)pCell->findWidgetById("headBg");
	CImageView *itemSpr = CImageView::create(str.c_str());
	if (!itemSpr)
	{
		itemSpr = CImageView::create("prop/32003.png");
		CCLOG("[ ERROR ] CPopItem::addTableCell Lost Image = %d");
	}
	pBgRect->addChild(itemSpr);
	NodeFillParent(itemSpr);

	//品质+事件
	CImageView *mask= (CImageView *)pCell->findWidgetById("head");
	mask->setTexture(setItemQualityTexture(iColor));
	mask->setUserData(pAData);
	mask->setTag(iType);
	mask->setTouchEnabled(true);
	mask->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onShowRankUp));

	//进阶
	for ( int i=0; i<5; i++)
	{
		CImageView *pStar = (CImageView *)pCell->getChildByTag(i+3);
		//阶级到,点亮
		if (i<iRank)
		{
			pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
		}
		else
		{
			pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
		}
	}
}
Beispiel #2
0
void CSharpTollgate::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	const vector<StageWidget> *data = DataCenter::sharedData()->getStageData()
		->getStageWidgets(m_chapter);
	CStage &stage = m_stageList.at(uIdx);

	for (int i = 0; i < 2; i++)
	{
		CCNode * node = (CCNode*)m_cell->getChildren()->objectAtIndex(i);

		if (node->getTag()==1)
		{
			const StageWidget *widget = nullptr;			
			CCString *strId = CCString::createWithFormat("hero%d",uIdx+1);
			for (int j=0; j<data->size();++j)
			{
				widget = &data->at(j);
				if (widget->widgetId!=""&&widget->widgetId.compare(strId->getCString())==0)
				{				
					CButton *btn =  CButton::create(widget->normalImage.c_str());
					btn->setScaleX(widget->scaleX);
					btn->setScaleY(widget->scaleY);
					btn->setPosition(ccp(100, 80/*btn->boundingBox().size.height*/));  
					btn->setAnchorPoint(ccp(0.5, 0.0));
					btn->setUserData(&m_stageList.at(uIdx));
					btn->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onBattle));
					btn->setTag(1);
					pCell->addChild(btn);
					if (!stage.isOpen)
					{
						btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
// 						btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
					break;
				}
			}
		}
		else if (node->getTag()==2)
		{
			CImageView *image = UICloneMgr::cloneImageView((CImageView*)node);
			if (stage.star>0)
			{		
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("tollgate/star_%d.png",stage.star)->getCString()));
			}
			else
			{
				image->setTexture(CCTextureCache::sharedTextureCache()->addImage("tollgate/star_3.png"));
				image->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			}
			image->setAnchorPoint(ccp(0.5f,0));

			pCell->addChild(image);
		}
	}
	pCell->setVisible(false);
	pCell->setScale(1.15f);
	pCell->runAction(CCSequence::create(CCDelayTime::create(0.1f+0.15f*uIdx),CCShow::create(),CCScaleTo::create(0.05f,1.0f),CCCallFuncN::create(this,callfuncN_selector(CSharpTollgate::heroCall)),nullptr));
}
Beispiel #3
0
void CSignLayer::updateTotoalSign()
{
	//更新
	//已领取的,宝箱变灰,加对勾
	//未领取的,宝箱变亮,
	//将要领取的,加黄色标题突出

	for (int i = 0; i < m_signData.totalList.size()&&i<4; i++)
	{
		CSign &sign = m_signData.totalList.at(i);

		//宝箱
		CImageView *mask = (CImageView*)m_ui->findWidgetById(CCString::createWithFormat("mask%d",i+1)->getCString());
		mask->setVisible(true);
		//mask->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("sign/box_%d.png", i+1)->getCString()));
		mask->setUserData(&sign);
		mask->setTouchEnabled(true);
		mask->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));

		//天数
		CLabel *day = (CLabel*)(m_ui->findWidgetById(CCString::createWithFormat("day%d",i+1)->getCString()));
		day->setString(CCString::createWithFormat(GETLANGSTR(209),sign.day)->getCString());

		//获得字样
		CImageView *getspr = (CImageView*)(m_ui->findWidgetById(CCString::createWithFormat("get%d",i+1)->getCString()));

		//已领取
		if (sign.status==1)
		{
			//宝箱变灰
			mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//加对勾
			getspr->setVisible(true);
		}
		//未领取
		else if(sign.status==2)
		{
			//宝箱变灰
			mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
			//加对勾
			getspr->setVisible(false);
		}
	}
}
Beispiel #4
0
void CHandBookHeroLayer::addTableCell( unsigned int uIdx, CTableViewCell * pCell )
{
	//先克隆外框条
	CLayout *pLay = UICloneMgr::cloneLayout(m_pCellBlank);

	//对应数据
	AtlasIns *pAtlasIns = m_AtlasResponse.mutable_atlas_list()->Mutable(uIdx);

	//赋值
	for (unsigned int i=1; i<=10; i++)
	{
		CCNode *child = pLay->getChildByTag(i);
		pLay->removeChild(child);
		child->setTag(i);
		pCell->addChild(child);
		pCell->setTag(uIdx);
	}

	//1-活动底板
	{
		CImageView* pBoard = dynamic_cast<CImageView*>(pCell->getChildByTag(1));
		pBoard->setTouchEnabled(true);
		pBoard->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickBlank));

		if ( uIdx==m_iSelectIndex )
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_2.png"));
		}
		else
		{
			pBoard->setTexture(CCTextureCache::sharedTextureCache()->addImage("handBook/bookbg_1.png"));
		}
	}

	//2-组合名字
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(2));
	}

	//3-//组合描述
	{
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(3));
	}

	//4-礼品背景
	//5-礼品
	//10-文字
	{
		CImageView* pGiftBg = dynamic_cast<CImageView*>(pCell->getChildByTag(4));
		CImageView* pGift = dynamic_cast<CImageView*>(pCell->getChildByTag(5));
		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(10));

		pLabel->setVisible(false);
		pGift->stopAllActions();

		//奖励领取标志 0未领取(不可领取),1未领取(可领取状态),2 已领取
		switch (pAtlasIns->get_prize())
		{
		case 0:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));

			}break;
		case 1:
			{
				pGiftBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				pGift->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
				ResetAnchorPointAndKeepSamePos(pGift, CCPointCenter);
				pGift->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 0.75f), CCScaleTo::create(0.3f, 0.7f))));

			}break;
		case 2:
			{
				pGiftBg->setVisible(false);
				pGift->setVisible(false);
				pLabel->setVisible(true);
			}break;
		default:
			break;
		}
	}


	//7-进度条
	//8-进度数字
	//9-进度图标
	{
		CProgressBar* pProgress = dynamic_cast<CProgressBar*>(pCell->getChildByTag(7));

		CLabel* pLabel = dynamic_cast<CLabel*>(pCell->getChildByTag(8));
		pLabel->setTouchEnabled(true);
		pLabel->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));

		CImageView* pIcon = dynamic_cast<CImageView*>(pCell->getChildByTag(9));
		pIcon->setTouchEnabled(true);
		pIcon->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onClickScoreIcon));
	}


	//收集列表
	CCPoint pPos(80, 54);
	int iGapX = 94;
	initListCellIcon( pAtlasIns, pPos, iGapX, pCell );

}