Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc @ 10859

Last change on this file since 10859 was 10859, checked in by gania, 8 years ago

almost all works now, check AITest.oxw

File size: 4.1 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#include "infos/PlayerInfo.h"
31
32namespace orxonox
33{
34
35    RegisterClass(DivisionController);
36
37    //Leaders share the fact that they have Wingmans
38    DivisionController::DivisionController(Context* context) : LeaderController(context)
39    {
40        RegisterObject(DivisionController);
41       
42        this->setFormationMode(FormationMode::DIAMOND);
43        this->target_ = 0;
44        this->myFollower_ = 0;
45        this->myWingman_ = 0;
46        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
47        this->rank_ = Rank::DIVISIONLEADER;
48    }
49
50    DivisionController::~DivisionController()
51    {
52        // if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
53        // {
54        //     if (this->myFollower_)
55        //     {
56        //         this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
57        //         if (this->myWingman_)
58        //         {
59        //             this->myWingman_->setAction(Action::FIGHTALL);
60        //         }
61        //     }
62        //     else if (this->myWingman_)
63        //     {
64        //         this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
65        //     }   
66        // }
67        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
68        {
69            if(this->actionpoints_[i])
70                this->actionpoints_[i]->destroy();
71        }
72        this->parsedActionpoints_.clear();
73        this->actionpoints_.clear();
74    } 
75
76    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
77    {
78        SUPER(DivisionController, XMLPort, xmlelement, mode);
79
80        //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
81    }
82    void DivisionController::tick(float dt)
83    {   
84        if (!this->isActive())
85            return;
86        SUPER(DivisionController, tick, dt);
87    }
88    void DivisionController::action()
89    {   
90        if (!this || !this->getControllableEntity())
91            return;
92        CommonController::action();
93       
94    }
95    void DivisionController::stayNearProtect()
96    {
97        CommonController::stayNearProtect();
98    }
99   
100    bool DivisionController::setWingman(CommonController* cwingman)
101    {
102
103        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
104        if (!this->myWingman_)
105        {
106            this->myWingman_ = wingman;
107            return true;
108        }
109        else
110        {
111            return false;
112        }
113    }
114    bool DivisionController::setFollower(LeaderController* myFollower)
115    {
116         if (!this->myFollower_)
117        {
118            this->myFollower_ = myFollower;
119            return true;
120        }
121        else
122        {
123            return false;
124        }
125    }
126    bool DivisionController::hasWingman()
127    {
128        if (this->myWingman_)
129            return true;
130        else
131            return false;
132    }
133    bool DivisionController::hasFollower()
134    {
135        if (this->myFollower_)
136            return true;
137        else
138            return false;
139    }
140}
Note: See TracBrowser for help on using the repository browser.