Changeset 9854 for code/branches/invaders/src/modules/invader
- Timestamp:
- Dec 2, 2013, 3:53:08 PM (11 years ago)
- Location:
- code/branches/invaders/src/modules/invader
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/invaders/src/modules/invader/Invader.cc
r9837 r9854 87 87 return; 88 88 89 for (int i = 0; i < level; i++) 89 srand(player->getPosition().x + player->getPosition().y); 90 for (int i = 0; i < level * 2; i++) 90 91 { 91 SmartPtr<InvaderEnemy> newPawn = new InvaderEnemy(this->center_->getContext());92 WeakPtr<InvaderEnemy> newPawn = new InvaderEnemy(this->center_->getContext()); 92 93 newPawn->addTemplate("enemyinvader"); 93 newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, 0)); 94 newPawn->setPlayer(player); 95 newPawn->level = level; 96 newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 94 97 } 95 98 } -
code/branches/invaders/src/modules/invader/Invader.h
r9837 r9854 66 66 int getLevel(){return this->level;} 67 67 int getPoints(){return this->point;} 68 int getMultiplier(){return this->multiplier;} 68 69 69 70 void costLife(){lives--; if (lives <= 0) end();}; -
code/branches/invaders/src/modules/invader/InvaderEnemy.cc
r9837 r9854 44 44 RegisterObject(InvaderEnemy); 45 45 enableCollisionCallback(); 46 lifetime = 0; 46 47 } 47 48 48 49 void InvaderEnemy::tick(float dt) 49 50 { 50 setVelocity(Vector3(500 ,0, 0)); 51 lifetime += dt; 52 if (lifetime > 5000) 53 { 54 removeHealth(2000); 55 } 56 if (player != NULL) 57 { 58 float newZ = player->getPosition().z - getPosition().z; 59 if (newZ < 0) 60 newZ = (-100 < newZ)?-100:newZ; 61 else 62 newZ = (100 > newZ)?100:newZ; 63 setVelocity(Vector3(1000 - level * 100 , 0, newZ)); 64 } 51 65 SUPER(InvaderEnemy, tick, dt); 52 66 } … … 54 68 inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 55 69 { 56 setVelocity(Vector3( 900,0,0));70 setVelocity(Vector3(1000,0,0)); 57 71 removeHealth(2000); 58 72 return false; -
code/branches/invaders/src/modules/invader/InvaderEnemy.h
r9829 r9854 50 50 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 51 51 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator); 52 virtual void setPlayer(WeakPtr<InvaderShip> player){this->player = player;} 52 53 54 int level; 53 55 private: 54 56 WeakPtr<Invader> getGame(); 55 57 WeakPtr<Invader> game; 58 WeakPtr<InvaderShip> player; 56 59 Camera* camera; 57 60 bool isFireing; 58 61 float speed, damping; 59 62 float lastTimeFront, lastTimeLeft; 63 float lifetime; 60 64 struct Velocity 61 65 { -
code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
r9828 r9854 44 44 this->bShowLevel_ = false; 45 45 this->bShowPoints_ = false; 46 this->bShowMultiplier_ = false; 46 47 } 47 48 … … 57 58 XMLPortParam(InvaderHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 58 59 XMLPortParam(InvaderHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false); 60 XMLPortParam(InvaderHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false); 59 61 } 60 62 … … 80 82 this->setCaption(points); 81 83 } 84 else if(this->bShowMultiplier_) 85 { 86 const std::string& Multiplier = multi_cast<std::string>(this->InvaderGame->getMultiplier()); 87 this->setCaption(Multiplier); 88 } 82 89 } 83 90 } -
code/branches/invaders/src/modules/invader/InvaderHUDinfo.h
r9828 r9854 60 60 { return this->bShowPoints_; } 61 61 62 inline void setShowMultiplier(bool value) 63 { this->bShowMultiplier_ = value; } 64 inline bool getShowMultiplier() const 65 { return this->bShowMultiplier_; } 66 67 62 68 private: 63 69 Invader* InvaderGame; … … 65 71 bool bShowLevel_; 66 72 bool bShowPoints_; 73 bool bShowMultiplier_; 67 74 }; 68 75 }
Note: See TracChangeset
for help on using the changeset viewer.