//随机填充地图 private void RandomFillMap() { for (int x = 0; x < m_numCols; x++) { for (int y = 0; y < m_numRows; y++) { bool b = CDarkRandom.SmallerThan(Threshold); m_values[x, y] = b ? 1 : 0; } } if (m_needAliveEdage) { //如果是整地图, 则我们需要在四周筑上围墙 //随机填充满所有的地图 int maxIndex_Y = m_numRows - 1; int maxIndex_X = m_numCols - 1; for (int x = 0; x < m_numCols; x++) { m_values[x, 0] = 1; m_values[x, maxIndex_Y] = 1; } for (int y = 0; y < m_numRows; y++) { m_values[0, y] = 1; m_values[maxIndex_X, y] = 1; } } }
/// <summary> /// walk = true mean alive /// </summary> private int GetTypeByAlive(bool alive) { if (alive) { return(0); } if (CDarkRandom.SmallerThan(0.5f)) { return(1); } return(2); }
/// <summary> /// 根据高度, 从配置中读取相关的asset /// </summary> private CForestTerrainSubType GetSubTypeAtHeight(float height) { //两种草 if (height <= GrassHeight) { if (CDarkRandom.SmallerThan(0.5f)) { return(CForestTerrainSubType.Grass1); } return(CForestTerrainSubType.Grass1); } //另外一种草 if (height <= GrassHeight2) { return(CForestTerrainSubType.Grass2); } //两种地面 if (height <= LandHeight) { return(CForestTerrainSubType.Land1); } if (height <= LandHeight2) { return(CForestTerrainSubType.Land2); } //墙壁 if (height <= WallHeight) { return(CForestTerrainSubType.Hill); } //默认的绿草地 return(CForestTerrainSubType.Grass1); }
/// <summary> /// 根据高度, 从配置中读取相关的asset /// </summary> private int GetTypeAtHeight(float height) { //两种海洋 if (height < SeaLevel) { if (CDarkRandom.SmallerThan(0.5f)) { return(0); } return(1); } //两种海岸线 if (height <= BeachHeight) { if (CDarkRandom.SmallerThan(0.5f)) { return(2); } return(3); } //两种草 if (height <= GrassHeight) { if (CDarkRandom.SmallerThan(0.5f)) { return(4); } return(5); } //另外一种草 if (height <= GrassHeight2) { return(6); } //两种地面 if (height <= LandHeight) { return(7); } if (height <= LandHeight2) { return(8); } //两种石头 if (height <= StoneHeight) { if (CDarkRandom.SmallerThan(0.5f)) { return(9); } return(10); } //默认的绿草地 return(4); }