void CreateLevel() { for (int i = 0; i < levelSize; ++i) { for (int j = 0; j < levelSize; ++j) { GameObject block = Instantiate(blockPrefab, new Vector3(i * blockGap, Random.Range(-pillarScale, pillarScale + 1), j * blockGap), Quaternion.identity) as GameObject; block.transform.localScale *= blockScale; BlockBehaviour bBehave = block.AddComponent <BlockBehaviour>(); int blockType = Random.Range(0, pillarChance); bBehave.Init(blockType, defaultChance, permanentChance, fragileChance, holdsDataChance, pillarChance, pillarScale); if (bBehave.blocktype == BlockType.HoldsData) { GameObject data = Instantiate(dataPrefab) as GameObject; data.hideFlags = HideFlags.HideInHierarchy; data.transform.position = block.transform.position + new Vector3(0, Random.Range(-(float)dataHeightDistanceMin, -dataHeightDistanceMax), 0); datas.Add(data); } block.transform.parent = blockParent.transform; blocks.Add(block); if (i == centralPoint && j == centralPoint) { GameObject sphere = Instantiate(outerSphere, new Vector3(i * blockGap, transform.position.y, j * blockGap), Quaternion.identity) as GameObject; sphere.transform.localScale = sphereScale; } } } AIManager.instance.Populate(levelSize, blockGap, pillarScale, blockScale); }
private void Awake() { children = GetComponentInChildren <NeedleController>(); rb = GetComponent <Rigidbody2D>(); behaviour = new BlockBehaviour(); behaviour.Init(transform, rb, velocity); }