0
|
1 using UnityEngine;
|
|
2 using System.Collections;
|
|
3 using System.Collections.Generic;
|
|
4
|
|
5 public class StageManager : MonoBehaviour {
|
|
6
|
3
|
7 public static StageManager Instance;
|
0
|
8 // stages["Attribute"]で取れる
|
|
9 public System.Collections.Generic.List<GameObject> stages = new System.Collections.Generic.List<GameObject>();
|
|
10 private GameObject baseStage;
|
|
11
|
|
12 public System.Collections.Generic.List<Vector3> StageData = new System.Collections.Generic.List<Vector3> ();
|
|
13
|
3
|
14 void Awake () {
|
|
15 if (Instance == null) {
|
|
16 Instance = this;
|
|
17 }
|
|
18 }
|
|
19
|
0
|
20 // Use this for initialization
|
|
21 void Start () {
|
|
22 Init ();
|
|
23 SetStage ();
|
|
24 CreateStages (10);
|
|
25 }
|
|
26
|
|
27 void Init () {
|
|
28 baseStage = new GameObject ();
|
|
29 baseStage.name = "stage";
|
|
30 baseStage.transform.position = Vector3.zero;
|
|
31 }
|
|
32
|
|
33 void SetStage () {
|
3
|
34 object[] objects = Resources.LoadAll ("Prefabs/Object");
|
0
|
35 foreach (var obj in objects) {
|
|
36 GameObject gbj = (GameObject)obj;
|
|
37 stages.Add(gbj);
|
|
38 }
|
|
39 }
|
|
40
|
|
41 // One.
|
|
42 public void CreateStage (int num, Vector3 pos) {
|
|
43 GameObject obj = Instantiate (stages[num]);
|
|
44 obj.GetComponent<Stage> ().SetPosition (pos);
|
|
45 obj.transform.SetParent (baseStage.transform);
|
|
46 }
|
|
47
|
|
48 // Any.
|
|
49 public void CreateStages (int count) {
|
|
50 for (int x = 0; x < count; x++) {
|
|
51 for (int z = 0; z < count; z++) {
|
|
52 CreateStage (Random.Range (0, stages.Count), new Vector3 (x, Random.Range(-1, 1), z));
|
|
53 }
|
|
54 }
|
|
55 }
|
|
56
|
|
57 // Update is called once per frame
|
|
58 void Update () {
|
|
59
|
|
60 }
|
|
61 }
|