void TeamFeedCell::resetUI() { auto pet = getCurrBag()->getPetByID(this->getUserID()); if(pet != nullptr) { _remainTime->stopAllActions(); _txtName->setString(_T(pet->getName())); UIHelper::setStars(_stars[0]->getParent(), pet->getStarNum(), pet->getStarMax()); _icon->loadTexture(_X(pet->getBigFrontIcon(), _icon)); _lv->setString(_T("Lv.%d", pet->getLevel())); if(getIsWater() == false) //----恢复HP需要的粮食值 { _hp->setString(_T("%d", getChangedHP())); _txtFood->setString("Expect Food:"); _food->setString(_T("%d", (int)(getChangedHP() * pow(10, pet->getStarNum())))); _remainTime->setString(_T("00:00:00")); _btnSlider->setPercent(((getHPMax() - getChangedHP() / pow(10, pet->getStarNum()))) * 100 / pet->getHpMax()); setloadingBarValue(currNum, (int)(getChangedHP() * pow(10, pet->getStarNum()))); if(getIsSuccess()) { for (int i = 0; i < _indexTime.size(); ++i) { if (getIndex() == _indexTime[i]) { _remainTime->runAction(ServerTimer::create(getCurrBag()->getTeamByID(_teamID)->getCD())); } } } } else { _hp->setString(_T("%d", getChangedHP())); _txtFood->setString("Expect Water:"); _food->setString(_T("%d", getChangedHP())); //----恢复HP需要的泉水值 _remainTime->setString(_T("00:00:00")); _btnSlider->setPercent(getHPMax() * 100 / pet->getHpMax()); setloadingBarValue(currNum, pet->getHpMax()); } } else { _isShow->setVisible(false); } }
void GameObj::resetObjectState() { // reset an object so i can be re-used this->cleanEnemiesList(); this->setHP(getHPMax()); this->body->SetActive(true); this->body->SetAwake(true); this->setGroundContact(false); }
void TeamFeedCell::setloadingBarValue(int Num, int hpmax) { auto pet = getCurrBag()->getPetByID(this->getUserID()); if(Num >= hpmax) { _loadingBar->setPercent(getHPMax() * 100 / pet->getHpMax()); } else if(Num < hpmax) { _loadingBar->setPercent(Num * 100 / pet->getHpMax()); } }
void CPlayer::useItem(int itemID) { std::string machineName = this->getMachineName(); size_t idx = machineName.find("Server"); if(idx != std::string::npos) { // Server端處理 CItemInfo* pItemInfo = CItem::getInfo(itemID); if(pItemInfo == NULL) return; if(pItemInfo->getClassType() == WEAPON) { CWeaponInfo *pWp = (CWeaponInfo*) pItemInfo; if(this->getLevel() >= pWp->getLevel()) { if(ONE_HAND == pWp->getWield()) wearToEquipSlot(MAIN_HAND, itemID); else if(TWO_HAND == pWp->getWield()) wearToEquipSlot(OFF_HAND, itemID); } } else if(pItemInfo->getClassType() == ARMOR) { CArmorInfo *pAm = (CArmorInfo*) pItemInfo; if(this->getLevel() >= pAm->getLevel()) { if(CLOTHES == pAm->getWear()) wearToEquipSlot(CHEST, itemID); else if(BELTS == pAm->getWear()) wearToEquipSlot(BELT, itemID); else if(PANTS == pAm->getWear()) wearToEquipSlot(LEGS, itemID); else if(PAULDRONS == pAm->getWear()) wearToEquipSlot(SHOULDER, itemID); else if(GLOVES == pAm->getWear()) wearToEquipSlot(GLOVE, itemID); else if(BOOTS == pAm->getWear()) wearToEquipSlot(BOOT, itemID); } } else if(pItemInfo->getClassType() == CONSUMABLE) { CConsumableInfo *pConsumableInfo = (CConsumableInfo *)pItemInfo; if(this->getLevel() >= pConsumableInfo->getLevel()) { if(pConsumableInfo->getEffect() == EDIBLE_SKILL) addSkill(pConsumableInfo->getMuch()); // 學習某項技能 else if(pConsumableInfo->getEffect() == EDIBLE_HP) { if(getHPMax() == getHP()) return; addHP(pConsumableInfo->getMuch()); // 補血 // Todo: 藥水是否有CD時間 } else if(pConsumableInfo->getEffect() == EDIBLE_MP) { if(getMP() == getMPMax()) return; addMP(pConsumableInfo->getMuch()); // 補魔 // Todo: 藥水是否有CD時間 } else return; // 背包物品減一 m_pBackpack->removeItem(itemID); } } } else { // Client端處理 } }