-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpawnerSmart.cs
37 lines (32 loc) · 1.04 KB
/
SpawnerSmart.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnerSmart : MonoBehaviour {
public GameObject extraBallPrefab;
public float extraBallSpawnPositionX;
public GameObject[] spawningItems;
public GameObject[] spawnPositions;
private int brickChoose;
// Use this for initialization
void Start () {
ExtraBallSpawn();
ForeachSpawn();
}
void ForeachSpawn(){
foreach (GameObject position in spawnPositions){
brickChoose = Random.Range(0,spawningItems.Length);
if (spawningItems[brickChoose]== null){
break;
}else{
GameObject myAttacker = Instantiate (spawningItems[brickChoose])as GameObject;
myAttacker.transform.SetParent(position.transform, false);
myAttacker.transform.position = position.transform.position;
}
}
}
void ExtraBallSpawn(){
GameObject extraBall = Instantiate(extraBallPrefab) as GameObject;
extraBall.transform.parent = transform;
extraBall.transform.position = new Vector3 (extraBallSpawnPositionX,9.5f,0);
}
}