- Timestamp:
- Dec 6, 2013, 3:09:30 PM (11 years ago)
- Location:
- code/branches/invaders
- Files:
-
- 6 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/invaders/data/levels/Invaders.oxw
r9868 r9874 1 1 <LevelInfo 2 2 name = "Orxonox Arcade" 3 description = " Arcade shooter. Maximise your points!!!"3 description = "2D Arcade shooter. Maximise your points!!!\nTip: try to keep the multiplier high by avoiding shots and enemies." 4 4 tags = "minigame" 5 5 screenshot = "emptylevel.png" 6 6 /> 7 <!-- include("HUDTemplates3.oxo") -->8 7 <?lua 9 8 include("stats.oxo") … … 16 15 include("templates/spaceshipInvader.oxt") 17 16 include("templates/enemyInvader.oxt") 17 include("templates/enemyInvaderShooter.oxt") 18 18 include("overlays/InvaderHUD.oxo") 19 19 ?> -
code/branches/invaders/src/modules/invader/CMakeLists.txt
r9828 r9874 5 5 InvaderShip.cc 6 6 InvaderEnemy.cc 7 InvaderEnemyShooter.cc 7 8 InvaderWeapon.cc 9 InvaderWeaponEnemy.cc 8 10 InvaderHUDinfo.cc 9 11 END_BUILD_UNIT -
code/branches/invaders/src/modules/invader/Invader.cc
r9868 r9874 48 48 #include "InvaderShip.h" 49 49 #include "InvaderEnemy.h" 50 #include "InvaderEnemyShooter.h" 50 51 51 52 #include "core/command/ConsoleCommand.h" 53 #include "worldentities/BigExplosion.h" 52 54 53 55 namespace orxonox … … 70 72 level = 1; 71 73 point = 0; 74 bShowLevel = false; 72 75 multiplier = 1; 73 76 b_combo = false; 74 // spawn enemy every 2seconds75 enemySpawnTimer.setTimer( 2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));76 comboTimer.setTimer( 2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));77 // spawn enemy every 3.5 seconds 78 enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this))); 79 comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this))); 77 80 } 78 81 79 void Invader::spawnEnemy() 82 void Invader::levelUp() 83 { 84 level++; 85 if (getPlayer() != NULL) 86 { 87 for (int i = 0; i < 7; i++) 88 { 89 WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext()); 90 chunk->setPosition(Vector3(600, 0, 100 * i - 300)); 91 chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() 92 chunk->setScale(20); 93 } 94 } 95 addPoints(multiplier * 42); 96 multiplier *= 2; 97 toggleShowLevel(); 98 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this))); 99 } 100 101 WeakPtr<InvaderShip> Invader::getPlayer() 80 102 { 81 103 if (player == NULL) … … 84 106 player = *it; 85 107 } 86 if (player == NULL) 108 return player; 109 } 110 111 void Invader::spawnEnemy() 112 { 113 if (getPlayer() == NULL) 87 114 return; 88 89 115 srand(player->getPosition().x + player->getPosition().y); 90 for (int i = 0; i < level * 2; i++)116 for (int i = 0; i < (3*log(level) + 1); i++) 91 117 { 92 WeakPtr<InvaderEnemy> newPawn = new InvaderEnemy(this->center_->getContext()); 93 newPawn->addTemplate("enemyinvader"); 118 WeakPtr<InvaderEnemy> newPawn; 119 if (rand() % 42/(1 + level*level) == 0) 120 { 121 newPawn = new InvaderEnemyShooter(this->center_->getContext()); 122 newPawn->addTemplate("enemyinvadershooter"); 123 } 124 else 125 { 126 newPawn = new InvaderEnemy(this->center_->getContext()); 127 newPawn->addTemplate("enemyinvader"); 128 } 94 129 newPawn->setPlayer(player); 95 130 newPawn->level = level; … … 133 168 Deathmatch::start(); 134 169 } 135 170 void Invader::addPoints(int numPoints) 171 { 172 if (!bEndGame) 173 { 174 point += numPoints * multiplier; 175 b_combo = true; 176 } 177 } 136 178 137 179 void Invader::end() -
code/branches/invaders/src/modules/invader/Invader.h
r9868 r9874 66 66 67 67 void costLife(); 68 void levelUp() {level++;}69 void addPoints(int numPoints) {point += numPoints * multiplier; b_combo = true;}68 void levelUp(); 69 void addPoints(int numPoints); 70 70 // checks if multiplier should be reset. 71 71 void comboControll(); … … 74 74 int multiplier; 75 75 bool bEndGame; 76 bool bShowLevel; 76 77 private: 78 void toggleShowLevel(){bShowLevel = !bShowLevel;} 79 WeakPtr<InvaderShip> getPlayer(); 77 80 WeakPtr<InvaderCenterPoint> center_; 78 81 WeakPtr<InvaderShip> player; … … 80 83 Timer enemySpawnTimer; 81 84 Timer comboTimer; 85 Timer showLevelTimer; 82 86 //Context* context; 83 87 int level; -
code/branches/invaders/src/modules/invader/InvaderEnemy.cc
r9868 r9874 34 34 #include "invader/InvaderPrereqs.h" 35 35 #include "InvaderEnemy.h" 36 // #include "worldentities/pawns/SpaceShip.h"36 #include "InvaderShip.h" 37 37 38 38 namespace orxonox … … 64 64 inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 65 65 { 66 if(orxonox_cast< Pawn*>(otherObject))66 if(orxonox_cast<InvaderShip*>(otherObject)) 67 67 removeHealth(2000); 68 68 return false; … … 81 81 void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator) 82 82 { 83 if (getGame()) 83 Pawn::damage(damage, healthdamage, shielddamage, originator); 84 if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0) 84 85 getGame()->addPoints(42); 85 Pawn::damage(damage, healthdamage, shielddamage, originator);86 86 } 87 87 } -
code/branches/invaders/src/modules/invader/InvaderEnemy.h
r9868 r9874 52 52 53 53 int level; 54 pr ivate:54 protected: 55 55 WeakPtr<Invader> getGame(); 56 56 WeakPtr<Invader> game; -
code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
r9868 r9874 78 78 this->InvaderGame->bEndGame = true; 79 79 } 80 else if (this->InvaderGame->bShowLevel) 81 { 82 setTextSize(0.1); 83 setPosition(Vector2(0.3, 0.55)); 84 std::stringstream sstm; 85 sstm << "Level " << Level; 86 this->setCaption(sstm.str()); // + level 87 } 80 88 else 81 89 { -
code/branches/invaders/src/modules/invader/InvaderPrereqs.h
r9868 r9874 72 72 class InvaderShip; 73 73 class InvaderEnemy; 74 class InvaderEnemyShooter; 74 75 class InvaderWeapon; 76 class InvaderWeaponEnemy; 75 77 class InvaderHUDinfo; 76 78 } -
code/branches/invaders/src/modules/invader/InvaderShip.cc
r9868 r9874 138 138 // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint; 139 139 WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject); 140 WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject); 140 141 // ensure that this gets only called once per enemy. 141 142 if (enemy != NULL && lastEnemy != enemy) … … 146 147 if (getGame()) 147 148 { 148 getGame()->multiplier = 1; 149 if (getHealth() <= 0) 150 getGame()->costLife(); 149 getGame()->multiplier = 1; 151 150 } 152 return false; 151 } 152 // was shot, decrease multiplier 153 else if (shot != NULL && lastShot != shot) 154 { 155 if (getGame() && orxonox_cast<InvaderEnemy*>(shot->getShooter()) != NULL) 156 { 157 if (getGame()->multiplier > 1) 158 { 159 lastShot = shot; 160 getGame()->multiplier -= 1; 161 } 162 } 153 163 } 154 164 return false; … … 165 175 return game; 166 176 } 177 178 void InvaderShip::death() 179 { 180 getGame()->costLife(); 181 SpaceShip::death(); 182 } 167 183 } -
code/branches/invaders/src/modules/invader/InvaderShip.h
r9868 r9874 39 39 #include "worldentities/pawns/SpaceShip.h" 40 40 #include "graphics/Camera.h" 41 #include "weapons/projectiles/Projectile.h" 41 42 42 43 namespace orxonox … … 65 66 66 67 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 68 69 protected: 70 virtual void death(); 67 71 private: 68 72 WeakPtr<Invader> getGame(); … … 79 83 80 84 WeakPtr<InvaderEnemy> lastEnemy; 85 WeakPtr<Projectile> lastShot; 81 86 82 87 }; -
code/branches/invaders/src/modules/invader/InvaderWeapon.cc
r9868 r9874 63 63 assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); 64 64 65 // Create the projectile. 66 Projectile*projectile = new Projectile(this->getContext());67 Model*model = new Model(projectile->getContext());65 // Create the projectile.projectile 66 projectile = new Projectile(this->getContext()); 67 WeakPtr<Model> model = new Model(projectile->getContext()); 68 68 model->setMeshSource(mesh_); 69 69 model->setCastShadows(false); -
code/branches/invaders/src/modules/invader/InvaderWeapon.h
r9868 r9874 49 49 protected: 50 50 virtual void shot(); 51 WeakPtr<Projectile> projectile; 51 52 }; 52 53 }
Note: See TracChangeset
for help on using the changeset viewer.