(サンプルコード)
using UnityEngine;
public class CountManager : MonoBehaviour
{
private int count;
public GameObject checkPointPrefab;
public GameObject[] enemyBox;
public void AddCount()
{
count += 1;
// ★次のチェックポイントの生成
Instantiate(checkPointPrefab, new Vector3(0, 1, 5 + 10 * count), Quaternion.identity);
// ★ランダム(敵の選択)
// 0〜2のランダム
int enemyNum = Random.Range(0, enemyBox.Length);
// ★ランダム(敵のセット数の選択)
// 1〜3のランダム
int setNum = Random.Range(1, 4);
switch (setNum)
{
case 1:
Set1(enemyNum, count);
break;
case 2:
Set2(enemyNum, count);
break;
case 3:
Set3(enemyNum, count);
break;
}
}
void Set1(int enemeyNum, int countNum)
{
Instantiate(enemyBox[enemeyNum], new Vector3(0, 0.5f, 3 + 10 * countNum), Quaternion.identity);
}
void Set2(int enemeyNum, int countNum)
{
Instantiate(enemyBox[enemeyNum], new Vector3(-2, 0.5f, 3 + 10 * countNum), Quaternion.identity);
Instantiate(enemyBox[enemeyNum], new Vector3(2, 0.5f, 3 + 10 * countNum), Quaternion.identity);
}
void Set3(int enemeyNum, int countNum)
{
Instantiate(enemyBox[enemeyNum], new Vector3(-4, 0.5f, 3 + 10 * countNum), Quaternion.identity);
Instantiate(enemyBox[enemeyNum], new Vector3(0, 0.5f, 3 + 10 * countNum), Quaternion.identity);
Instantiate(enemyBox[enemeyNum], new Vector3(4, 0.5f, 3 + 10 * countNum), Quaternion.identity);
}
}
(実行結果)