示例#1
0
    void Start()
    {
        if (_on)
        {
            Debug.Log("Start");
            _tileMapCollider.enabled = false;
            _grid = Cave.Generate(_cols, _rows, false /* isAngular */, false /* isEmpty */);
            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _cols; col++)
                {
                    CellType cell = _grid[col, row];
                    if (cell != CellType.Empty)
                    {
                        _tileMap.SetTile(new Vector3Int(col, row, 0), _tile);
                    }
                }
            }

            Debug.Log(watch.ElapsedMilliseconds);
            _tileMapCollider.enabled = true;

            GridPoint gp = Cave.GetSpawnPoint();
            Instantiate(_playerPrefab, new Vector3(gp.column + 0.5f, (gp.row + 0.5f), 10), Quaternion.identity);

            for (int i = 0; i < 10; i++)
            {
                gp = Cave.GetSpawnPoint();
                Instantiate(_enemyPrefab, new Vector3(gp.column + 0.5f, (gp.row + 0.5f), 10), Quaternion.identity);
            }
        }
    }