Gerard-Meier

Wormhole decorator

Apr 22nd, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #ifndef WORMHOLES_H
  2. #define WORMHOLES_H
  3.  
  4. #include "Empty.h"
  5. #include "json/writer.h"
  6.  
  7. using namespace std;
  8.  
  9. class Wormholes : public Empty {
  10.  
  11. public:
  12.     virtual void applyTo(json::Object& starSystem, json::Array& gameObjects) {
  13.        
  14.         // These are the neighbouring starsystems:
  15.         json::Array& neighbours = starSystem["neighbours"];
  16.         json::Array::iterator itNeighbour;
  17.  
  18.         int r = rand() % 10;
  19.  
  20.         // For each neighbour, generate a wormhole:
  21.         for(itNeighbour = neighbours.Begin(); itNeighbour != neighbours.End(); ++itNeighbour) {
  22.             json::Object apply;
  23.            
  24.             apply["targetStarSystem"] = json::Number(*itNeighbour);
  25.  
  26.             gameObjects.Insert(gob("wormhole", 50 * r++, 50 * r, 50 * r, apply));
  27.         }
  28.  
  29.         //cout << "EnemyBase: Cannot decorate with enemybase. We have no enemy base :( " << endl;
  30.     }
  31. };
  32.  
  33.  
  34. #endif // WORMHOLES_H
Advertisement
Add Comment
Please, Sign In to add comment