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 "FleetController.h" |
---|
30 | |
---|
31 | |
---|
32 | namespace orxonox |
---|
33 | { |
---|
34 | |
---|
35 | RegisterClass(FleetController); |
---|
36 | |
---|
37 | FleetController::FleetController(Context* context) : Controller(context) |
---|
38 | { |
---|
39 | RegisterObject(FleetController); |
---|
40 | |
---|
41 | this->gameGoal_ = DOMINATE; |
---|
42 | this->goalPosition_ = NULL; |
---|
43 | this->goalTarget_ = NULL; |
---|
44 | this->goalProtect_ = NULL; |
---|
45 | this->nTicks_ = 0; |
---|
46 | this->bTicked_ = false; |
---|
47 | //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&FleetController::action, this))); |
---|
48 | } |
---|
49 | |
---|
50 | FleetController::~FleetController() |
---|
51 | { |
---|
52 | if (this->isInitialized()) |
---|
53 | { |
---|
54 | |
---|
55 | } |
---|
56 | } |
---|
57 | void FleetController::action() |
---|
58 | { |
---|
59 | |
---|
60 | |
---|
61 | } |
---|
62 | void FleetController::tick(float dt) |
---|
63 | { |
---|
64 | |
---|
65 | /*if (nTicks_ == 30) |
---|
66 | { |
---|
67 | std::vector<WeakPtr<WingmanController> > wingmen; |
---|
68 | std::vector<WeakPtr<LeaderController> > leaders; |
---|
69 | |
---|
70 | //--------------------------Put all WingmanController's in a vector-------------------------- |
---|
71 | for (ObjectList<WingmanController>::iterator it = ObjectList<WingmanController>::begin(); it; ++it) |
---|
72 | { |
---|
73 | |
---|
74 | |
---|
75 | if ((*it)->getTeam() == this->getTeam()) |
---|
76 | { |
---|
77 | orxout(internal_error) << "ANOTHER SUCKER" << endl; |
---|
78 | wingmen.push_back(*it); |
---|
79 | } |
---|
80 | |
---|
81 | } |
---|
82 | //--------------------------Substitute half of WingmanController's with LeaderController-------------------------- |
---|
83 | |
---|
84 | bool nowLeader = true; |
---|
85 | LeaderController* leader; |
---|
86 | |
---|
87 | for (std::vector<WeakPtr<WingmanController> >::iterator it = wingmen.begin() ; it != wingmen.end(); ++it) |
---|
88 | { |
---|
89 | if (nowLeader) |
---|
90 | { |
---|
91 | leader = new LeaderController(this->getContext()); |
---|
92 | leader->setTeam(this->team_); |
---|
93 | |
---|
94 | (*it)->getControllableEntity()->setController(leader); |
---|
95 | leaders.push_back(leader); |
---|
96 | nowLeader = !nowLeader; |
---|
97 | orxout(internal_error) << "NEW SUCKER" << endl; |
---|
98 | |
---|
99 | } |
---|
100 | else |
---|
101 | { |
---|
102 | if (leader) |
---|
103 | { |
---|
104 | leader->setWingman(*it); |
---|
105 | nowLeader = !nowLeader; |
---|
106 | orxout(internal_error) << "I OWN THE SUCKER" << endl; |
---|
107 | |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | //--------------------------Substitute half of LeaderController's with DivisionController-------------------------- |
---|
113 | bool nowDivision = true; |
---|
114 | DivisionController* division; |
---|
115 | |
---|
116 | for (std::vector<WeakPtr<LeaderController> >::iterator it = leaders.begin() ; it != leaders.end(); ++it) |
---|
117 | { |
---|
118 | if (nowDivision) |
---|
119 | { |
---|
120 | division = new DivisionController(this->getContext()); |
---|
121 | division->setTeam(this->team_); |
---|
122 | |
---|
123 | (*it)->getControllableEntity()->setController(division); |
---|
124 | |
---|
125 | divisions_.push_back(division); |
---|
126 | |
---|
127 | nowDivision = !nowDivision; |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | if (division) |
---|
132 | { |
---|
133 | division->setLeader(*it); |
---|
134 | nowDivision = !nowDivision; |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | bTicked_ = true; |
---|
139 | nTicks_ += 1; |
---|
140 | } |
---|
141 | else if (!bTicked_) |
---|
142 | { |
---|
143 | nTicks_ += 1; |
---|
144 | |
---|
145 | }*/ |
---|
146 | SUPER(FleetController, tick, dt); |
---|
147 | |
---|
148 | } |
---|
149 | void FleetController::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
150 | { |
---|
151 | SUPER(FleetController, XMLPort, xmlelement, mode); |
---|
152 | |
---|
153 | //XMLPortObject(FleetController, GameGoal, "gameGoal", setGameGoal, getGameGoal, xmlelement, mode).defaultValues(DOMINATE); |
---|
154 | //XMLPortParam(FleetController, "goalPosition", setGoalPosition, getGoalPosition, xmlelement, mode).defaultValues(NULL); |
---|
155 | //XMLPortParam(FleetController, "goalTarget", setGoalTarget, getGoalTarget, xmlelement, mode).defaultValues(NULL); |
---|
156 | //XMLPortParam(FleetController, "goalProtect", setGoalProtect, getGoalProtect, xmlelement, mode).defaultValues(NULL); |
---|
157 | |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | } |
---|