Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ai/src/ai/ai_team.cc @ 10158

Last change on this file since 10158 was 10158, checked in by tfahrni, 17 years ago

tried some new ideas for swarming and fixed a bug in Vector.h

File size: 1.4 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Thomas Fahrni
13   co-programmer:
14*/
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_AI
16#include "ai_team.h"
17#include "debug.h"
18
19void AITeam::process(float dt)
20{
21        //int x;
22        //int z;
23        //Vector random;
24       
25        std::map<int,AISwarm*>::iterator it;
26        for (it= swarms.begin(); it!= swarms.end(); it++ ){
27       
28                //x = 20*(rand()%10 + 1)-100;
29                //z = 20*(rand()%10 + 1)-100;
30                //random=Vector(x,0,z);
31               
32                it->second->setEnemyList(enemyList);
33                if(enemyList->size()>0)
34                        it->second->setDestination(enemyList->at(0)->getAbsCoor());
35                it->second->process(dt);
36        }
37}
38
39void AITeam::addAI(int swarmNumber, AIModule* aiModule)
40{
41        std::pair<std::map<int,AISwarm*>::iterator,bool> p;
42        AISwarm* newSwarm=new AISwarm();
43        p=swarms.insert(std::make_pair(swarmNumber,newSwarm));
44        if(!p.second)delete newSwarm;
45        p.first->second->addAI(aiModule);
46}
47
48void AITeam::removeAI(int swarmNumber, AIModule* aiModule)
49{
50        std::map<int,AISwarm*>::iterator it = swarms.find(swarmNumber);
51        if(it==swarms.end())return;
52        it->second->removeAI(aiModule);
53        if(it->second->getSwarmSize()==0){
54                delete it->second;
55                swarms.erase(it);
56        }
57}
Note: See TracBrowser for help on using the repository browser.