Esempio n. 1
0
    void generateWorldInit()
    {
        for (int i = 0; i < gridWidthWorld; i++)
        {
            for (int j = 0; j < gridHeightWorld; j++)
            {
                grid[i][j] = true;
            }
        }
        grid[gridWidthWorld / 2][gridHeightWorld / 2] = false;

        int   minX    = gridWidthArea / 2 - startWidth / 2;
        int   maxX    = gridWidthArea / 2 + startWidth / 2;
        int   minY    = gridHeightArea / 2 - startHeight / 2;
        int   maxY    = gridHeightArea / 2 + startHeight / 2;
        float offsetX = (gridWidthWorld / 2) * gridWidthArea + 0.5f;
        float offsetY = (gridHeightWorld / 2) * gridHeightArea + 0.5f;

        for (int i = 0; i < gridWidthArea; i++)
        {
            for (int j = 0; j < gridHeightArea; j++)
            {
                if (i < minX || i >= maxX || j < minY || j >= maxY)
                {
                    Pool.Spawn(Block, new Vector3(i + offsetX, j + offsetY, 0f), Quaternion.identity);
                }
            }
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Спауним префаб
 /// </summary>
 public void ShowPrefab()
 {
     if (prefab == null)
     {
         prefab = PoolsManager.Spawn(prefabName, new Vector3(position.x, position.y, 0), Quaternion.identity);
         prefab.transform.SetParent(GameObject.FindGameObjectWithTag("MapLayer").transform);//инкапсулировать
     }
 }