- Timestamp:
- Dec 16, 2008, 6:01:13 PM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/orxonox/gamestates/GSLevel.cc
r2460 r2485 41 41 #include "core/CoreIncludes.h" 42 42 #include "core/Core.h" 43 //#include "objects/Backlight.h"44 43 #include "objects/Tickable.h" 45 44 #include "objects/Radar.h" 46 //#include "tools/ParticleInterface.h"47 45 #include "CameraManager.h" 48 46 #include "LevelManager.h" 47 #include "PlayerManager.h" 49 48 #include "Settings.h" 50 49 … … 55 54 GSLevel::GSLevel() 56 55 // : GameState<GSGraphics>(name) 57 : timeFactor_(1.0f) 58 , keyBinder_(0) 56 : keyBinder_(0) 59 57 , inputState_(0) 60 58 , radar_(0) … … 64 62 { 65 63 RegisterObject(GSLevel); 64 65 this->ccKeybind_ = 0; 66 this->ccTkeybind_ = 0; 67 66 68 setConfigValues(); 67 69 } … … 95 97 } 96 98 99 this->playerManager_ = new PlayerManager(); 100 97 101 if (Core::isMaster()) 98 102 { 99 103 // create the global LevelManager 100 104 this->levelManager_ = new LevelManager(); 101 102 // reset game speed to normal103 timeFactor_ = 1.0f;104 105 105 106 this->loadLevel(); … … 114 115 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); 115 116 functor1->setObject(this); 116 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind")); 117 ccKeybind_ = createConsoleCommand(functor1, "keybind"); 118 CommandExecutor::addConsoleCommandShortcut(ccKeybind_); 117 119 FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind); 118 120 functor2->setObject(this); 119 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind")); 121 ccTkeybind_ = createConsoleCommand(functor2, "tkeybind"); 122 CommandExecutor::addConsoleCommandShortcut(ccTkeybind_); 120 123 // set our console command as callback for the key detector 121 124 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); … … 124 127 InputManager::getInstance().requestEnterState("game"); 125 128 } 126 127 if (Core::isMaster())128 {129 // time factor console command130 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);131 functor->setObject(this);132 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;133 }134 129 } 135 130 136 131 void GSLevel::leave() 137 132 { 133 // destroy console commands 134 if (this->ccKeybind_) 135 { 136 delete this->ccKeybind_; 137 this->ccKeybind_ = 0; 138 } 139 if (this->ccTkeybind_) 140 { 141 delete this->ccTkeybind_; 142 this->ccTkeybind_ = 0; 143 } 144 138 145 // this call will delete every BaseObject! 139 146 // But currently this will call methods of objects that exist no more … … 149 156 150 157 if (this->radar_) 158 { 151 159 delete this->radar_; 160 this->radar_ = 0; 161 } 152 162 153 163 if (this->cameraManager_) 164 { 154 165 delete this->cameraManager_; 166 this->cameraManager_ = 0; 167 } 155 168 156 169 if (this->levelManager_) 170 { 157 171 delete this->levelManager_; 172 this->levelManager_ = 0; 173 } 174 175 if (this->playerManager_) 176 { 177 delete this->playerManager_; 178 this->playerManager_ = 0; 179 } 158 180 159 181 if (Core::showsGraphics()) … … 162 184 InputManager::getInstance().requestDestroyState("game"); 163 185 if (this->keyBinder_) 186 { 164 187 delete this->keyBinder_; 188 this->keyBinder_ = 0; 189 } 165 190 } 166 191 } … … 172 197 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 173 198 // it->tick(time.getDeltaTime() * this->timeFactor_); 174 }175 176 /**177 @brief178 Changes the speed of Orxonox179 */180 void GSLevel::setTimeFactor(float factor)181 {182 /*183 float change = factor / this->timeFactor_;184 */185 this->timeFactor_ = factor;186 /*187 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)188 it->setSpeedFactor(it->getSpeedFactor() * change);189 190 for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)191 it->setTimeFactor(timeFactor_);192 */193 199 } 194 200
Note: See TracChangeset
for help on using the changeset viewer.