当前位置: 首页>>代码示例>>C++>>正文


C++ UserData::getRoleFood方法代码示例

本文整理汇总了C++中UserData::getRoleFood方法的典型用法代码示例。如果您正苦于以下问题:C++ UserData::getRoleFood方法的具体用法?C++ UserData::getRoleFood怎么用?C++ UserData::getRoleFood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserData的用法示例。


在下文中一共展示了UserData::getRoleFood方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateSelectCity

void CCommandLayer::updateSelectCity(CCity *data)
{
	CCSprite *build = (CCSprite*)(m_comLayer->findWidgetById("build"));
    CCTexture2D *textTure = CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("command/%d.jpg",data->cityId*10+1)->getCString());
	if (textTure)
	{
		build->setTexture(textTure);
	}

	CLabel *food = (CLabel*)(m_comLayer->findWidgetById("food"));
	food->setString(ToString(data->lvFood));

	CLabel *heronum = (CLabel*)(m_comLayer->findWidgetById("heronum"));
	heronum->setString(CCString::createWithFormat("%d/%d",data->haveHeroNum,data->heroNum)->getCString());

	CLabel *note1 = (CLabel*)(m_comLayer->findWidgetById("func1"));

	CLabel *note2 = (CLabel*)(m_comLayer->findWidgetById("func2"));

    CCArray *strArr = strSplit(data->note.c_str(),"|");
	
	if (strArr->count()==1)
	{
		note1->setString(((CCString*)strArr->objectAtIndex(0))->getCString());
		note2->setString("");
	}
	else if (strArr->count()==2)
	{
		note1->setString(((CCString*)strArr->objectAtIndex(0))->getCString());
		note2->setString(((CCString*)strArr->objectAtIndex(1))->getCString());
	}

	CButton *command = (CButton*)(m_comLayer->findWidgetById("strengthen"));

	UserData *user = DataCenter::sharedData()->getUser()->getUserData();
	if (data->cityId != m_commandData.cityInfo.cityId)
	{
		if (user->getRoleFood()>=data->lvFood&&data->level< m_commandData.cityInfo.level)
		{
			command->setEnabled(true);
		}
		else
		{
			command->setEnabled(false);
		}
	}
	else
	{
		if (user->getRoleFood()>=data->lvFood)
		{
			command->setEnabled(true);
		}
		else
		{
			command->setEnabled(false);
		}
	}
}
开发者ID:54993306,项目名称:Classes,代码行数:58,代码来源:CommandLayer.cpp

示例2: addTableCell

void CCommandLayer::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CCity &data = m_commandData.cityList[uIdx];

	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	for (int i=1;i<=6;++i)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
		if (i==1)
		{
			child->setTag(uIdx+100);
			child->setUserData((void*)&m_commandData.cityList[uIdx]);
			((CButton*)child)->setOnClickListener(this,ccw_click_selector(CCommandLayer::onSelectCity));
		}
		else if(i==3)
		{
			CLabel *name = (CLabel*)child;
			name->setString(data.cityName.c_str());
		}
		else if (i==2)
		{
			((CButton*)child)->setEnabled(false);
			CCSprite *prop = CCSprite::create(CCString::createWithFormat("command/%d.jpg",data.cityId*10)->getCString());
			if (prop)
			{
				prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
				child->addChild(prop,0,1);
			}
			else 
			{
				prop = CImageView::create("command/30.jpg");
				prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
				child->addChild(prop,0,1);
			}
		}

		else if(i==4)
		{
			CLabel *level = (CLabel*)child;
			level->setString(CCString::createWithFormat(GETLANGSTR(230),data.level)->getCString());
		}
		else if (i==5)
		{
			UserData *user = DataCenter::sharedData()->getUser()->getUserData();
			if (user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
		}
		else if (i==6)
 		{
			UserData *user = DataCenter::sharedData()->getUser()->getUserData();
			if (m_commandData.cityInfo.level>=data.level&&m_commandData.cityInfo.cityId!=data.cityId&&user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
			else if(m_commandData.cityInfo.cityId==data.cityId&&user->getRoleFood()>=data.lvFood)
			{
				child->setVisible(false);
			}
 		}
	}
}
开发者ID:54993306,项目名称:Classes,代码行数:65,代码来源:CommandLayer.cpp

示例3: processNetMsg

void CCommandLayer::processNetMsg(int type, google::protobuf::Message *msg)
{
	this->setVisible(true);

	switch (type)
	{
	case CommanderMsg:
		{
			 CommanderResponse *res = (CommanderResponse*)msg;
			 m_commandData.cityInfo.read(res->info());
			 for (int i = 0; i < res->citylist_size(); i++)
			 {
				 CCity city;
				 city.read(res->citylist(i));
				 m_commandData.cityList.push_back(city);
			 }
			 showCommandList();
		}
		break;
	case LevelUpMsg:
		{
			LevelUpResponse *res = (LevelUpResponse*)msg;
			//1 升级成功,2 粮食不足,3 指挥府等级限制,4 已达到最大等级,5 数据错误

			switch (res->result())
			{
			case 1:
				ShowPopTextTip(GETLANGSTR(244));		
				if (res->has_city())
				{
					UserData *user = DataCenter::sharedData()->getUser()->getUserData();
					int food = user->getRoleFood() - m_selectCity->lvFood;
					user->setRoleFood(food);
					CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_HERO,0,nullptr,nullptr);

					m_selectCity->read(res->city());
					
					CCity *city = new CCity;
					*city = *m_selectCity;

					CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_BUILD,0,nullptr, city);

					//更新指挥塔数据
					if (m_selectCity->cityId==m_commandData.cityInfo.cityId)
					{
						m_commandData.cityInfo = *m_selectCity;
					}
					m_tableView->setContentOffset(m_tableView->getContentOffset());
					m_tableView->reloadData();
					updateSelectCity(m_selectCity);

				}
				break;
			case 2:
				ShowPopTextTip(GETLANGSTR(241));		

				break;
			case 3:
				ShowPopTextTip(GETLANGSTR(242));		

				break;
			case 4:
				ShowPopTextTip(GETLANGSTR(243));		

				break;
			case 5:
				ShowPopTextTip(GETLANGSTR(170),RGB_RED);
				break;

			default:
				break;
			}
		}
		break;

	default:
		break;
	}
}
开发者ID:54993306,项目名称:Classes,代码行数:79,代码来源:CommandLayer.cpp


注:本文中的UserData::getRoleFood方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。