Пример #1
0
void MainView::handle_keypress(KeySym ks) {
  if (nav.handle_keypress(ks)) return;

  switch (ks) {
  case KEY_r:
    if (influence >= 0) {
      //influence -= 15;
      city->ent(1, 1).insert(new_citizen({ 1, 1, city }, Security::RED));
    } else {
      announce("You must have 15 influence to recruit new troubleshooters.");
    }
    break;
  case KEY_e:
    if (influence >= 5) {
      influence -= 5;
      city->ent(1, 1).insert(new_citizen({ 1, 1, city }, Security::INFRARED));
    } else {
      announce("You must have 5 influence to recruit new infrareds.");
    }
    break;
  default:
    cerr << ks << endl;
    break;
  }
}
Пример #2
0
    // adds a random number of entities of a specified type
    void add_entities(Security::Mask entity, int min, int max)
    {
        int count = randNext(min, max);
        for (int i = 0; i<count;)
        {
            int r = randNext(0, city.getYSize());
            int c = randNext(0, city.getXSize());

            if (city.tile(c, r).type == Tile::TileKind::ground)
            {
                new_citizen({ &city, c, r }, entity);
                i++;
            }
        }
    }