예제 #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));
		}
	}
}
예제 #2
0
void CStrengthenItem::onTouchItem(CCObject* pSender)
{
	if(isVisible())
	{
		PlayEffectSound(SFX_Button);
	}

	CImageView * img = (CImageView*)pSender;
	m_item = (CItem*)img->getUserData();

	m_pItemTip->showItemProperty(m_item);

	CLayout *attribute = (CLayout*)(m_ui->findWidgetById("attr"));
	attribute->setVisible(true);

	m_selectCellImg->removeFromParent();
	img->addChild(m_selectCellImg);
	m_selectCellImg->setVisible(true);
	m_selectCellImg->setPosition(ccp(img->getContentSize().width/2,0/*img->getContentSize().height/2*/));

	CButton *select = (CButton*)(m_ui->findWidgetById("select")); //sel_font
	CLabel *selfont = (CLabel*)(m_ui->findWidgetById("sel_font"));
	if (m_toHero==m_item->armor.hero&&m_toHero>0)
	{
		select->setVisible(true);
		selfont->setVisible(false);
	}
	else if (m_toHero>0&&!m_item->canUse)
	{
		select->setVisible(false);
		selfont->setVisible(false);
	}
	else
	{
		select->setVisible(true);
		selfont->setVisible(true);
	}

	if (m_type==2)
	{
		if (m_toHero>0)
		{
			CImageView *uninstall = (CImageView*)(m_ui->findWidgetById("uninstall"));
			CImageView *change = (CImageView*)(m_ui->findWidgetById("change"));
			CImageView *selfont = (CImageView*)(m_ui->findWidgetById("sel_font"));
			uninstall->setVisible(m_toHero==m_item->armor.hero);
			change->setVisible(m_toHero!=m_item->armor.hero&&m_item->armor.hero>0&&m_item->canUse);
			selfont->setVisible(m_item->armor.hero==0&&m_item->canUse);
		}
	}
}
예제 #3
0
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// 	CHero *hero = m_currHeroList->at(uIdx);
	CSign &sign = m_signData.signList.at(uIdx);
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	pCell->setScale(0.97f);

	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
	}


	CImageView *imagView = (CImageView*)pCell->getChildByTag(1);	
	imagView->setTouchEnabled(true);
	imagView->setEnabled(true);
	imagView->setUserData(&m_signData.signList.at(uIdx));
	imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
	


	CCSprite *item = nullptr;
	if (sign.prize.thumb>=0)
	{
		CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
		SmartSetRectPrizeColor(pMask, &sign.prize);
		item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}