Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

ships spread before fight

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