本文整理汇总了C#中GameObject.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetLength方法的具体用法?C# GameObject.GetLength怎么用?C# GameObject.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.GetLength方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMap
// Sets the map for pathing, must be called before running the pathing.
// map: array of tiles
// easiestRoute: should the easiest route be located (as little climbing as possible)
// heights: list of height values for the cells, in order
public void SetMap(GameObject[,] map, bool easiestRoute, List<int> heights)
{
this.easiestRoute = easiestRoute;
resetNodes = new List<Node>();
nextNodes = new List<Node>();
this.width = map.GetLength(0);
this.height = map.GetLength(1);
this.nodes = new Node[this.width, this.height];
if (easiestRoute) //save heights to nodes for easiest route
{
for (int y = 0; y < this.height; y++)
{
for (int x = 0; x < this.width; x++)
{
nodes[x, y] = new Node(x, y, heights[x + 1 * y + 1]);
}
}
}
else
{
for (int y = 0; y < this.height; y++)
{
for (int x = 0; x < this.width; x++)
{
this.nodes[x, y] = new Node(x, y, true); // TRUE = Walkable for all tiles
}
}
}
}
示例2: getSerArray
public static sCell[,] getSerArray(GameObject[,] cellArray)
{
sCell[,] ser = new sCell[cellArray.GetLength(0), cellArray.GetLength(1)];
for (int x = 0; x < ser.GetLength(0); x++)
{
for (int y = 0; y < ser.GetLength(1); y++)
{
ser[x, y] = new sCell(cellArray[x, y]);
}
}
return ser;
}
示例3: InspectArray
void InspectArray(GameObject[,] gos)
{
int columns = gos.GetLength(0);
Debug.Log("Columns: " + columns);
int rows = gos.GetLength(1);
Debug.Log("Rows: " + rows);
for (int c = 0; c < columns; c++)
{
for (int r = 0; r < rows; r++)
{
Debug.Log(gos [c, r].name);
}
}
}
示例4: PerformCheck
public void PerformCheck(GameObject[,] List)
{
for (int i = 0; i < List.GetLength(0); i++)
{
List<GameObject> toDelete = new List<GameObject>();
for (int j = 0; j < List.GetLength(1); j++)
{
if ((j + 1 < List.GetLength(1) && List[i, j].tag == List[i, j + 1].tag) || (toDelete.Count > 0 && toDelete[toDelete.Count-1].tag == List[i,j].tag))
{
toDelete.Add(List[i, j]);
//Debug.Log("Got match at " + AllTilesY[k, l] + " and " + AllTilesY[k, l + 1]);
}
else if (toDelete.Count >= 3)
{
Debug.Log("Got a chain of " + toDelete.Count);
Found(toDelete);
}
else
toDelete = new List<GameObject>();
}
}
}
示例5: random_building
GameObject random_building(GameObject[] gameoblist)
{
int total=gameoblist.GetLength(0);
int pick=(int)(total*Random.value);
return gameoblist[pick];
}
示例6: replaceOnEllipse
public void replaceOnEllipse(GameObject[,] world, GameObject tile, int tarX, int tarY, int length, int height, GameObject targetTile) {
//Debug.Log ("Generating ellipse at x:"+tarX+", y:"+tarY+" of length:"+length+" and height:"+height);
for (int x = tarX - length; x <= tarX + length; x++) {
for (int y = tarY - height; y <= tarY + height; y++) {
float theta = Mathf.Atan2 ((y - tarY), (x - tarX));
float radius = Mathf.Sqrt (Mathf.Pow (height / 2, 2) * Mathf.Pow (Mathf.Cos (theta), 2) + Mathf.Pow (length / 2, 2) * Mathf.Pow (Mathf.Sin (theta), 2));
float distance = getDistance (tarX, tarY, x, y);
if (distance <= radius) {
if (x >= 0 && x < world.GetLength (0) && y >= 0 && y < world.GetLength (1)) {
GameObject wTile = world[x,y];
if (wTile.CompareTag(targetTile.tag)) {
Destroy(world[x,y]);
world[x,y] = Instantiate(tile);
}
}
}
}
}
}
示例7: genEllipse
public void genEllipse(GameObject[,] world, GameObject tile, int tarX, int tarY, int length, int height) {
//Debug.Log ("Generating ellipse at x:"+tarX+", y:"+tarY+" of length:"+length+" and height:"+height);
for (int x = tarX - length; x <= tarX + length; x++) {
for (int y = tarY - height; y <= tarY + height; y++) {
float theta = Mathf.Atan2 ((y - tarY), (x - tarX));
float radius = Mathf.Sqrt (Mathf.Pow (height / 2, 2) * Mathf.Pow (Mathf.Cos (theta), 2) + Mathf.Pow (length / 2, 2) * Mathf.Pow (Mathf.Sin (theta), 2));
float distance = getDistance (tarX, tarY, x, y);
if (distance <= radius) {
if (x >= 0 && x < world.GetLength (0) && y >= 0 && y < world.GetLength (1)) {
GameObject tarTile = world [x, y];
if (!tarTile.GetComponent<SpriteRenderer> ().sprite.Equals (tile.GetComponent<SpriteRenderer> ().sprite)) {
Destroy (tarTile);
world [x, y] = Instantiate (tile);
} else {
//Debug.Log ("Was equal, not replacing");
}
}
}
}
}
}
示例8: genLip
public GameObject[,] genLip(GameObject[,] world, GameObject tarTile, GameObject replaceTile, GameObject neighborTile) {
GameObject[,] returnWorld = world;
Debug.Log ("Lip Generating");
for (int x = 0; x < world.GetLength (0); x++) {
for (int y = 0; y < world.GetLength (1); y++) {
Debug.Log ("X:" + x + ", Y:" + y);
GameObject tile = world [x, y];
if (tile.CompareTag(tarTile.tag)) {
if (y - 1 >= 0 && neighborTile.CompareTag(world[x,y-1].tag) ) {
Debug.Log ("Replacing... Y-1");
Destroy(world[x,y]);
returnWorld [x, y] = Instantiate (replaceTile);
}
else if (x - 1 >= 0 && neighborTile.CompareTag(world[x-1,y].tag) ) {
Debug.Log ("Replacing... X-1");
Destroy(world[x,y]);
returnWorld [x, y] = Instantiate (replaceTile);
}
else if (x + 1 < world.GetLength(0) && neighborTile.CompareTag(world[x+1,y].tag) ) {
Debug.Log ("Replacing... X+1");
Destroy(world[x,y]);
returnWorld [x, y] = Instantiate (replaceTile);
}
else if (y + 1 < world.GetLength(1) && neighborTile.CompareTag(world[x,y+1].tag) ) {
Debug.Log ("Replacing... Y+1");
Destroy(world[x,y]);
returnWorld [x, y] = Instantiate (replaceTile);
}
}
}
}
return returnWorld;
}
示例9: setParentForCells
//Used when loading a game. Replaces the current cellArray with the new one
public void setParentForCells(GameObject[,] cells)
{
//Destroy any current children
foreach (Transform child in transform)
{
Destroy(child.gameObject);
}
CellHandler.cellArray = cells;
for (int x = 0; x < cells.GetLength(0); x++)
{
for (int y = 0; y < cells.GetLength(1); y++)
{
if (cells[x, y] != null)
cells[x, y].transform.SetParent(this.transform);
}
}
}
示例10: ShuffleInPlace
//----------------------------------------- Para el manejo del nivel -----------------------------------------------
private void ShuffleInPlace(GameObject[] source)
{
//Shuffle dentro de un array
for (int inx = source.GetLength(0)-1; inx > 0; --inx) {
int position = UnityEngine.Random.Range(0, source.GetLength(0)-1);
GameObject temp = source[inx];
source[inx] = source[position];
source[position] = temp;
}
}