本文整理汇总了C#中Terrain.GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C# Terrain.GetHeight方法的具体用法?C# Terrain.GetHeight怎么用?C# Terrain.GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terrain
的用法示例。
在下文中一共展示了Terrain.GetHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VegetationManager
public VegetationManager(Terrain terrain)
{
vegetationList = new List<DrawableGameComponent>();
var doc = new XmlDocument();
doc.Load(Config.VegetationConfigPath);
foreach (XmlElement objectElement in doc.GetElementsByTagName("Object"))
{
float radius = float.Parse(objectElement.GetAttribute("boundingCylinderRadius").Replace('.',','));
float height = float.Parse(objectElement.GetAttribute("boundingCylinderHeight").Replace('.', ','));
foreach (XmlElement transformElement in objectElement.GetElementsByTagName("Transform"))
{
var vegetationObj = new DrawableGameComponent(radius, height);
float x = float.Parse(transformElement.GetAttribute("translateX").Replace('.', ','));
float z = float.Parse(transformElement.GetAttribute("translateZ").Replace('.', ','));
float y = terrain.GetHeight(x, z);
vegetationObj.Position = new Vector3(x, y, z);
vegetationObj.Scale = new Vector3(float.Parse(transformElement.GetAttribute("scale").Replace('.', ',')));
vegetationList.Add(vegetationObj);
}
}
}
示例2: CreateNew
private static void CreateNew(bool flag, Terrain terrain, float x, float y, float bw, float bh, List<Box> boxes, World world, Gameplay gameplay)
{
Vector2 position;
Vector2 size;
Box box;
if (flag)
{
float checkY;
int number;
checkY = terrain.GetHeight(x);
if (checkY != y)
{
checkY = y - checkY;
number = (int)(checkY / 3);
Console.WriteLine(number);
float newY;
newY = checkY;
for (int k = 1; k <= number; k++)
{
newY += bh;
Console.WriteLine(newY);
position = new Vector2(x, newY);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "base-block", true, gameplay.Player1, BASE_STRENGTH);
boxes.Add(box);
Console.WriteLine("Yes!");
}
}
}
}
示例3: CreateBuilding
public static List<Box> CreateBuilding(World world, Gameplay gameplay, EntityCategory playerType)
{
List<Box> boxes = new List<Box>();
Terrain terrain = new Terrain(world);
bool flag = true;
switch (playerType)
{
case (EntityCategory.Player1):
{
float x, y;
y = terrain.GetHeight(-300);
float bw, bh;
bw = 6;
bh = 3;
Vector2 position;
Vector2 size;
Box box;
for (int i = 0; i < 8; i++)
{
x = -300;
for (int j = 0; j < 3; j++)
{
if (j >= 1 && i>=1)
{
flag = false;
}
CreateNew(flag, terrain, x, y, bw, bh, boxes, world, gameplay);
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "base-block", true, gameplay.Player1, BASE_STRENGTH);
boxes.Add(box);
x += bw;
}
y += bh;
}
flag = true;
x = -303;
y = terrain.GetHeight(x) + 24f;
for (int i = 0; i < 4; i++)
{
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "base-block", true, gameplay.Player1, BASE_STRENGTH);
boxes.Add(box);
x += bw;
}
x = -303;
y = terrain.GetHeight(x) + 27f;
for (int i = 0; i < 3; i++)
{
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "base-block", true, gameplay.Player1, BASE_STRENGTH);
boxes.Add(box);
x += bw + bw / 2f;
}
y = terrain.GetHeight(-230);
for (int i = 0; i < 8; i++)
{
x = -230;
for (int j = 0; j < 3; j++)
{
if (j >= 1 && i >= 1)
{
flag = false;
}
CreateNew(flag, terrain, x, y, bw, bh, boxes, world, gameplay);
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "block2", true, gameplay.Player1,200);
boxes.Add(box);
x += bw;
}
y += bh;
}
x = -233;
y = terrain.GetHeight(-233)+24f;
for (int i = 0; i < 4; i++)
{
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "block2", true, gameplay.Player1,200);
boxes.Add(box);
x += bw;
}
x = -233;
y = terrain.GetHeight(-233)+27f;
for (int i = 0; i < 3; i++)
{
position = new Vector2(x, y);
size = new Vector2(bw, bh);
box = new Box(world, position, size, "block2", true, gameplay.Player1,200);
boxes.Add(box);
x += bw + bw / 2f;
}
flag = true;
y = terrain.GetHeight(-236);
for (int i = 0; i < 5; i++)
{
//.........这里部分代码省略.........