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


C# Grid.containsObject方法代码示例

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


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

示例1: GenerateWideGround

    public Transform GenerateWideGround(int x, int y, int wide, Grid grid, TerrainChunk tc)
    {
        for (int i = x; i < x + wide; ++i) {
            if (grid.containsObject(i, y)) {
                return null;
            }
        }

        Vector3 spawnPos = new Vector3 (0, 0, 0);
        for (int i = x; i < x + wide; ++i) {
            spawnPos += grid.GridToWorld(i, y);
        }

        spawnPos /= wide;
        spawnPos += tc.transform.position;

        //Vector3 spawnPos = grid.GridToWorld (x, y) + tc.transform.position;
        spawnPos.z = 0;
        Transform piece = wide == 3 ? ground3wide : (wide == 2 ? ground2wide : ground1wide);
        Transform t = GameObject.Instantiate (piece, spawnPos, Quaternion.identity) as Transform;

        for (int i = x; i < x + wide; ++i) {
            grid.MarkGrid(i, y);
        }

        Debug.Log ("Created in grid: " + x + ", " + y + "width: " + wide);

        return t;
    }
开发者ID:nchou001,项目名称:Popz,代码行数:29,代码来源:GroundGenerator.cs

示例2: GenerateGrounds

    //FOR N_Back!
    public void GenerateGrounds(Grid grid, TerrainChunk tc, int y = 0, 
	                             bool ceiling = false)
    {
        // Generate ground and potholes
        //First and last cannot be a hole.
        for (int i = 0; i < grid.numCellsX; ++i) {
            if (grid.containsObject(i, y)) {
                continue;
            }

            //level is chance that there is a hole! Do not spawnground!
            //int rand = Random.Range (0, 101);

            //if(!(i ==0 || i == grid.numCellsX))
            //{
            if (initCeiling == 0) {
                initCeiling++;
                continue;
            }
            //}

            // Generate random width ground pieces varying from 1-3
            int cap, roll;
            do {
                //cap = Mathf.Min (4, grid.numCellsX - i + 1);
                roll = 3;
            } while (!GenerateWideGround(i, y, roll, grid, tc, ceiling));
        }
    }
开发者ID:nchou001,项目名称:NC-Popz,代码行数:30,代码来源:GroundGenerator.cs

示例3: GenerateNbackInGrid

    public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int difficulty = navigationDifficulty;
        int scale = 10;

        // Generate beginning so character doesnt fall
        if (generateCount == 0) {
            for (int i = 0; i < 5; ++i) {
                ggen.GenerateGround (i, 0, grid, tc);
                ggen.GenerateGround (i, 7, grid, tc);
            }
        }
        ++generateCount;

        // Entry for prototype platforms generation
        if (platforms) {
            GenerateNbackInGridPlatforms(grid, tc, ggen);
            return;
        }

        // Generate Nback collectibles
        int x = lastGridOffset;
        for ( ; x < grid.numCellsX; x += rate) {
            int rand = Random.Range(0, 2);
            int y = rand == 0 ? 1 : 6;
            Transform h = GenerateNbackObjectInGrid(x, y, grid, tc);
        }

        // Generate ground and potholes
        for (int i = 0; i < grid.numCellsX; ++i) {
            // For floor
            // Generate ground (NOT pothole) by scale and difficulty
            if (grid.containsObject(i, 0)) {
                Debug.Log ("Grid Contains at: " + i);
                continue;
            }
            int cap = Mathf.Min (4, grid.numCellsX - i + 1);
            int roll = Random.Range (1, cap);

            while (!ggen.GenerateWideGround(i, 0, roll, grid, tc)) {
                roll = Random.Range (1, 4);
            }

        //			int rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				ggen.GenerateGround (i, 0, grid, tc);
        //			}
        //
        //			// For Ceiling
        //			rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				//ggen.GenerateGround (i, 7, grid, tc);
        //			}
        }
        lastGridOffset = x - grid.numCellsX;
    }
