int startOfQueueCalc() { ActionQueueStructure queue = getQueue(NULL); if(queue->start != NULL) { return calculateCosts(queue->start->command,queue->start->option,queue->start->target); } return 0; }
/* *Checks start of action Queue for command, and actions it if all criteria are met */ int popToTower() { ActionQueueStructure queue = getQueue(NULL); GameProperties Game = getGame(NULL); int needed; if(queue->start != NULL) { needed = calculateCosts(queue->start->command,queue->start->option,queue->start->target); switch(queue->start->command) { case cmd_upgrade: if (checkQueue(queue, Game,needed)) { upgradeTowerStat(queue->start->option,queue->start->target); useMemory(Game, needed); removeQueueItem(); } break; case cmd_mktwr: if (checkQueue(queue,Game,needed)) { switch(queue->start->option) { case mktwr_int: createTowerTypeFromPositions(queue->start->target,INT_TYPE); break; case mktwr_char: createTowerTypeFromPositions(queue->start->target,CHAR_TYPE); break; default: fprintf(stderr,"Unrecognised tower type\n"); break; } //createTowerFromPositions(queue->start->target); useMemory(Game, needed); removeQueueItem(); } break; case cmd_aptget: if(checkQueue(queue,Game,needed)) { unlock_ability(KILL); useMemory(Game, needed); removeQueueItem(); } default: break; } } else { return 0; } return 1; }
/* *Pops from front of Queue. : replaced with popToTower() */ int popFromQueue(ActionQueueStructure queue, cmdType *cmd, cmdOption *stat, int *target) { GameProperties Game = getGame(NULL); int needed = calculateCosts(*cmd,*stat,*target); if((queue->start != NULL) && (checkQueue(queue,Game, needed))) { //! testing target, available Memory, cooldown time *cmd = queue->start->command; *stat = queue->start->option; *target = queue->start->target; QueueNode tempStart = queue->start; queue->start = queue->start->nextNode; free(tempStart); --(queue->nItems); useMemory(Game, needed); //use memory setlastAction(Game); //activate cooldown timer. return 1; } return 0; }
//Function executed at each frame bool mhtTrackingModule::run() { for(uint i=0; i<hyp.size(); i++) hyp.at(i).stimate(); measures_t_1.clear(); measures_t_1.insert(measures_t_1.begin(), measures_t.begin(), measures_t.end()); for(uint i=0; i<m_data->blobs.size(); i++) measures_t.push_back(measure((m_data->blobs.at(i).bbox.xleft+m_data->blobs.at(i).bbox.xleft)/2.0, (m_data->blobs.at(i).bbox.ytop+m_data->blobs.at(i).bbox.ybottom)/2.0, m_data->blobs.at(i).bbox.width, m_data->blobs.at(i).bbox.height)); for(uint i=0; i<hyp.size(); i++) calculateCosts(hyp.at(i)); getKhypothesis(); return true; }