Changeset 9868 for code/branches/invaders
- Timestamp:
- Dec 3, 2013, 8:18:15 PM (11 years ago)
- Location:
- code/branches/invaders
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/invaders/data/levels/Invaders.oxw
r9866 r9868 25 25 <?lua include("includes/notifications.oxi") ?> 26 26 27 <!-- ambientlight = "0.8, 0.8, 0.8" 28 skybox = "Orxonox/Starbox" --> 27 29 <Scene 28 ambientlight = "0.8, 0. 8, 0.8"29 skybox = "Orxonox/Starbox"30 ambientlight = "0.8, 0.7, 0.4" 31 skybox = "Orxonox/skyBoxBasic" 30 32 > 31 33 32 <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"/> 34 <!-- <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"/> --> 35 <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> 33 36 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=InvaderShip pawndesign=spaceshipinvader /> 34 <MovableEntity35 position = "-200,0,0"36 velocity = "975.7, 0, 0"37 >38 <events>39 <activity>40 <EventListener event="start" />41 </activity>42 </events>43 <attached>44 45 <Model mass="1000" mesh="ast1.mesh" />46 </attached>47 <camerapositions>48 <CameraPosition position="0,300,-100" direction="0, -1, 0" drag=false mouselook=true />49 </camerapositions>50 </MovableEntity>51 37 52 38 <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 /> -
code/branches/invaders/data/levels/includes/invaderWeapon.oxi
r9862 r9868 15 15 <Weapon> 16 16 <InvaderWeapon mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" projectileMesh="laserbeam.mesh" /> 17 <!--InvaderWeapon mode=0 munitionpershot=0 delay=018 19 LaserBeam220 21 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-1.6, 1.3,-2" projectileMesh="LaserBeam.mesh" /-->22 17 </Weapon> 23 18 <Weapon> 24 19 <InvaderWeapon mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" projectileMesh="laserbeam.mesh" /> 25 <!--InvaderWeapon mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.1, 1.6, -2.0" projectileMesh="LaserBeam.mesh" /-->26 20 </Weapon> 27 21 </WeaponPack> -
code/branches/invaders/data/levels/templates/enemyInvader.oxt
r9854 r9868 7 7 explosionchunks = 4 8 8 9 health = 10 010 maxhealth = 10 011 initialhealth = 10 09 health = 10 10 maxhealth = 10 11 initialhealth = 10 12 12 13 shieldhealth = 3514 initialshieldhealth = 3515 maxshieldhealth = 6013 shieldhealth = 10 14 initialshieldhealth = 10 15 maxshieldhealth = 10 16 16 shieldabsorption = 0.9 17 17 reloadrate = 1 -
code/branches/invaders/data/overlays/InvaderHUD.oxo
r9854 r9868 69 69 /> 70 70 71 72 <OverlayText73 position = "0.4, 0.1"74 pickpoint = "0.0, 0.0"75 font = "ShareTechMono"76 textsize = 0.0477 colour = "1.0, 1.0, 1.0, 1.0"78 align = "left"79 caption = "X"80 />81 71 <InvaderHUDinfo 82 position = "0. 42, 0.1"72 position = "0.25, 0.1" 83 73 pickpoint = "0.0, 0.0" 84 74 font = "ShareTechMono" -
code/branches/invaders/src/modules/invader/Invader.cc
r9866 r9868 59 59 RegisterObject(Invader); 60 60 this->center_ = 0; 61 init(); 62 this->setHUDTemplate("InvaderHUD"); 63 } 61 64 62 this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) ); 63 //this->context = context; 64 this->setHUDTemplate("InvaderHUD"); 65 65 void Invader::init() 66 { 67 bEndGame = false; 66 68 lives = 3; 69 // TODO: 67 70 level = 1; 68 71 point = 0; 69 72 multiplier = 1; 70 73 b_combo = false; 74 // spawn enemy every 2 seconds 71 75 enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this))); 72 76 comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this))); 73 }74 75 Invader::~Invader()76 {77 77 } 78 78 … … 94 94 newPawn->setPlayer(player); 95 95 newPawn->level = level; 96 // spawn enemy at random points in front of player. 96 97 newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 97 98 } … … 101 102 { 102 103 lives--; 103 multiplier = 0; 104 if (lives <= 0) end(); 104 multiplier = 1; 105 // end the game in 30 seconds. 106 if (lives <= 0) 107 enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this))); 105 108 }; 106 109 … … 109 112 if (b_combo) 110 113 multiplier++; 114 // if no combo was performed before, reset multiplier 111 115 else 112 116 multiplier = 1; … … 114 118 } 115 119 116 // inject custom player controller117 /** void Invader::spawnPlayer(PlayerInfo* player)118 {119 assert(player);120 121 //player->startControl(new InvaderShip(this->center_->getContext() ) );122 }*/123 124 120 void Invader::start() 125 121 { 122 init(); 126 123 // Set variable to temporarily force the player to spawn. 127 124 this->bForceSpawn_ = true; … … 137 134 } 138 135 136 139 137 void Invader::end() 140 138 { 141 orxout() << "STOP THE GAME, CHEATER!!!" << endl; 142 // Call end for the parent class. 143 // Deathmatch::end(); 139 // DON'T CALL THIS! 140 // Deathmatch::end(); 141 // It will misteriously crash the game! 142 // Instead startMainMenu, this won't crash. 143 GSLevel::startMainMenu(); 144 144 } 145 145 } -
code/branches/invaders/src/modules/invader/Invader.h
r9866 r9868 29 29 /** 30 30 @file Invader.h 31 @brief Declaration of the Invader class.31 @brief Gametype. 32 32 @ingroup Invader 33 33 */ … … 50 50 { 51 51 public: 52 Invader(Context* context); //!< Constructor. Registers and initializes the object. 53 virtual ~Invader(); //!< Destructor. Cleans up, if initialized. 52 Invader(Context* context); 54 53 55 virtual void start(); //!< Starts the Invader minigame. 56 virtual void end(); ///!< Ends the Invader minigame. 57 58 //virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player. 54 virtual void start(); 55 virtual void end(); 59 56 60 57 void spawnEnemy(); … … 71 68 void levelUp(){level++;} 72 69 void addPoints(int numPoints){point += numPoints * multiplier; b_combo = true;} 70 // checks if multiplier should be reset. 73 71 void comboControll(); 72 void init(); 74 73 int lives; 74 int multiplier; 75 bool bEndGame; 75 76 private: 76 77 WeakPtr<InvaderCenterPoint> center_; 77 78 WeakPtr<InvaderShip> player; 78 79 79 ConsoleCommand* console_addEnemy;80 80 Timer enemySpawnTimer; 81 81 Timer comboTimer; … … 84 84 int point; 85 85 bool b_combo; 86 int multiplier;87 86 }; 88 87 } -
code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc
r9725 r9868 42 42 RegisterClass(InvaderCenterPoint); 43 43 44 /**45 @brief46 Constructor. Registers and initializes the object and checks whether the gametype is actually Invader.47 */48 44 InvaderCenterPoint::InvaderCenterPoint(Context* context) : StaticEntity(context) 49 45 { … … 53 49 } 54 50 55 /**56 @brief57 Method to create a InvaderCenterPoint through XML.58 */59 51 void InvaderCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 52 { 61 53 SUPER(InvaderCenterPoint, XMLPort, xmlelement, mode); 62 63 // XMLPortParam(InvaderCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);64 65 54 } 66 55 67 /**68 @brief69 Is called when the gametype has changed.70 */71 56 void InvaderCenterPoint::changedGametype() 72 57 { … … 77 62 } 78 63 79 /**80 @brief81 Checks whether the gametype is Invader and if it is, sets its centerpoint.82 */83 64 void InvaderCenterPoint::checkGametype() 84 65 { -
code/branches/invaders/src/modules/invader/InvaderCenterPoint.h
r9725 r9868 45 45 { 46 46 public: 47 InvaderCenterPoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Invader. 48 virtual ~InvaderCenterPoint() {} 47 InvaderCenterPoint(Context* context); //checks whether the gametype is actually Invader. 49 48 50 51 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML. 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 50 53 51 virtual void changedGametype(); //!< Is called when the gametype has changed. 54 52 private: 55 void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.53 void checkGametype(); 56 54 57 55 }; -
code/branches/invaders/src/modules/invader/InvaderEnemy.cc
r9866 r9868 50 50 { 51 51 lifetime += dt; 52 // die after 5 seconds. 52 53 if (lifetime > 5000) 53 {54 54 removeHealth(2000); 55 } 55 56 56 if (player != NULL) 57 57 { 58 58 float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01, 2) + 1) * (player->getPosition().z - getPosition().z); 59 // if (newZ < 0)60 // newZ = (-100 < newZ)?-100:newZ;61 // else62 // newZ = (100 > newZ)?100:newZ;63 59 setVelocity(Vector3(1000 - level * 100 , 0, newZ)); 64 60 } … … 68 64 inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 69 65 { 70 // setVelocity(Vector3(1500,0,0));71 removeHealth(2000);66 if(orxonox_cast<Pawn*>(otherObject)) 67 removeHealth(2000); 72 68 return false; 73 69 } … … 87 83 if (getGame()) 88 84 getGame()->addPoints(42); 89 // SUPER(InvaderEnemy, damage,damage, healthdamage, shielddamage, originator);85 Pawn::damage(damage, healthdamage, shielddamage, originator); 90 86 } 91 87 } -
code/branches/invaders/src/modules/invader/InvaderEnemy.h
r9854 r9868 45 45 public: 46 46 InvaderEnemy(Context* context); 47 // virtual ~InvaderEnemy() {}48 47 49 48 virtual void tick(float dt); -
code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
r9866 r9868 47 47 } 48 48 49 InvaderHUDinfo::~InvaderHUDinfo()50 {51 }52 53 49 void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 50 { … … 75 71 { 76 72 const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel()); 77 this->setCaption(Level); 73 if (this->InvaderGame->lives <= 0) 74 { 75 setPosition(Vector2(0.1, 0.65)); 76 this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart press space."); 77 setTextSize(0.05); 78 this->InvaderGame->bEndGame = true; 79 } 80 else 81 { 82 setTextSize(0.04); 83 setPosition(Vector2(0.14, 0.055)); 84 this->setCaption(Level); 85 } 78 86 } 79 87 else if(this->bShowPoints_) … … 82 90 if (this->InvaderGame->lives <= 0) 83 91 { 84 setTextSize(0.1); 85 setPosition(Vector2(0.2, 0.5)); 92 setTextSize(0.2); 93 setPosition(Vector2(0.1, 0.25)); 94 this->setCaption("Final score:\n" + points); 95 this->setColour(ColourValue(1, 0, 0, 1)); 86 96 } 87 this->setCaption(points); 97 else 98 { 99 setTextSize(0.04); 100 setPosition(Vector2(0.14, 0.1)); 101 this->setColour(ColourValue(1, 1, 1, 1)); 102 this->setCaption(points); 103 } 88 104 } 89 105 else if(this->bShowMultiplier_) 90 106 { 91 const std::string& Multiplier = multi_cast<std::string>(this->InvaderGame->getMultiplier()); 107 int mult = this->InvaderGame->getMultiplier(); 108 const std::string& Multiplier = "X " + multi_cast<std::string>(mult); 92 109 this->setCaption(Multiplier); 110 this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f))); 111 this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01 + 0.04); 93 112 } 94 113 } -
code/branches/invaders/src/modules/invader/InvaderHUDinfo.h
r9854 r9868 39 39 public: 40 40 InvaderHUDinfo(Context* context); 41 virtual ~InvaderHUDinfo();42 41 43 42 virtual void tick(float dt); -
code/branches/invaders/src/modules/invader/InvaderPrereqs.h
r9828 r9868 21 21 * 22 22 * Author: 23 * Reto Grieder23 * Florian Zinggeler 24 24 * Co-authors: 25 25 * ... -
code/branches/invaders/src/modules/invader/InvaderShip.cc
r9829 r9868 42 42 RegisterClass(InvaderShip); 43 43 44 /**45 @brief46 Constructor. Registers and initializes the object.47 */48 44 InvaderShip::InvaderShip(Context* context) : SpaceShip(context) 49 45 { … … 78 74 if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3) 79 75 velocity.x = 0; 80 // this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x));81 76 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 82 77 } 83 78 79 // shoot! 84 80 if (isFireing) 85 81 ControllableEntity::fire(0); … … 91 87 camera->setPosition(Vector3(-pos.z, -posforeward, 0)); 92 88 camera->setOrientation(Vector3::UNIT_Z, Degree(90)); 93 // orxout() << "asbhajskjasjahg" << pos << endl;94 89 } 95 90 … … 97 92 98 93 // bring back on track! 99 // if (pos.z > 42*2.5)100 // pos.z = 42*2.5;101 // else if (pos.z < -42*3)102 // pos.z = -42*3;103 94 if(pos.y != 0) 104 95 pos.y = 0; 105 106 96 107 97 setPosition(pos); … … 122 112 lastTime = 0; 123 113 if (getGame()) 124 {125 114 getGame()->levelUp(); 126 // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype());127 128 }129 //level++130 115 } 131 116 … … 144 129 { 145 130 isFireing = bBoost; 131 // restart if game ended 132 if (getGame()) 133 if (getGame()->bEndGame) 134 getGame()->start(); 146 135 } 147 136 inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 148 137 { 149 138 // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint; 150 151 139 WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject); 140 // ensure that this gets only called once per enemy. 152 141 if (enemy != NULL && lastEnemy != enemy) 153 142 { 154 143 lastEnemy = enemy; 155 orxout() << "Enemy!!!! " << endl; 144 156 145 removeHealth(20); 157 if (get Health() <= 0)146 if (getGame()) 158 147 { 159 orxout() << "DIED!!!! " << endl; 160 if (getGame()) 161 { 162 getGame()->costLife(); 163 // SmartPtr<Invader> game = orxonox_cast<Invader>(getGametype()); 164 165 } 148 getGame()->multiplier = 1; 149 if (getHealth() <= 0) 150 getGame()->costLife(); 166 151 } 167 152 return false; -
code/branches/invaders/src/modules/invader/InvaderShip.h
r9829 r9868 45 45 { 46 46 public: 47 InvaderShip(Context* context); //!< Constructor. Registers and initializes the object. 48 virtual ~InvaderShip() {} 47 InvaderShip(Context* context); 49 48 50 49 virtual void tick(float dt); 51 50 51 // overwrite for 2d movement 52 52 virtual void moveFrontBack(const Vector2& value); 53 53 virtual void moveRightLeft(const Vector2& value); 54 54 55 virtual void boost(bool bBoost); // Starts or stops fireing 55 // Starts or stops fireing 56 virtual void boost(bool bBoost); 56 57 57 58 //no rotation! 58 59 virtual void rotateYaw(const Vector2& value){}; 59 60 virtual void rotatePitch(const Vector2& value){}; 60 virtual void rotateRoll(const Vector2& value){}; 61 //return to main menu if game has ended. 62 virtual void rotateRoll(const Vector2& value){if (getGame()) if (getGame()->bEndGame) getGame()->end();}; 61 63 62 64 virtual void updateLevel(); 63 65 64 // *InvaderShip getShip(){return this;}65 66 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 66 67 private: 67 68 68 WeakPtr<Invader> getGame(); 69 69 WeakPtr<Invader> game; -
code/branches/invaders/src/modules/invader/InvaderWeapon.cc
r9744 r9868 61 61 void InvaderWeapon::shot() 62 62 { 63 // orxout(internal_error) << "shotttttt" << endl;64 65 63 assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); 66 64 … … 74 72 75 73 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 76 projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0)); //this->getMuzzleOrientation() Quaternion::IDENTITY 74 // only shoot in foreward direction 75 projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0)); 77 76 projectile->setPosition(this->getMuzzlePosition()); 78 projectile->setVelocity(Vector3(1, 0, 0) * 2000); //this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_ 77 // only shoot in foreward direction 78 projectile->setVelocity(Vector3(1, 0, 0) * 2000); 79 79 80 80 projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); -
code/branches/invaders/src/modules/invader/InvaderWeapon.h
r9744 r9868 42 42 namespace orxonox 43 43 { 44 45 /**46 @brief47 Shoots laser beams.48 @author49 Hagen Seifert50 @ingroup WeaponsHsW01s51 */52 44 class _InvaderExport InvaderWeapon : public HsW01 53 45 { -
code/branches/invaders/src/orxonox/gametypes/Gametype.cc
r9667 r9868 171 171 entity->setOrientation(oldentity->getWorldOrientation()); 172 172 } 173 174 173 it->first->startControl(entity); 175 174 } -
code/branches/invaders/src/orxonox/worldentities/BigExplosion.cc
r9837 r9868 148 148 this->debrisEntity4_->attach(debris4_); 149 149 150 // particleSpawner is a static entity. It should probably be dynamic, for better explosions. 151 // effect->SetVelocity(this->getVelocity() + Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10,100)) 150 152 ParticleSpawner* effect = new ParticleSpawner(this->getContext()); 151 153 effect->setDestroyAfterLife(true);
Note: See TracChangeset
for help on using the changeset viewer.