void USBMapGenerator::GenerateMap(USBHexMap* map)
{
	//map->Init(w, h);

	this->_w = map->Width;
	this->_h = map->Height;

	
	for (int x = 0; x < _w; x++)
		for (int y = 0; y < _h; y++)
			_grid.Add(FMapGenPoint(x, y), ESBTerrainType::Grass);


	AddTerrain(ESBTerrainType::Desert, 10, 200, 0.02f);
	AddTerrain(ESBTerrainType::Forest, 10, 200, 0.02f);


	// Copy map gen grid to USBHexMap output
	for (int x = 0; x < _w; x++)
		for (int y = 0; y < _h; y++)
		{
			auto gridpoint = USBGameStatics::FromOffsetCoords(x, y);
			(*map)[gridpoint].SetTerrainType(_grid[FMapGenPoint(x, y)]);
		}
}
Exemple #2
0
int RobotWorld::LoadTerrain(const string& fn)
{
  Environment* t = new Environment;
  if(!t->Load(fn.c_str())) {
    delete t;
    return -1;
  }
  const char* justfn = GetFileName(fn.c_str());
  char* buf = new char[strlen(justfn)+1];
  strcpy(buf,justfn);
  StripExtension(buf);
  string name=buf;
  delete [] buf;
  int i = AddTerrain(name,t);
  return i;
}