示例#1
0
Element::Element(PackElement *pe, SDK *sdk, gdouble x, gdouble y):
		on_property_change(this, CBT_ELEMENT_PROP_CHANGE)
{
	TRACE_PROC
	this->x = x;
	this->y = y;
	parent = sdk;
	minWidth = 32;
	minHeight = 32;
	width = minWidth;
	height = minHeight;
	tpl = pe;
	this->sdk = NULL;
	flag = 0;
	cIndex = 0;
	elinkList = NULL;
	userData = NULL;

	buildFromTemplate();

	sysProps.push_back(new ElementProperty(this, "Hint", "Element description", data_list));
	ElementProperty *c = new ElementProperty(this, "Color", "Element color", data_color);
	sysProps.push_back(c);
	color = (Gdk::RGBA*)c->value;
	*color = sysColors.btnFace;
	colorLight = sysColors.btnLight;
	colorDark = sysColors.btnDark;
	c->setAsDefault();
}
示例#2
0
bool MapGenEgyptTomb::run_() {
  eng.map->resetMap();

  buildFromTemplate(Pos(0, 0), mapTemplate_pharaohsChamber);

  eng.player->pos = Pos(40, 11);

  for(int y = 0; y < MAP_H; y++) {
    for(int x = 0; x < MAP_W; x++) {
      Feature* const f = eng.map->cells[x][y].featureStatic;
      if(f->getId() == feature_stoneWall) {
        dynamic_cast<Wall*>(f)->wallType = wall_egypt;
      }
    }
  }

  if(Rnd::coinToss()) {
    eng.featureFactory->spawnFeatureAt(feature_stairs, Pos(4, 2), NULL);
  } else {
    eng.featureFactory->spawnFeatureAt(feature_stairs, Pos(4, 19), NULL);
  }


  dynamic_cast<Monster*>(
    eng.actorFactory->spawnActor(
      actor_mummy, Pos(12, 10)))->isRoamingAllowed_ = false;
  dynamic_cast<Monster*>(
    eng.actorFactory->spawnActor(
      actor_khephren, Pos(11, 11)))->isRoamingAllowed_ = false;
  dynamic_cast<Monster*>(
    eng.actorFactory->spawnActor(
      actor_mummy, Pos(12, 12)))->isRoamingAllowed_ = false;

  dynamic_cast<Monster*>(
    eng.actorFactory->spawnActor(
      actor_cultist, Pos(17, 10)))->isRoamingAllowed_ = false;
  dynamic_cast<Monster*>(
    eng.actorFactory->spawnActor(
      actor_cultist, Pos(17, 12)))->isRoamingAllowed_ = false;

  return true;
}
示例#3
0
void MapBuild::buildFromTemplate(const coord pos, MapTemplateId_t templateId) {
  MapTemplate* t = eng->mapTemplateHandler->getTemplate(templateId);
  buildFromTemplate(pos, t);
}
示例#4
0
void MapBuild::buildForestTrees(const coord& stairsCoord) {
  unsigned minPathLength = 1;
  unsigned maxPathLength = 999;

  int forestPatches = 40 + eng->dice(1, 15);

  vector<coord> path;

  backupMap();

  const coord churchPos = stairsCoord - coord(26, 7);

  bool proceed = false;
  while(proceed == false) {
    for(int i = 0; i < forestPatches; i++) {
      buildForestTreePatch();
    }

    buildFromTemplate(churchPos, mapTemplate_church);

    bool blockers[MAP_X_CELLS][MAP_Y_CELLS];
    eng->mapTests->makeMoveBlockerArrayForMoveTypeFeaturesOnly(moveType_walk, blockers);

    path = eng->pathfinder->findPath(eng->player->pos, blockers, stairsCoord);

    eng->featureFactory->spawnFeatureAt(feature_stairsDown, stairsCoord);

    if(path.size() >= minPathLength && path.size() <= maxPathLength) {
      proceed = true;
    } else {
      restoreMap();
    }

    maxPathLength++;
  }

  const coord cultistCoordRelStairs = coord(-1, 1);
  const coord cultistCoord(stairsCoord + cultistCoordRelStairs);

  Monster* const monster = dynamic_cast<Monster*>(eng->actorFactory->spawnActor(actor_cultist, cultistCoord));
  monster->isRoamingAllowed = false;

  //Build path
  for(unsigned int i = 0; i < path.size(); i++) {
    for(int dx = -1; dx < 1; dx++) {
      for(int dy = -1; dy < 1; dy++) {
        const coord c(path.at(i) + coord(dx, dy));
        if(eng->map->featuresStatic[c.x][c.y]->canHaveStaticFeature() && eng->mapTests->isCellInsideMainScreen(c)) {
          eng->featureFactory->spawnFeatureAt(feature_forestPath, c);
        }
      }
    }
  }

  //Place graves
  vector<HighScoreEntry> highscoreEntries = eng->highScore->getEntriesSorted();
  const unsigned PLACE_TOP_N_HIGHSCORES = 7;
  const int NR_HIGHSCORES = min(PLACE_TOP_N_HIGHSCORES, (unsigned int)highscoreEntries.size());
  if(NR_HIGHSCORES > 0) {
    bool blockers[MAP_X_CELLS][MAP_Y_CELLS];
    eng->mapTests->makeMoveBlockerArrayForMoveTypeFeaturesOnly(moveType_walk, blockers);

    bool vision[MAP_X_CELLS][MAP_Y_CELLS];

    const int SEARCH_RADI = FOV_STANDARD_RADI_INT - 2;
    const int TRY_PLACE_EVERY_N_STEP = 2;

    vector<coord> gravePositions;

    int pathWalkCount = 0;
    for(unsigned int i = 0; i < path.size(); i++) {
      if(pathWalkCount == TRY_PLACE_EVERY_N_STEP) {

        eng->fov->runFovOnArray(blockers, path.at(i), vision, false);

        for(int dy = -SEARCH_RADI; dy <= SEARCH_RADI; dy++) {
          for(int dx = -SEARCH_RADI; dx <= SEARCH_RADI; dx++) {

            const int X = path.at(i).x + dx;
            const int Y = path.at(i).y + dy;

            const bool IS_LEFT_OF_CHURCH = X < churchPos.x - (SEARCH_RADI) + 2;
            const bool IS_ON_STONE_PATH = eng->map->featuresStatic[X][Y]->getId() == feature_forestPath;

            bool isLeftOfPrev = true;
            if(gravePositions.empty() == false) {
              isLeftOfPrev = X < gravePositions.back().x;
            }

            bool isPosOk = vision[X][Y] && IS_LEFT_OF_CHURCH && IS_ON_STONE_PATH == false && isLeftOfPrev;

            if(isPosOk) {
              for(int dy_small = -1; dy_small <= 1; dy_small++) {
                for(int dx_small = -1; dx_small <= 1; dx_small++) {
                  if(blockers[X + dx_small][Y + dy_small]) {
                    isPosOk = false;
                  }
                }
              }
              if(isPosOk) {
                gravePositions.push_back(coord(X, Y));
                blockers[X][Y] = true;
                if(gravePositions.size() == static_cast<unsigned int>(NR_HIGHSCORES)) {
                  i = 9999;
                }
                dy = 99999;
                dx = 99999;
              }
            }
          }
        }
        pathWalkCount = 0;
      }
      pathWalkCount++;
    }
    for(unsigned int i = 0; i < gravePositions.size(); i++) {
      Feature* f = eng->featureFactory->spawnFeatureAt(feature_gravestone, gravePositions.at(i));
      Grave* const grave = dynamic_cast<Grave*>(f);
      HighScoreEntry curHighscore = highscoreEntries.at(i);
      const string name = curHighscore.getName();
      const string date = eng->textFormatting->getSpaceSeparatedList(curHighscore.getDateAndTime()).at(0);
      const string score = intToString(curHighscore.getScore());
      grave->setInscription("RIP " + name + " " + date + " Score: " + score);
    }
  }
}