开发者ID:nchou001,项目名称:Popz,代码行数:56,代码来源:NbackGenerator.cs

示例4: GenerateGround

 public Transform GenerateGround(int x, int y, Grid grid, TerrainChunk tc)
 {
     if (grid.containsObject(x, y)) {
         return null;
     }
     Vector3 spawnPos = grid.GridToWorld (x,y) + tc.transform.position;
     Transform t = GenerateGround (spawnPos.x, spawnPos.y);
     t.parent = tc.gameObject.transform;
     grid.MarkGrid (x, y);
     return t;
 }
开发者ID:nchou001,项目名称:NC-Popz,代码行数:11,代码来源:GroundGenerator.cs

示例5: GenerateGrounds

 public void GenerateGrounds(Grid grid, TerrainChunk tc)
 {
     for (int x = 0; x < grid.numCellsX; x++) {
         if (Random.value < pitSpawnChance && !previousHasPit) {
             previousHasPit = !grid.containsObject(x,0);
             continue;
         }
         GenerateGround (x, 0, grid, tc);
         if (Random.value < hillSpawnChance && !previousHasPit) {
             Transform h = GenerateGround (x, 1, grid, tc);
             h.tag = "Hill";
         }
         previousHasPit = false;
     }
 }
开发者ID:nchou001,项目名称:Popz,代码行数:15,代码来源:GroundGenerator.cs

示例6: GeneratePlatform

 // Generates platform of the specified type at the grid location (x,y)
 public Transform GeneratePlatform(int x, int y, int type, Grid grid, TerrainChunk tc)
 {
     for (int i = 0; i < platforms[type].numCells; i++) {
         if (grid.containsObject(x + i, y)) {
             return null;
         }
     }
     Vector3 offset =  new Vector3 (((float)(platforms[type].numCells - 1)) * 0.5f * grid.cellSizeX, 0f, 0f);
     Vector3 spawnPos = grid.GridToWorld (x, y) + offset + tc.transform.position;
     for (int i = 0; i < platforms[type].numCells; i++) {
         grid.MarkGrid (x + i, y);
     }
     Transform t = GeneratePlatform (spawnPos.x, spawnPos.y, type);
     t.parent = tc.gameObject.transform;
     return t;
 }
开发者ID:nchou001,项目名称:NC-Popz,代码行数:17,代码来源:PlatformGenerator.cs

示例7: GenerateWideGround

    public Transform GenerateWideGround(int x, int y, int wide, Grid grid, TerrainChunk tc, bool ceiling = false)
    {
        // Check grid spaces aren't currently occupied
        for (int i = x; i < x + wide; ++i) {
            if (grid.containsObject(i, y)) {
                return null;
            }
        }

        // Position piece by averaging the grid space positions
        Vector3 spawnPos = new Vector3 (0, 0, 0);
        for (int i = x; i < x + wide; ++i) {
            spawnPos += grid.GridToWorld(i, y);
        }
        spawnPos /= wide;
        spawnPos += tc.transform.position;
        //spawnPos.y = 0;
        spawnPos.z = 0;
        //Vector3 spawnPos = grid.GridToWorld (x, y) + tc.transform.position;

        // Create piece
        Transform piece;

        if (ceiling) {
            piece = ceiling3wide;

            if (y == 7) {
                float topY = Camera.main.ScreenToWorldPoint(new Vector3(0, Camera.main.pixelHeight, 0)).y;
                spawnPos.y = topY - (grid.cellSizeY / 2.0f) + 0.2f;
            }else{
                Vector3 newPos = spawnPos;
                newPos.y = y-1.3f;
                Transform test = GameObject.Instantiate (ceiling3big, newPos, Quaternion.identity) as Transform;
            }
        } else {
            piece = ground3wide;
        }
        Transform t = GameObject.Instantiate (piece, spawnPos, Quaternion.identity) as Transform;

        // Mark grid spaces
        for (int i = x; i < x + wide; ++i) {
            grid.MarkGrid(i, y);
        }
        Destroy (t.gameObject, 15);

        return t;
    }
