本文整理汇总了C#中Layout.CheckIfNextToEdge方法的典型用法代码示例。如果您正苦于以下问题:C# Layout.CheckIfNextToEdge方法的具体用法?C# Layout.CheckIfNextToEdge怎么用?C# Layout.CheckIfNextToEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout.CheckIfNextToEdge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateForestMeshFromMap
public static void CreateForestMeshFromMap(Layout layout, Grid grid, int seedX, int seedY, int seedZ)
{
Texture2D tex = CreateForestTextureFromMap (layout.layout, grid, seedX, seedY, seedZ);
Rect rec = new Rect (0, 0, grid.width*16, grid.height*16);
//Hardcoded Paths
GameObject blankObj = Resources.Load ("Prefabs/BlankSprite") as GameObject;
GameObject blockObj = Resources.Load ("Prefabs/BlankInter") as GameObject;
Vector3 vec = new Vector3 ( ((float)(grid.width))/2, ((float)(grid.height))/2, 1);
GameObject obj = (GameObject) Instantiate (blankObj, vec, Quaternion.identity);
Sprite sprite = Sprite.Create(tex, rec, new Vector2(0.5f, 0.5f), 16);
PseudoRandom prnd = new PseudoRandom (seedX, seedY, seedZ);
obj.GetComponent<SpriteRenderer> ().sprite = sprite;
SceneObjects.AddObjectToScene (obj);
for (int y = 0; y < grid.height; y++) {
for (int x = 0; x < grid.width; x++) {
// Create Invisible wall rigidbodys
if (layout.CheckIfOnEdge(x,y)){
//GameObject objr = (GameObject)Instantiate (blockObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
//SceneObjects.AddObjectToScene (objr);
}
else if (layout.CheckIfNextToEdge(x,y))// Create wall leaves.
{
int num = prnd.Next (1, 3);
string nsewData = NSEWMap.GetNSEWString(layout.layout, x, y, 0);
if (nsewData.Length > 3) {
num = 1;
}
string spriteName = "Forest_Leaf" + nsewData + "_" + num.ToString ();
if (CheckSpriteExists (spriteName)) {
GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
objr.GetComponent<SpriteRenderer> ().sortingOrder = 100;
SceneObjects.AddObjectToScene (objr);
}
}
if (layout.IsOpen (x, y))
{
double chance = prnd.Next ();
if (chance < 0.01) {
int num = prnd.Next (1, 4);
string spriteName = "Forest_Mush_" + num.ToString();
GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
SceneObjects.AddObjectToScene (objr);
}
else if(chance >= 0.01 && chance < 0.02)
{
int num = prnd.Next (1, 5);
string spriteName = "Forest_Rock_" + num.ToString();
GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
SceneObjects.AddObjectToScene (objr);
}
}
}
}
}