当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.GetUpperBound方法代码示例

本文整理汇总了C#中GameObject.GetUpperBound方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetUpperBound方法的具体用法?C# GameObject.GetUpperBound怎么用?C# GameObject.GetUpperBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameObject的用法示例。


在下文中一共展示了GameObject.GetUpperBound方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindMatch

	private ArrayList FindMatch (GameObject[,] cells)
	{
		ArrayList stack = new ArrayList ();
		for (var x = 0; x <= cells.GetUpperBound (0); x++) {
			for (var y = 0; y <= cells.GetUpperBound (1); y++) {
				var thiscell = cells [x, y];
				if (thiscell.name == "empty(Clone)")
					continue;
				int matchCount = 0;
				int y2 = cells.GetUpperBound (1);
				int y1;
				for (y1 = y + 1; y1 <= y2; y1++) {
					if (cells [x, y1].name == "empty(Clone)" ||
					    (thiscell.name != cells [x, y1].name))
						break;
					matchCount++;
				}
				if (matchCount >= 2) {
					y1 = Mathf.Min (cells.GetUpperBound (1), y1 - 1);
					for (var y3 = y; y3 <= y1; y3++) {
						if (!stack.Contains (cells [x, y3])) {
							stack.Add (cells [x, y3]);
						}
					}
				}
			}
		}

		for (var y = 0; y <= cells.GetUpperBound (1); y++) {
			for (var x = 0; x <= cells.GetUpperBound (0); x++) {
				var thiscell = cells [x, y];
				if (thiscell.name == "empty(Clone)")
					continue;


				int matchCount = 0;
				int x2 = cells.GetUpperBound (0);
				int x1;
				for (x1 = x + 1; x1 <= x2; x1++) {
					if (cells [x1, y].name == "empty(Clone)" ||
					    (thiscell.name != cells [x1, y].name))
						break;
					matchCount++;
				}
				if (matchCount >= 2) {
					x1 = Mathf.Min (cells.GetUpperBound (0), x1 - 1);
					for (var x3 = x; x3 <= x1; x3++) {
						if (!stack.Contains (cells [x3, y])) {
							stack.Add (cells [x3, y]);
						}
					}
				}
			}
		}
		return stack;
	}
开发者ID:Unity-mylearn,项目名称:DelObject,代码行数:56,代码来源:mainGame.cs