开发者ID:nchou001,项目名称:NC-Popz,代码行数:47,代码来源:GroundGenerator.cs

示例8: GenerateNbackObjectInGrid

    Transform GenerateNbackObjectInGrid(int x, int y, Grid grid, TerrainChunk tc)
    {
        if (grid.containsObject(x, y)) {
            return null;
        }
        Vector3 spawnPos = grid.GridToWorld (x,y) + tc.transform.position;
        Transform t = GenerateNbackObject (spawnPos.x, spawnPos.y);

        // Used to spawn randomly placed obstacles from floor to ceiling in levels 4 and 5
        int r = Random.Range (-7, 5);
        int r2 = Random.Range (-7, 0);
        if (timer >= 360f && timer < 480f) {
            Transform i = GenerateObstacles (spawnPos.x+5, r);
        } else if (timer >= 480) {
            Transform i = GenerateObstacles (spawnPos.x+5, r2);
        }
        t.parent = tc.gameObject.transform;
        grid.MarkGrid (x, y);
        return t;
    }
开发者ID:SamClose,项目名称:NC-Popz,代码行数:20,代码来源:NbackGenerator.cs

示例9: GenerateCollectibles

    //No TerrainChunk
    public void GenerateCollectibles(Grid grid, GameObject cloud)
    {
        int amount = possibleTypes.Count;

        //List of x locations
        List<Vector2> grid_locations = new List<Vector2>();
        for (int x = 0; x < grid.numCellsX; x++)
        {
            for (int y = 3; y < grid.numCellsY; y+=2)
            {
                if (!grid.containsObject(x,y-1))
                { //Spawn Chance or there is a platform underneath
                    continue;
                }
                grid_locations.Add( new Vector2(x,y));

            }

        }

        int rand_temp = 0;// = new Vector2(0,0);
        int randType = 0;
        int collectibleType;

        for(int i = amount; i != 0;i--)
        {
            rand_temp = Random.Range (0, grid_locations.Count);

            //Make List! Not Just Random!!
            randType = Random.Range (0, possibleTypes.Count);
            Debug.Log ("RandType: "+randType);

            collectibleType = possibleTypes[randType];

            GenerateCollectible ((int)grid_locations[rand_temp].x, (int)grid_locations[rand_temp].y, collectibleType, grid, cloud);
            grid_locations.RemoveAt(rand_temp);
            possibleTypes.RemoveAt(randType);

        }

        /*for (int x = 0; x < grid.numCellsX; x++)
        {
            for (int y = 3; y < grid.numCellsY; y+=2)
            {
                //if (Random.value > spawnChance || !grid.containsObject(x,y-1))
                if (!grid.containsObject(x,y-1))
                { //Spawn Chance or there is a platform underneath
                    continue;
                }
                //if(!grid.containsObject(x,y-1)) // Make sure that there is platform underneath.
                //{
                //	continue;
                //}
                //int collectibleType = Random.Range (0, collectibles.Length);

                if(amount != 0)
                {
                    int collectibleType = Random.Range (0, spawnableCollectibles.Count);
                    //This is where we actually generate the plants!
                    GenerateCollectible (x, y, collectibleType, grid, cloud);
                    amount--;
                }
            }
        }
        */
    }
开发者ID:nchou001,项目名称:Popz,代码行数:67,代码来源:CollectibleGenerator.cs

示例10: GenerateCollectible

    public void GenerateCollectible(int x, int y, int type, Grid grid, GameObject cloud)
    {
        if (grid.containsObject(x, y))
        {

        }
        Vector3 spawnPos = grid.GridToWorld (x,y) + cloud.transform.position;
        Transform t = GenerateCollectible (spawnPos.x, spawnPos.y, type,1);
        t.parent = cloud.gameObject.transform;
        grid.MarkGrid (x, y);
    }
开发者ID:nchou001,项目名称:Popz,代码行数:11,代码来源:CollectibleGenerator.cs


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