Changeset 8434 for code/branches/dockingsystem2
- Timestamp:
- May 9, 2011, 4:26:37 PM (14 years ago)
- Location:
- code/branches/dockingsystem2
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dockingsystem2/data/levels/docking.oxw
r8382 r8434 27 27 <Light type="directional" position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> 28 28 29 30 29 31 <?lua for i = 1, 10, 1 do ?> 30 <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />32 <SpawnPoint position="<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" /> 31 33 <?lua end ?> 32 34 33 <Dock position="-50,-100,50"> 34 <effects> 35 <DockToShip target="theDestroyer" /> 36 </effects> 37 <events> 38 <execute> 39 <EventListener event="dockMe" /> 40 </execute> 41 </events> 42 <attached> 43 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" /> 44 <Billboard material="Examples/Flare" colour="1.0, 0, 0" /> 45 </attached> 46 </Dock> 47 48 49 35 36 37 38 <Dock> 39 <effects> 40 <DockToShip target="destroyer" /> 41 </effects> 42 <events> 43 <execute> 44 <EventListener event="dockMe" /> 45 </execute> 46 </events> 47 <attached> 48 <DistanceTrigger position="0,0,0" distance="50" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" /> 49 <Billboard material="Examples/Flare" colour="1.0, 0, 0" /> 50 </attached> 51 </Dock> 52 53 50 54 51 55 <SpaceShip 56 position = "-150,-50,-100" 52 57 hudtemplate = "spaceshiphud" 53 58 camerapositiontemplate = "spaceshipassffcameras" … … 71 76 > 72 77 <attached> 73 <DistanceTriggerBeacon name="b eacon1" />74 <DockingTarget name=" asdf" />78 <DistanceTriggerBeacon name="bcnSpaceShip1" /> 79 <DockingTarget name="spaceShip1" /> 75 80 76 81 <Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" /> … … 96 101 97 102 <Destroyer 98 position = "100,150, 0"103 position = "100,150,100" 99 104 collisionType = "dynamic" 100 105 mass = "100000" … … 108 113 <attached> 109 114 110 <DistanceTriggerBeacon name=" destroyerBeacon" />111 <DockingTarget name=" theDestroyer" />115 <DistanceTriggerBeacon name="bcnDestroyer" /> 116 <DockingTarget name="destroyer" /> 112 117 113 118 -
code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
r8257 r8434 10 10 FIND_HEADER_FILES 11 11 TOLUA_FILES 12 Dock.h 12 13 PCH_FILE 13 14 DockingPrecompiledHeaders.h -
code/branches/dockingsystem2/src/modules/docking/Dock.cc
r8382 r8434 34 34 #include "Dock.h" 35 35 36 #include "core/CoreIncludes.h" 37 #include "core/LuaState.h" 38 #include "core/GUIManager.h" 36 39 #include "infos/HumanPlayer.h" 37 40 #include "worldentities/pawns/Pawn.h" 38 41 #include "interfaces/PlayerTrigger.h" 39 #include "controllers/HumanController.h"40 42 #include "core/command/ConsoleCommand.h" 41 43 42 44 #include "ToluaBindDocking.h" 43 45 44 46 namespace orxonox 45 47 { 48 // Register tolua_open function when loading the library 49 DeclareToluaInterface(Docking); 50 46 51 CreateFactory(Dock); 47 52 … … 111 116 COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl; 112 117 113 if(bTriggered) { 118 if(bTriggered) 119 { 114 120 // Add player to this Docks candidates 115 121 candidates.insert(player); 116 122 123 // Show docking dialog 124 GUIManager::showGUI("DockingDialog"); 117 125 //DockingEffect::invokeEffect(docking::DOCKING, player, effects_); 118 } else { 126 } 127 else 128 { 119 129 // Remove player from candidates list 120 130 candidates.erase(player); … … 127 137 128 138 129 void Dock::cmdDock() { 130 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 131 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) { 139 void Dock::cmdDock() 140 { 141 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 142 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 143 { 132 144 if(it->dock(player)) 133 145 break; … … 135 147 } 136 148 137 void Dock::cmdUndock() { 138 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 139 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) { 149 void Dock::cmdUndock() 150 { 151 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 152 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 153 { 140 154 if(it->undock(player)) 141 155 break; … … 144 158 145 159 146 bool Dock::dock(PlayerInfo* player) { 160 bool Dock::dock(PlayerInfo* player) 161 { 147 162 // Check if player is a candidate 148 if(candidates.find(player) == candidates.end()) { 149 COUT(0) << "Player is not a candidate!"; 163 if(candidates.find(player) == candidates.end()) 164 { 165 COUT(0) << "Player is not a candidate!" << std::endl; 150 166 return false; 151 167 } … … 158 174 } 159 175 160 bool Dock::undock(PlayerInfo* player) { 176 bool Dock::undock(PlayerInfo* player) 177 { 161 178 // Check if player is docked to this Dock 162 if(docked.find(player) == docked.end()) { 179 if(docked.find(player) == docked.end()) 180 { 163 181 COUT(0) << "Player is not docked to this Dock." << std::endl; 164 182 return false; … … 173 191 174 192 175 bool Dock::addEffect(DockingEffect* effect) { 193 unsigned int Dock::getNumberOfActiveDocks() 194 { 195 int i = 0; 196 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 197 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 198 { 199 if(it->candidates.find(player) != it->candidates.end()) 200 i++; 201 } 202 return i; 203 } 204 205 Dock* Dock::getActiveDockAtIndex(unsigned int index) 206 { 207 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 208 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 209 { 210 if(it->candidates.find(player) != it->candidates.end()) 211 { 212 if(index == 0) 213 return *it; 214 index--; 215 } 216 } 217 return NULL; 218 } 219 220 221 bool Dock::addEffect(DockingEffect* effect) 222 { 176 223 assert(effect); 177 224 effects.push_back(effect); … … 179 226 } 180 227 181 const DockingEffect* Dock::getEffect(unsigned int index) const { 228 const DockingEffect* Dock::getEffect(unsigned int index) const 229 { 182 230 int i = index; 183 for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) { 231 for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) 232 { 184 233 if(i == 0) 185 234 return *effect; -
code/branches/dockingsystem2/src/modules/docking/Dock.h
r8383 r8434 43 43 44 44 #include "worldentities/StaticEntity.h" 45 #include " notifications/NotificationManager.h"45 #include "controllers/HumanController.h" 46 46 47 47 #include "DockingEffect.h" 48 48 #include "DockingPrereqs.h" 49 49 50 namespace orxonox { 50 namespace orxonox // tolua_export 51 { // tolua_export 51 52 52 class _DockingExport Dock : public StaticEntity { 53 class _DockingExport Dock // tolua_export 54 : public StaticEntity 55 { // tolua_export 53 56 public: 54 57 Dock(BaseObject* creator); … … 66 69 bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked) 67 70 71 void dock() { this->dock(HumanController::getLocalControllerSingleton()->getPlayer()); } // tolua_export 72 static unsigned int getNumberOfActiveDocks(); // tolua_export 73 static Dock* getActiveDockAtIndex(unsigned int index); // tolua_export 74 68 75 static void cmdDock(); 69 76 static void cmdUndock(); … … 73 80 std::set<PlayerInfo*> docked; //!< A set of all docked players 74 81 std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks. 75 }; 76 77 78 } 82 }; // tolua_export 83 } // tolua_export 79 84 80 85 #endif /* _Dock_H__ */
Note: See TracChangeset
for help on using the changeset viewer.