本文整理汇总了C++中UserData::setRoleFood方法的典型用法代码示例。如果您正苦于以下问题:C++ UserData::setRoleFood方法的具体用法?C++ UserData::setRoleFood怎么用?C++ UserData::setRoleFood使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData::setRoleFood方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}