Changeset 3084 for code/trunk/src/orxonox/objects/worldentities
- Timestamp:
- May 26, 2009, 9:20:57 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
r3049 r3084 379 379 registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 380 380 registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 381 381 382 382 383 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); -
code/trunk/src/orxonox/objects/worldentities/MobileEntity.h
r3068 r3084 61 61 { this->setAngularVelocity(Vector3(x, y, z)); } 62 62 inline const Vector3& getAngularVelocity() const 63 { return this-> linearAcceleration_; }63 { return this->angularVelocity_; } 64 64 65 65 void setAcceleration(const Vector3& acceleration); -
code/trunk/src/orxonox/objects/worldentities/PongBall.cc
r2896 r3084 32 32 #include "core/CoreIncludes.h" 33 33 #include "core/GameMode.h" 34 #include "objects/worldentities/PongBat.h"35 34 #include "objects/gametypes/Gametype.h" 36 35 … … 47 46 this->speed_ = 0; 48 47 this->bat_ = 0; 48 this->batID_ = new unsigned int[2]; 49 this->batID_[0] = OBJECTID_UNKNOWN; 50 this->batID_[1] = OBJECTID_UNKNOWN; 49 51 this->relMercyOffset_ = 0.05; 52 53 this->registerVariables(); 54 } 55 56 void PongBall::registerVariables() 57 { 58 registerVariable( this->fieldWidth_ ); 59 registerVariable( this->fieldHeight_ ); 60 registerVariable( this->batlength_ ); 61 registerVariable( this->speed_ ); 62 registerVariable( this->relMercyOffset_ ); 63 registerVariable( this->batID_[0] ); 64 registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) ); 50 65 } 51 66 … … 119 134 this->setPosition(position); 120 135 } 136 else 137 { 138 Vector3 position = this->getPosition(); 139 Vector3 velocity = this->getVelocity(); 140 141 if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2) 142 { 143 velocity.z = -velocity.z; 144 145 if (position.z > this->fieldHeight_ / 2) 146 position.z = this->fieldHeight_ / 2; 147 if (position.z < -this->fieldHeight_ / 2) 148 position.z = -this->fieldHeight_ / 2; 149 } 150 151 if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2) 152 { 153 float distance = 0; 154 155 if (this->bat_) 156 { 157 if (position.x > this->fieldWidth_ / 2 && this->bat_[1]) 158 { 159 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2); 160 if (fabs(distance) <= 1) 161 { 162 position.x = this->fieldWidth_ / 2; 163 velocity.x = -velocity.x; 164 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 165 } 166 } 167 if (position.x < -this->fieldWidth_ / 2 && this->bat_[0]) 168 { 169 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2); 170 if (fabs(distance) <= 1) 171 { 172 position.x = -this->fieldWidth_ / 2; 173 velocity.x = -velocity.x; 174 velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_; 175 } 176 } 177 } 178 } 179 180 if (velocity != this->getVelocity()) 181 this->setVelocity(velocity); 182 if (position != this->getPosition()) 183 this->setPosition(position); 184 } 121 185 } 122 186 -
code/trunk/src/orxonox/objects/worldentities/PongBall.h
r2885 r3084 33 33 34 34 #include "objects/worldentities/MovableEntity.h" 35 #include "objects/worldentities/PongBat.h" 35 36 36 37 namespace orxonox … … 43 44 44 45 virtual void tick(float dt); 46 47 void registerVariables(); 45 48 46 49 void setFieldDimension(float width, float height) … … 61 64 62 65 void setBats(PongBat** bats) 63 { this->bat_ = bats; } 66 { this->bat_ = bats; this->batID_[0] = this->bat_[0]->getObjectID(); this->batID_[1] = this->bat_[1]->getObjectID(); } 67 68 void applyBats() 69 { if(!this->bat_) this->bat_ = new PongBat*[2]; if(this->batID_[0] != OBJECTID_UNKNOWN) this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0])); if(this->batID_[1] != OBJECTID_UNKNOWN) this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); } 64 70 65 71 static const float MAX_REL_Z_VELOCITY; … … 71 77 float batlength_; 72 78 PongBat** bat_; 79 unsigned int* batID_; 73 80 float relMercyOffset_; 74 81 }; -
code/trunk/src/orxonox/objects/worldentities/PongBat.cc
r2839 r3084 54 54 { 55 55 registerVariable(this->speed_); 56 registerVariable(this-> speed_);57 registerVariable(this-> speed_);56 registerVariable(this->fieldHeight_); 57 registerVariable(this->length_); 58 58 } 59 59 … … 91 91 position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2; 92 92 if (position != this->getPosition()) 93 { 93 94 this->setPosition(position); 95 this->setVelocity( Vector3::ZERO ); 96 } 94 97 } 95 98 … … 97 100 { 98 101 this->bMoveLocal_ = false; 99 this->movement_ -=value.x;102 this->movement_ = -value.x; 100 103 } 101 104 -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
r3073 r3084 39 39 #include "objects/worldentities/ParticleSpawner.h" 40 40 #include "objects/worldentities/ExplosionChunk.h" 41 41 42 #include "objects/weaponsystem/WeaponSystem.h" 42 43 #include "objects/weaponsystem/WeaponSlot.h" … … 44 45 #include "objects/weaponsystem/WeaponSet.h" 45 46 47 #include "network/NetworkFunction.h" 48 46 49 namespace orxonox 47 50 { 48 51 CreateFactory(Pawn); 52 53 registerMemberNetworkFunction( Pawn, doFire ); 49 54 50 55 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) … … 123 128 SUPER(Pawn, tick, dt); 124 129 125 if (this->weaponSystem_ && GameMode::isMaster())126 {127 for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++)128 if (this->fire_ & WeaponSystem::getFiremodeMask(firemode))129 this->weaponSystem_->fire(firemode);130 131 if (this->bReload_)132 this->weaponSystem_->reload();133 }134 135 this->fire_ = this->firehack_;136 this->firehack_ = 0x0;130 // if (this->weaponSystem_ && GameMode::isMaster()) 131 // { 132 // for (unsigned int firemode = 0; firemode < WeaponSystem::MAX_FIRE_MODES; firemode++) 133 // if (this->fire_ & WeaponSystem::getFiremodeMask(firemode)) 134 // this->weaponSystem_->fire(firemode); 135 // 136 // if (this->bReload_) 137 // this->weaponSystem_->reload(); 138 // } 139 // 140 // this->fire_ = this->firehack_; 141 // this->firehack_ = 0x0; 137 142 this->bReload_ = false; 138 143 139 if (this->health_ <= 0) 144 if (GameMode::isMaster()) 145 if (this->health_ <= 0) 140 146 this->death(); 141 147 } … … 263 269 void Pawn::fire(unsigned int firemode) 264 270 { 265 this->firehack_ |= WeaponSystem::getFiremodeMask(firemode); 271 this->doFire(firemode); 272 } 273 274 void Pawn::doFire(uint8_t firemode) 275 { 276 if(GameMode::isMaster()) 277 { 278 if (this->weaponSystem_) 279 this->weaponSystem_->fire(firemode); 280 } 281 else 282 { 283 callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, ((uint8_t)firemode)); 284 if (this->weaponSystem_) 285 this->weaponSystem_->fire(firemode); 286 } 266 287 } 267 288 -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
r3073 r3084 79 79 virtual void fire(unsigned int firemode); 80 80 virtual void reload(); 81 virtual void doFire(uint8_t firemode); 81 82 virtual void postSpawn(); 82 83
Note: See TracChangeset
for help on using the changeset viewer.