本文整理汇总了C++中UserData::setRoleGold方法的典型用法代码示例。如果您正苦于以下问题:C++ UserData::setRoleGold方法的具体用法?C++ UserData::setRoleGold怎么用?C++ UserData::setRoleGold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserData
的用法示例。
在下文中一共展示了UserData::setRoleGold方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMsg
//.........这里部分代码省略.........
ShowPopTextTip(GETLANGSTR(207));
return false;
}
//读取上一次登录选择的服务器
std::string sServerGame = CCUserDefault::sharedUserDefault()->getStringForKey(SERVER_FOR_GAME);
m_iSelectServerIndex = getServerIndex(sServerGame);
//读取更新服务器列表
std::string sUpdateServer = serverInfo->update_server();
if(sUpdateServer.compare("") != 0)
{
CCUserDefault::sharedUserDefault()->setStringForKey(SERVER_FOR_UPDATE, sUpdateServer);
CCUserDefault::sharedUserDefault()->flush();
}
//版本更新
bool bUpdate = GamePlatformMgr->VersionUpdateWithPlatform( serverInfo->game_version() );
if(!bUpdate)
{
initLogin();
}
}
break;
case LoginResponseMsg:
{
LoginResponse *loginResponse = (LoginResponse *)msg;
printf("%d,%d,",loginResponse->authrecode(),loginResponse->hasrole());
printf("\n name = %s ,...", loginResponse->GetDescriptor()->name().c_str());
int res =loginResponse->authrecode(); //登录成功,
if (res==0)
{
if (loginResponse->hasrole())
{
for (int i=0; i<loginResponse->rolelist_size();i++)
{
protos::common::Role role = loginResponse->rolelist(i);
printf("role id:%d rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv());
CNetClient::getShareInstance()->sendInGameReq(role.roleid());
break;
}
}
else
{
m_armature->getAnimation()->play("enter");
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound))));
removeLogin();
}
}
//0x01服务器人数上限,0x02账号禁止登录,0x03账号验证错误)
else if (res==1)
{
ShowTexttip(GETLANGSTR(227),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
}
else if (res==2)
{
ShowTexttip(GETLANGSTR(228),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
}
else if (res==3)
{
ShowTexttip(GETLANGSTR(165),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
}
else if(res==4)
{
ShowTexttip(GETLANGSTR(1155),RGB_RED,0,ccp(VCENTER.x,VCENTER.y+150),0.0f,2.0f,0.0f,20.0f);
}
return true;
}
break;
//进入游戏
case InGameResponseMsg:
{
InGameResponse *inRespon = (InGameResponse*)msg;
protos::common::Role role = inRespon->myrole();
printf("role id:%d rolename:%s, rolelv: %d", role.roleid(), U8(role.rolename().c_str()),role.rolelv());
UserData* userData = DataCenter::sharedData()->getUser()->getUserData();
userData->setRaceType(role.rolenation());
userData->setAliveID(role.roleid());
userData->setRoleID(role.roleid());
userData->setLevel(role.rolelv());
userData->setName(role.rolename().c_str());
userData->setCoin(role.rolecoin());
userData->setExp(role.roleexp());
userData->setNextExp(role.nextexp());
userData->setRoleAction(role.roleaction());
userData->setRoleGold(role.rolegold());
userData->read(role);
m_armature->getAnimation()->play("enter");
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callbackForSound))));
removeLogin();
return true;
}
break;
default:
break;
}
return false;
}
示例2: ProcessMsg
void CSignLayer::ProcessMsg(int type, google::protobuf::Message *msg)
{
if(!isVisible())
{
this->setVisible(true);
//NOTIFICATION->postNotification(HIDE_MAIN_SCENE);
m_pLineEffect->showEffect();
}
if (type == SignDataMsg)
{
SignData *res = (SignData*)msg;
m_signData.read(*res);
m_gridView->setCountOfCell(m_signData.signList.size());
ReloadGridViewWithSameOffset(m_gridView);
m_resignGold = m_signData.resign_gold;
//更新阶段签到情况
updateTotoalSign();
//加黄标提示
showTipsOnNextTotalSign();
updateSignDays();
showCheckDayToCenter();
initHeroData();
}
else if (type== SignReqMsg)
{
SignResponse *res = (SignResponse *)msg;
CSignRes signRes;
signRes.read(*res);
switch (res->result())
{
case 1:
{
if (m_bIsReSign)//补签要扣勾玉
{
UserData *data = DataCenter::sharedData()->getUser()->getUserData();
data->setRoleGold(data->getRoleGold()-m_resignGold);
CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_HERO,0,nullptr,nullptr);
}
if (res->has_resigngold())
{
m_resignGold = res->resigngold();
}
//下一个未签的改为已签
int iIndex = autoNextSignStatusChange();
m_signData.resign-= m_bIsReSign;
m_signData.sign+=1 ;
//普通签到
if(!m_bIsReSign)
{
m_signData.bCanSign = false;
}
ReloadGridViewWithSameOffset(m_gridView);
updateSignDays();
showCheckDayToCenter();
if(iIndex!=-1)
{
CSign& sign = m_signData.signList[iIndex];
if(DataCenter::sharedData()->getUser()->getUserData()->getVip()>=sign.vip && sign.vip>0)
{
sign.prize.num *= 2;
}
CPopItem *popItem = CPopItem::create();
popItem->signPrize(&sign.prize);
popItem->setDescVisiable(true);
LayerManager::instance()->push(popItem);
//界面关闭后给回一个回调,用于处理阶段签的宝箱
int iIndexTotal = checkTotalBox();
if(iIndexTotal!=-1)
{
popItem->bindTargetCallBack(this, popitem_selector(CSignLayer::callBackForTotalSignEffect));
}
}
PlayEffectSound(SFX_407);
}
break;
case 2:
{
//ShowPopTextTip(GETLANGSTR(240));
CShowToBuyResource* pShow = CShowToBuyResource::create();
pShow->showToBuyResourceByType(ShowBuyResourceAction);
}
//.........这里部分代码省略.........
示例3: proceesMessage
void CSmeltArmor::proceesMessage(int type, google::protobuf::Message *msg)
{
this->setVisible(true);
switch (type)
{
//洗练数据
case SmeltDataRequestMsg:
{
Armor *res = (Armor*)msg;
if(res)
{
m_armor.armor.atkRange = res->atkrange();
m_armor.armor.hpRange = res->hprange();
m_armor.armor.defRange = res->defrange();
m_armor.armor.IntRange = res->dexrange();
m_armor.armor.hitRange = res->hitrange();
m_armor.armor.critRange = res->critrange();
m_armor.armor.renewRange = res->renewrange();
m_armor.armor.dodgeRange = res->dodgerange();
showSmeltDataToUI();
}
}break;
//洗练
case SmeltArmorMsg:
{
SmeltResponse *res = (SmeltResponse*)msg;
//1 成功,2 金币不足,3 元宝不足,4 数据错误
if (res->reslut()==1)
{
//1 攻击addAtk,2 防御addDef,3 血量addHp,4 敏捷addDex,5 命中addHit,6 暴击addCrit,7 回复addRenew,8 闪避addDodge)
m_armor.armor.addAtk = res->armor().armor().addatk();
m_armor.armor.addDef = res->armor().armor().adddef();
m_armor.armor.addHp = res->armor().armor().addhp();
m_armor.armor.addDex = res->armor().armor().adddex();
m_armor.armor.addHit = res->armor().armor().addhit();
m_armor.armor.addCrit = res->armor().armor().addcrit();
m_armor.armor.addRenew = res->armor().armor().addrenew();
m_armor.armor.addDodge = res->armor().armor().adddodge();
//更新金钱
UserData *data = DataCenter::sharedData()->getUser()->getUserData();
data->setCoin(data->getCoin() - m_coin);
data->setRoleGold(data->getRoleGold() - m_diamond);
CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_HERO,0,nullptr,nullptr);
CSceneManager::sharedSceneManager()->PostMessageA(UPDATE_ITEM_DATA, 2, nullptr, &m_armor);
//播放效果
float fTime = showStrengthEffect();
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(fTime), CCCallFunc::create(this, callfunc_selector(CSmeltArmor::showArmorAttr))));
}
else if (res->reslut()==2)
{
//ShowPopTextTip(GETLANGSTR(205));
CShowToBuyResource* pShow = CShowToBuyResource::create();
pShow->showToBuyResourceByType(ShowBuyResourceCoin);
}
else if (res->reslut()==3)
{
//ShowPopTextTip(GETLANGSTR(203));
CShowToBuyResource* pShow = CShowToBuyResource::create();
pShow->showToBuyResourceByType(ShowBuyResourceGold);
}
else if (res->reslut()==4)
{
ShowPopTextTip(GETLANGSTR(170));
}
}break;
default:
break;
}
}