MissionCubeSpawner.cs
1.09 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MissionCubeSpawner : MonoBehaviour {
public GameObject MissionCubePrefab;
public Transform[] SpawnPositions;
bool newGameStart;
// Use this for initialization
void Start () {
newGameStart = true;
}
// Update is called once per frame
void Update () {
}
public void CreateMissionCube()
{
int prev1 = 6;
int prev2 = 6;
int randomNumber ;
for (int i = 0; i < 3; i++)
{
randomNumber = Random.Range(0, 5);
if (randomNumber != prev1 && randomNumber != prev2)
{
GameObject.Instantiate(MissionCubePrefab, SpawnPositions[randomNumber]);
}
else
{
i--;
}
if (i == 0)
{
prev1 = randomNumber;
}
else if (i==1)
{
prev2 = randomNumber;
}
Debug.Log("Random No. : " + randomNumber);
}
}
}