Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc @ 10737

Last change on this file since 10737 was 10737, checked in by gania, 9 years ago

nothing really changed

File size: 5.7 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      Dominik Solenicki
26 *
27 */
28
29#include "DivisionController.h"
30
31
32namespace orxonox
33{
34
35    RegisterClass(DivisionController);
36
37    DivisionController::DivisionController(Context* context) : LeaderController(context)
38    {
39        RegisterObject(DivisionController);
40        this->setFormationMode(WALL);
41
42        this->myFollower_ = 0;
43        this->myWingman_ = 0;
44        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
45        this->rank_ = DIVISIONLEADER;
46
47        Vector3* pos = new Vector3(500,500,-500);
48        this->setTargetPosition(*pos);
49
50    }
51
52    DivisionController::~DivisionController()
53    {
54     
55    } 
56
57   
58    void DivisionController::tick(float dt)
59    {
60        if (this->target_)
61        {
62            //this->aimAtTarget();
63            //this->doFire();
64            //this->bShooting_ = true;
65        }
66     
67        if (this->bHasTargetPosition_)
68        {
69            this->moveToTargetPosition();
70        }
71
72        SUPER(DivisionController, tick, dt);
73
74    }
75    void DivisionController::action()
76    {
77        setTargetPositionOfFollower();
78        setTargetPositionOfWingman();
79/*
80        for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
81        {
82            if (this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())
83            {
84                this->target_=it->getControllableEntity();
85                this->setTargetPosition(this->target_->getWorldPosition());
86                break;
87            }
88        }*/
89           
90     
91    }
92
93   
94
95    void DivisionController::setTargetPositionOfWingman()
96    {
97        if (!this->myWingman_)
98            return;
99        Vector3* targetRelativePositionOfWingman;
100        switch (this->formationMode_){
101            case WALL:
102            {
103                targetRelativePositionOfWingman = new Vector3 (400, 0, 0); 
104                break;
105            }
106            case FINGER4: 
107            {
108                break;
109            }
110            case VEE: 
111            {
112                break;
113            }
114            case DIAMOND: 
115            {
116                break;
117            }
118        }
119        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
120       
121        Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 
122        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
123       
124        myWingman_->setTargetOrientation(orient);
125        myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
126       
127    }
128    void DivisionController::setTargetPositionOfFollower()
129    {
130        if (!this->myFollower_)
131            return;
132        Vector3* targetRelativePositionOfFollower;
133        switch (this->formationMode_){
134            case WALL:
135            {
136                targetRelativePositionOfFollower = new Vector3 (-400, 0, 0);   
137                break;
138            }
139            case FINGER4: 
140            {
141                break;
142            }
143            case VEE: 
144            {
145                break;
146            }
147            case DIAMOND: 
148            {
149                break;
150            }
151        }
152        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
153       
154        Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) + 
155        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
156       
157        myFollower_->setTargetOrientation(orient);
158        myFollower_->setTargetPosition(targetAbsolutePositionOfFollower);
159       
160    }
161
162
163    bool DivisionController::setWingman(CommonController* cwingman)
164    {
165
166        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
167        if (!this->myWingman_)
168        {
169            this->myWingman_ = wingman;
170            return true;
171        }
172        else
173        {
174            return false;
175        }
176   
177    }
178    bool DivisionController::setFollower(LeaderController* myFollower)
179    {
180         if (!this->myFollower_)
181        {
182            this->myFollower_ = myFollower;
183            return true;
184        }
185        else
186        {
187            return false;
188        }
189    }
190    bool DivisionController::hasWingman()
191    {
192        if (this->myWingman_)
193            return true;
194        else
195            return false;
196    }
197    bool DivisionController::hasFollower()
198    {
199        if (this->myFollower_)
200            return true;
201        else
202            return false;
203    }
204
205
206    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
207    {
208        SUPER(DivisionController, XMLPort, xmlelement, mode);
209
210        //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
211    }
212
213   
214   
215
216}
Note: See TracBrowser for help on using the repository browser.