示例2: Move

    // Write a general move command that uses only the directions
    public void Move(GameObject[,] brickArray, MoveDirection moveDir)
    {
        // Settings to figure out which way it is going

        int brickArrayWidth = brickArray.GetUpperBound(0) + 1;
        int brickArrayHeight = brickArray.GetUpperBound(1) + 1;
        int newX;
        int newY;
        int xModifier = 0;
        int yModifier = 0;
        int startX = 0;
        int startY = 0;
        bool movingUpAndDown = false;

        newX = startX;
        newY = startY;

        if(moveDir == MoveDirection.Up)
        {
            // This should all be done by column

            newY = brickArrayHeight - 1;
            newX = 0;
            // Set up here which sides will be affected
            for(int x = 0; x < brickArrayWidth; x++)
            {
                for(int y = brickArrayHeight - 1; y >= 0; y--)
                {
                    if(brickArray[x,y] == null || brickArray[x, y] == gameModel.CurrentActiveBrick)
                    {

                    }
                    else if(brickArray[x,y] != null)
                    {
                        BrickComponent brickComponet = brickArray[x, y].GetComponent<BrickComponent>();
                        if(brickComponet.Side == Sides.Top || brickComponet.Side == Sides.Bottom)
                        {
                        }
                        else if(brickComponet.Side == Sides.Left || brickComponet.Side == Sides.Right)
                        {
                            gameModel.MoveBrick(brickArray[x,y], moveDir, false);
                        }

                        newY -= 1;
                    }
                }
                newY = brickArrayHeight - 1;
                newX += 1;
            }
        }
        else if(moveDir == MoveDirection.Down)
        {
            newY = 0;
            newX = 0;
            // Set up here which sides will be affected
            for(int x = 0; x < brickArrayWidth; x++)
            {
                for(int y = 0; y < brickArrayHeight; y++)
                {
                    if(brickArray[x,y] == null || brickArray[x, y] == gameModel.CurrentActiveBrick)
                    {

                    }
                    else if(brickArray[x,y] != null)
                    {
                        BrickComponent brickComponet = brickArray[x, y].GetComponent<BrickComponent>();
                        if(brickComponet.Side == Sides.Top || brickComponet.Side == Sides.Bottom)
                        {

                        }
                        else if(brickComponet.Side == Sides.Left || brickComponet.Side == Sides.Right)
                        {
                            gameModel.MoveBrick(brickArray[x,y], moveDir, false);
                        }

                        newY += 1;
                    }
                }
                newY = 0;
                newX += 1;
            }
        }
        else if(moveDir == MoveDirection.Left)
        {
            newX = 0;
            newY = brickArrayHeight - 1;
            // Set up here which sides will be affected
            for(int y = brickArrayHeight - 1; y >= 0; y--)
            {
                for(int x = 0; x < brickArrayWidth; x++)
                {
                    if(brickArray[x,y] == null || brickArray[x, y] == gameModel.CurrentActiveBrick)
                    {

                    }
                    else if(brickArray[x,y] != null)
                    {
                        BrickComponent brickComponet = brickArray[x, y].GetComponent<BrickComponent>();
                        if(brickComponet.Side == Sides.Left || brickComponet.Side == Sides.Right)
//.........这里部分代码省略.........
开发者ID:KellanHiggins,项目名称:BlockGame,代码行数:101,代码来源:MoveSidesProcessor.cs

示例3: MoveUp

    public void MoveUp(GameObject[,] brickArray)
    {
        // This takes the entire BrickArray and goes column by column moving every block that is in the side up to the top of its column.

        // First

        int brickArrayWidth = brickArray.GetUpperBound(0) + 1;
        int brickArrayHeight = brickArray.GetUpperBound(1) + 1;

        int newX = 0;
        int newY = brickArrayHeight - 1;

        for(int x = 0; x < brickArrayWidth; x++)
        {

            for(int y = brickArrayHeight - 1; y >= 0; y--)
            {
                if(brickArray[x,y] == null)
                {

                }
                // Need to add in a check to see which side the brick is on
                else if(brickArray[x,y] != null)
                {
                    Debug.Log(brickArray[x,y].ToString());
                    brickArray[x,y].GetComponent<BrickComponent>().Location = new Vector2((float)newX, (float)newY);
                    newY--;
                }

            }
            newY = brickArrayHeight - 1;
            newX++;
        }
        moveProcessor.UpdateBrickArray();
    }
开发者ID:KellanHiggins,项目名称:BlockGame,代码行数:35,代码来源:MoveSidesProcessor.cs

示例4: Update_Field_Size

    //This will generate out the field based off of the size, and add/remove any spots. if the spot has something and it is removed then that is removed with it.
    public void Update_Field_Size(int new_x, int new_y)
    {
        i_field_width = new_x;
        i_field_height = new_y;
        //This is the highest path spot that is placed on the new field, 0 means the path maker is not on the field at all and can ignore.
        int i_Highest_Path_Spot = 0;
        int[] i_All_Spots = new int[2000];
        GameObject Path_Maker_Temp = null;

        //we make a new field that will eventually replace the old field.
        GameObject[,] New_All_Field_Spots = new GameObject[i_field_width, i_field_height];

        //Debug.Log("Newx: " + i_field_width);
        //Debug.Log("Newy: " + i_field_height);

        //Debug.Log("Oldx: " + All_Field_Spots.GetUpperBound(0));
        //Debug.Log("Oldy: " + All_Field_Spots.GetUpperBound(1));

        //go through each of the field spots and give it the game object and then update it.
        for (int i = 0; i <= New_All_Field_Spots.GetUpperBound(0); i++)
        {
            for (int j = 0; j <= New_All_Field_Spots.GetUpperBound(1); j++)
            {
                //Create/initilze a spot for this spot.
                GameObject New_Game_Field_Spot = Instantiate(Empty_Field_Spot);
                New_Game_Field_Spot.transform.parent = The_Field_Test.transform;
                //now we add the spot to the spot on the all field spots.
                New_All_Field_Spots[i, j] = New_Game_Field_Spot;

                //now we tell that spot to move it's gameobject to the correct location on said grid.
                //we use 1.28 because the sprite is 256 pixles, but devided by half so 128. so 1.28 is how far apart they are.
                Vector2 New_Vect = new Vector2(i * 1.28f, j * -1.28f);
                New_Game_Field_Spot.transform.localPosition = New_Vect;

            }
        }

        //see if the x or y is lower to know if we need to check for path moves.
        if (New_All_Field_Spots.GetUpperBound(0) < All_Field_Spots.GetUpperBound(0) || New_All_Field_Spots.GetUpperBound(1) < All_Field_Spots.GetUpperBound(1))
        {
            //this will be what we will check through x/y wise.
            int Check_x = All_Field_Spots.GetUpperBound(0);
            int Check_y = All_Field_Spots.GetUpperBound(1);

            //we get the lower of the two values.
            if (New_All_Field_Spots.GetUpperBound(0) < All_Field_Spots.GetUpperBound(0))
            {
                Check_x = New_All_Field_Spots.GetUpperBound(0);
            }
            if (New_All_Field_Spots.GetUpperBound(1) < All_Field_Spots.GetUpperBound(1))
            {
                Check_y = New_All_Field_Spots.GetUpperBound(1);
            }



            //going to go through all the places with the check x/y and see if there is a path, then if so we will move the maker to the highest spot.
            //Then we need to make sure everything is moved and if it can't be moved it's removed.
            //Only the path maker and start will not be removed, they are at worse moved to the invintory.

            //get the path maker if it exsists
            for (int i = 0; i <= All_Field_Spots.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= All_Field_Spots.GetUpperBound(1); j++)
                {
                    //go through each of the children for that spot and move them to the new spot.
                    for (int q = 0; q < All_Field_Spots[i, j].gameObject.transform.childCount; q++)
                    {
                        if (All_Field_Spots[i, j].gameObject.transform.GetChild(q).name == G_Tags.Name_Path_Maker)
                        {
                            //this is the path maker.
                            Path_Maker_Temp = (All_Field_Spots[i, j].gameObject.transform.GetChild(q).gameObject);
                        }
                        if (All_Field_Spots[i, j].gameObject.transform.GetChild(q).name == G_Tags.Name_Start_Point)
                        {
                            //make sure it's within the x/y.
                            if (i > Check_x || j > Check_y)
                            {
                                //it's outside the new field so we move it back to invintory.
                                Move_To_Invintory(All_Field_Spots[i, j].gameObject.transform.GetChild(q).gameObject);
                            }

                        }
                    }
                }
            }

                    //go through and move everything but path while counting how high path goes.
                    //go through each of the field spots and give it the game object and then update it.
                    for (int i = 0; i <= Check_x; i++)
            {
                for (int j = 0; j <= Check_y; j++)
                {
                    //Debug.Log("Running_Check");

                    //go through each of the children for that spot and move them to the new spot.
                    for (int q = 0; q < All_Field_Spots[i, j].gameObject.transform.childCount; q++)
                    {
                        //Debug.Log("Child_FOund");
//.........这里部分代码省略.........
开发者ID:lostsq,项目名称:First_Git_Unity_TDD,代码行数:101,代码来源:LE_Stats_Controller.cs

示例5: DoEmptyDown

	private void DoEmptyDown (ref GameObject[,] cells)
	{
		for (int x = 0; x <= cells.GetUpperBound (0); x++) {
			for (int y = 0; y <= cells.GetUpperBound (1); y++) {
			
				var thisCell = cells [x, y];
				if (thisCell.name == "empty(Clone)") {
					for (int y2 = y; y2 <= cells.GetUpperBound (1); y2++) {
						if (cells [x, y2].name != "empty(Clone)") {
							cells [x, y] = cells [x, y2];
							cells [x, y2] = thisCell;
							break;
						}
					}
				}
			}
		}

		for (int x = 0; x <= cells.GetUpperBound (0); x++) {
			for (int y = 0; y <= cells.GetUpperBound (1); y++) {
				if (cells [x, y].name == "empty(Clone)") { 
					Destroy (cells [x, y]);
					cells [x, y] = GameObject.Instantiate (_listOfShapes [Random.Range (0, _listOfShapes.Length)] 
						as GameObject, new Vector3 (x, y, 0), transform.rotation) as GameObject;
				}
			}
		}

		for (int x = 0; x <= cells.GetUpperBound (0); x++) {
			for (int y = 0; y <= cells.GetUpperBound (1); y++) {
				cells [x, y].transform.position = new Vector3 (x, y, 0);
			}
		}
	}
开发者ID:Unity-mylearn,项目名称:DelObject,代码行数:34,代码来源:mainGame.cs


注:本文中的GameObject.GetUpperBound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。