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


C# Grid.GridToWorld方法代码示例

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


在下文中一共展示了Grid.GridToWorld方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Awake

    void Awake()
    {
        _gc = GameController.Get();
        _grid = Grid.Get();

        transform.position = _grid.GridToWorld(new Vector2(_grid.Width - 1, _grid.Height - 1)) +
                             new Vector3(_grid.GridUnitSize + 0.5f, _grid.GridUnitSize + 0.5f);

        Spawn();
    }
开发者ID:ZeronSix,项目名称:ld30,代码行数:10,代码来源:AlienMothership.cs

示例3: 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

示例4: 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

示例5: 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

示例6: 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

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