Ejemplo n.º 1
0
    private void SpawningRoom()
    {
        int[,] grid = layout.GetGridLayout();

        string text = "";

        for (int i = 0; i < roomSize.y; i++)
        {
            for (int j = 0; j < roomSize.x; j++)
            {
                text += grid[j, i] + " ";
                if (grid[j, i] != 0)
                {
                    Room spawn = Instantiate(testa, new Vector2(j, i), Quaternion.identity, parent);
                    spawn.Init(grid, j, i, grid[j, i]);

                    if ((j, i) == layout.GetStartNode())
                    {
                        spawn.SetStateRoom("START");
                    }
                    else if ((j, i) == layout.GetEndNode())
                    {
                        spawn.SetStateRoom("END");
                    }
                }
            }
            text += "\n";
        }

        parent.localScale = new Vector3(1, -1, 1);
        Debug.Log(text);
    }
Ejemplo n.º 2
0
    private void SpawningRoom()
    {
        int[,] grid = layout.GetGridLayout();

        for (int i = 0; i < roomSize.y; i++)
        {
            for (int j = 0; j < roomSize.x; j++)
            {
                if (grid[j, i] != 0)
                {
                    Vector2 spawnPos = new Vector2(j, i) * spaceScale;
                    Room    spawn    = Instantiate(roomPrefabs, spawnPos, Quaternion.identity, parent);
                    spawn.Init(grid, j, i, grid[j, i]);
                    spawn.transform.localScale = spaceScale;

                    if (spawn.IsEnemyArea())
                    {
                        ScanRoomPath(spawnPos * scaleParent);
                    }

                    if ((j, i) == layout.GetStartNode())
                    {
                        spawn.SetStateRoom("START");
                    }
                    else if ((j, i) == layout.GetEndNode())
                    {
                        spawn.SetStateRoom("END");
                    }
                }
            }
        }

        parent.localScale = scaleParent;
        if (AstarPath.active.graphs.Length > 0)
        {
            AstarPath.active.Scan();
        }
    }