static Prop *FindExistingProp(Prop *prop) { for (Prop *p = gAllProps->IterStart(); p; p = gAllProps->IterNext()) { if (p->Eq(prop)) return p; } return NULL; }
Prop* PropFactory::createWall(int health){ Prop* wall = new Prop(false); wall->setName("Wall"); wall->getHealth()->init(wall->getHealth()->getName(), health, health); vector<Item*> debris; debris.push_back(ItemFactory::createWoodPlank()); debris.push_back(ItemFactory::createWoodPlank()); wall->setDebris(debris); return wall; }
int Group::pollAllProps(double dt ){ last_dt = dt; int cnt=0; Prop *cur = prop_top; // poll Prop *to_clean[32*1024]; // 1ループにこの個数までclean int to_clean_cnt = 0; while(cur){ cnt++; bool to_keep = cur->basePoll(dt); if(!to_keep) cur->to_clean = true; if( cur->to_clean ){ if( to_clean_cnt < elementof(to_clean) ){ if( cur->debug_id ) print("Debug: cleaning prop id:%d cnt:%d",cur->id, to_clean_cnt ); to_clean[ to_clean_cnt ] = cur; to_clean_cnt ++; } } cur = cur->next; } // clean 高速版 // if( to_clean_cnt > 0 ) print("top-p:%p clean_n:%d", prop_top, to_clean_cnt ); for(int i=0;i<to_clean_cnt;i++){ Prop *p = to_clean[i]; if( p->debug_id ) print("deleting p:%p prev:%p next:%p", p, p->prev, p->next ); if(p == prop_top ){ prop_top = p->next; } if(p->prev ){ p->prev->next = p->next; } if(p->next){ p->next->prev = p->prev; } p->next = NULL; p->onDelete(); #ifdef __linux__ std::map<int,Prop*>::iterator ii = idmap.find(p->id); #else std::unordered_map<int,Prop*>::iterator ii = idmap.find(p->id); #endif idmap.erase(ii); delete p; } last_poll_num = cnt; return cnt; }
int countHit() { int hitcnt = 0; for(int i=0;i<N;i++) { Prop *p = props[i]; bool hit = false; for(int j=0;j<N;j++) { Prop *phit = props[j]; if( p != phit && p->hit(phit,20000000) ) hit = true; } if( hit ) hitcnt ++; } return hitcnt; }
void Destroy() { for (Prop *p = gAllProps->IterStart(); p; p = gAllProps->IterNext()) { p->Free(); } delete gAllProps; delete gStyleButtonDefault; delete gStyleButtonMouseOver; delete gStyleCache; delete gStyleDefault; }
// used only as part of a storing operation MediaAnalyticsItem::Prop *MediaAnalyticsItem::allocateProp(const char *name) { size_t len = strlen(name); size_t i = findPropIndex(name, len); Prop *prop; if (i < mPropCount) { prop = &mProps[i]; } else { if (i == mPropSize) { growProps(); // XXX: verify success } i = mPropCount++; prop = &mProps[i]; prop->setName(name, len); } return prop; }
AINode* CAIGoalAttackProp::HandleGoalAttractors() { // Check if already attacking a prop. if( m_pAI->GetState()->GetStateType() != kState_HumanAttackProp ) { CAIHuman* pAIHuman = (CAIHuman*)m_pAI; if( pAIHuman->HasHolsterString() || pAIHuman->GetPrimaryWeapon()) { AIGBM_GoalTemplate* pTemplate = g_pAIGoalButeMgr->GetTemplate( GetGoalType() ); AIASSERT(pTemplate->cAttractors > 0, m_pAI->m_hObject, "CAIGoalAbstract::HandleGoalAttractors: Goal has no attractors."); // Check if attractors are triggering activateability. AINode* pNode; for(uint32 iAttractor=0; iAttractor < pTemplate->cAttractors; ++iAttractor) { pNode = g_pAINodeMgr->FindNearestNodeInRadius(m_pAI, pTemplate->aAttractors[iAttractor], m_pAI->GetPosition(), pTemplate->fAttractorDistSqr * m_fBaseImportance, LTTRUE); if(pNode != LTNULL) { HOBJECT hObject; if ( LT_OK == FindNamedObject(pNode->GetObject(), hObject) ) { Prop* pProp = (Prop*)g_pLTServer->HandleToObject(hObject); if(pProp->GetState() != kState_PropDestroyed) { AIASSERT(pNode->GetType() == kNode_UseObject, m_pAI->m_hObject, "CAIGoalAttackProp::HandleGoalAttractors: AINode is not of type UseObject."); m_hNode = pNode->m_hObject; SetCurToBaseImportance(); return pNode; } } // Disable node if prop has been destroyed. pNode->Disable(); } } } m_hNode = LTNULL; } return LTNULL; }
QString KWinWaylandTouchpad::valueWriter(const Prop<T> &prop) { if (!prop.changed()) { return QString(); } m_iface->setProperty(prop.dbus, prop.val); QDBusError error = m_iface->lastError(); if (error.isValid()) { qCCritical(KCM_TOUCHPAD) << error.message(); return error.message(); } return QString(); }
void FileManager_Scene::LoadScene_AddProp(string line) { vec3 propPosition; char propFile[MAX_FILE_WORD_LENGTH]; string position = line+2; byte wordBuffer[MAX_FILE_WORD_LENGTH]; ReadWord(&position, wordBuffer); strcpy(propFile, wordBuffer); ReadWord(&position, wordBuffer); propPosition.x = atof(wordBuffer); ReadWord(&position, wordBuffer); propPosition.y = atof(wordBuffer); ReadWord(&position, wordBuffer); propPosition.z = atof(wordBuffer); Prop* myProp; myProp = propManager->createProp(propFile); myProp->setPosition(&propPosition); }
void PKRoomWidget::updateProp(Player player,Prop prop) { PKRoomWidgetDebug("PKRoomWidget updateProp"); switch (prop.getID()) { case PROP_ID_LUCKYWING: { propWidget->updateLuckyWing(); animeMgr->addAnimation(this , QRect(268 , 14 , 300 , 180) ,prop); break; } case PROP_ID_PIG: { animeMgr->addAnimation(this , QRect(353 , 90 , 160 , 120) , prop); break; } case PROP_ID_KISS: { animeMgr->addAnimation(this , randomArea(QRect(0 , 0 , 200 , 200 )) ,prop); break; } case PROP_ID_SCRAWL: { animeMgr->addAnimation(this , QRect(ui->lyricWidget->x() ,ui->lyricWidget->y() - 30 ,305 , 105) , prop); break; } case PROP_ID_FROG: { animeMgr->addAnimation(this , QRect(0 , 90 , 260 , 100) , prop); break; } case PROP_ID_TRANSFORMER: case PROP_ID_TOMCAT: { peopleAnimeWidget->animateProp(prop); } default: break; } messageWidget->updateMessage(player, prop); }
void PropAnimator::AnimateProp(Prop &prop , QWidget *parent, QRect geometry) { for(int i = 0 ; i < cfg->getPropList().size() ; i++) { if(prop.getID() == cfg->getPropList().at(i).getID()) { this->prop = cfg->getPropList().at(i); } } // audioPlayer->setSourceData(cfg->getPluginPath() + QString("PropSound\\%1.wav").arg(this->prop.getID()), // AudioPlayer::eSourceFile, // AudioPlayer::eDecodeWAV); // audioPlayer->start(false, false); aniLabel = new QLabel(parent); aniLabel->setGeometry(geometry); aniCount = 0; if(this->prop.getIsComplexAni()) { isComplexAni = true; aniPath = cfg->getPluginPath() + "PropAnimation\\" + QString("%1Prop\\%1_head").arg(prop.getID()).arg(prop.getID()); state = "head"; aniTimer.start(); } else { isComplexAni = false; //test prop.setID(PROP_ID_SCRAWL); //--test end-- aniPath = cfg->getPluginPath() + "PropAnimation\\" + QString("%1Prop\\%2").arg(prop.getID()).arg(prop.getID()); aniTimer.start(); } }
void GameScene::bgMove(float dt){ //游戏数据存储,根据移动的速度计算得分和距离 if(over){ return; } srand(time(0)); GameData::addLoop(); if(GameData::getLoop() % 5 == 0){ GameData::addDistance(getSpeed() * 2); GameData::addScore(getSpeed() * 5); } char v[20]; sprintf(v,"%d",GameData::getDistance()); distanceValue->setString(v); sprintf(v,"%d",GameData::getScore()); scoreValue->setString(v); //地图移动 map->mapMove(this,hero); //判断是否碰到道具 for(int j = 0; j < 2; j++){ for(int i = 0;i < props[j]->count(); i++){ Prop* temp = (Prop*)props[j]->objectAtIndex(i); temp->move(map->getSpeed()); if(temp->collision(hero->getSprite())){ if(temp->getType() == Prop::PROP){ changeIndex = rand() % 3 + 4; hero->hideSprite(); CCSprite* temp = CCSprite::create(); SETANCHPOS(temp, hero->getSprite()->getPositionX(),hero->getSprite()->getPositionY(),0.5,0.5); addChild(temp,20); temp->runAction(CCSequence::create(createAni("change",5,0.05f),CCCallFuncN::create(this,callfuncN_selector(GameScene::tempCallback)),NULL)); }else{ GameData::addScore(temp->getScore()); } temp->setCollision(this); } } } if(((Prop*)(props[propIndex]->lastObject()))->getPosX() < 0){ for(int i = 0;i < props[propIndex]->count();i++){ props[propIndex]->objectAtIndex(i)->release(); } props[propIndex]->removeAllObjects(); if(++propIndex > 1){ propIndex = 0; } if(map->getPercent() > 0.7){ initProps(2200); }else{ initProps(854); } } if(hero->getState() != Role::ATTACK){ /* map->clearChange(); clearChange();*/ if(hero->getSprite()->getPositionY() < 130){ if(map->onLand(hero->getSprite())){ if(hero->getState() != Role::FALL && hero->getState() != Role::ATTACK){ hero->changeState(Role::NORMAL); }else if(hero->getState() == Role::ATTACK){ hero->hold(); } }else{ if(!hero->isProtected() && hero->getState() != Role::ATTACK && hero->getState() != Role::HOLD){ hero->fall(); }else if(hero->isProtected()){ hero->changeState(Role::NORMAL); } } }else if(hero->getSprite()->getPositionY() == 130){ if(!map->onLand(hero->getSprite()) && !hero->isProtected()) { hero->fall(); }else if(hero->getState() == Role::FALL && hero->isProtected()){ hero->changeState(Role::NORMAL); } } }else{ /* map->tempChange(SPEEDUP); tempChange(SPEEDUP);*/ } //武器是否否使用 if(map->weaponOn(hero)){ hero->weaponDone(map,dt); } if(hero->isDie()){ over = true; hero->setDie(this); CCSprite* temp = hero->getSprite(); temp->runAction(CCSequence::create(CCJumpTo::create(0.8, ccp(temp->getPositionX(),-200),300,1),CCCallFunc::create(this, callfunc_selector(GameScene::gameOver)),NULL)); //gameOver(); }else if(strcmp(hero->getChange(), "") != 0){ //变身状态 totalTime += dt; if(totalTime > 8){ hero->resumeNormal(); totalTime = 0; map->clearChange(); clearChange(); } } if(items->getPositionX() > -items->getContentSize().width){ items->setPositionX(items->getPositionX() - getSpeed() / 2); }else{ if(rand() % 10 == 5){ items->setPositionX(854); } } }
void CProp::read(const Prop& prop) { this->AddType = prop.addtype(); this->AddVal = prop.addval(); this->param = prop.param(); }