本文整理汇总了C#中MapData.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# MapData.GetLength方法的具体用法?C# MapData.GetLength怎么用?C# MapData.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapData
的用法示例。
在下文中一共展示了MapData.GetLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TextureFromHeightMap
public static void TextureFromHeightMap(string displayMode,
MapData[,] map,
ScalarFieldType type,
int width, int height,
Mutex imageMutex,
Color[] worldData,
Texture2D worldMap, float sealevel)
{
if(JetGradient == null)
{
List<ColorStop> stops = new List<ColorStop>();
ColorStop first = new ColorStop
{
m_color = new Color(0, 255, 255),
m_position = 0.0f
};
ColorStop second = new ColorStop
{
m_color = new Color(0, 0, 255),
m_position = 0.2f
};
ColorStop third = new ColorStop
{
m_color = new Color(255, 255, 0),
m_position = 0.4f
};
ColorStop fourth = new ColorStop
{
m_color = new Color(255, 0, 0),
m_position = 0.8f
};
ColorStop fifth = new ColorStop
{
m_color = new Color(255, 255, 255),
m_position = 1.0f
};
stops.Add(first);
stops.Add(second);
stops.Add(third);
stops.Add(fourth);
stops.Add(fifth);
JetGradient = new ColorGradient(stops);
}
int stepX = map.GetLength(0) / width;
int stepY = map.GetLength(1) / height;
string index = "";
for(int tx = 0; tx < width; tx++)
{
for(int ty = 0; ty < height; ty++)
{
int x = tx * stepX;
int y = ty * stepY;
float h1 = map[x, y].GetValue(type);
Biome biome = Map[x, y].Biome;
if(h1 < 0.1f)
{
index = "Sea";
}
else if(h1 >= 0.1f && h1 <= sealevel)
{
index = "Water";
}
else if(displayMode == "Biomes")
{
index = "Biome";
}
else if(displayMode == "Height")
{
if(h1 >= 0.2f && h1 < 0.21f)
{
index = "Shore";
}
else if(h1 >= 0.21f && h1 < 0.4f)
{
index = "Lowlands";
}
else if(h1 >= 0.4f && h1 < 0.6f)
{
index = "Highlands";
}
else if(h1 >= 0.6f && h1 < 0.9f)
{
index = "Mountains";
}
else
{
index = "Peaks";
}
}
if(displayMode == "Gray")
{
//.........这里部分代码省略.........
示例2: MultValue
public static void MultValue(MapData[,] heightMap, Vector2 pos, ScalarFieldType value, float height)
{
int x = Math.Max(Math.Min((int) pos.X, heightMap.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, heightMap.GetLength(1) - 1), 0);
float c = heightMap[x, y].GetValue(value);
heightMap[x, y].SetValue(value, c * height);
}
示例3: SetWater
public static void SetWater(MapData[,] heightMap, Vector2 pos, WaterType waterType)
{
int x = Math.Max(Math.Min((int) pos.X, heightMap.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, heightMap.GetLength(1) - 1), 0);
heightMap[x, y].Water = waterType;
}
示例4: MinBlend
public static void MinBlend(MapData[,] heightMap, Vector2 pos, float height, Overworld.ScalarFieldType type)
{
int x = Math.Max(Math.Min((int) pos.X, heightMap.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, heightMap.GetLength(1) - 1), 0);
float orig = heightMap[x, y].GetValue(type);
heightMap[x, y].SetValue(type, Math.Min(orig, height));
}
示例5: LinearInterpolate
public static float LinearInterpolate(Vector2 position, MapData[,] map, ScalarFieldType fieldType)
{
float x = position.X;
float y = position.Y;
float x1 = (int) MathFunctions.Clamp((float) Math.Ceiling(x), 0, map.GetLength(0) - 2);
float y1 = (int) MathFunctions.Clamp((float) Math.Ceiling(y), 0, map.GetLength(1) - 2);
float x2 = (int) MathFunctions.Clamp((float) Math.Floor(x), 0, map.GetLength(0) - 2);
float y2 = (int) MathFunctions.Clamp((float) Math.Floor(y), 0, map.GetLength(1) - 2);
if(Math.Abs(x1 - x2) < 0.5f)
{
x1 = x1 + 1;
}
if(Math.Abs(y1 - y2) < 0.5f)
{
y1 = y1 + 1;
}
float q11 = map[(int) x1, (int) y1].GetValue(fieldType);
float q12 = map[(int) x1, (int) y2].GetValue(fieldType);
float q21 = map[(int) x2, (int) y1].GetValue(fieldType);
float q22 = map[(int) x2, (int) y2].GetValue(fieldType);
return MathFunctions.LinearCombination(x, y, x1, y1, x2, y2, q11, q12, q21, q22);
}
示例6: GetWater
public static WaterType GetWater(MapData[,] map, Vector2 pos)
{
int x = Math.Max(Math.Min((int) pos.X, map.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, map.GetLength(1) - 1), 0);
return map[x, y].Water;
}
示例7: GetValue
public static float GetValue(MapData[,] map, Vector2 pos, ScalarFieldType value)
{
int x = Math.Max(Math.Min((int) pos.X, map.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, map.GetLength(1) - 1), 0);
return map[x, y].GetValue(value);
}
示例8: AddValue
public static void AddValue(MapData[,] map, Vector2 pos, ScalarFieldType value, float amount)
{
int x = Math.Max(Math.Min((int) pos.X, map.GetLength(0) - 1), 0);
int y = Math.Max(Math.Min((int) pos.Y, map.GetLength(1) - 1), 0);
map[x, y].SetValue(value, map[x, y].GetValue(value) + amount);
}