Mercurial > hg > Members > kazuma > JungleforUnity
comparison Assets/Application/Scripts/StageManager.cs @ 0:e5ef0342d00b
First commit
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 00:39:49 +0900 |
parents | |
children | 2dd40b4412e4 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e5ef0342d00b |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System.Collections.Generic; | |
4 | |
5 public class StageManager : MonoBehaviour { | |
6 | |
7 // stages["Attribute"]で取れる | |
8 public System.Collections.Generic.List<GameObject> stages = new System.Collections.Generic.List<GameObject>(); | |
9 private GameObject baseStage; | |
10 | |
11 public System.Collections.Generic.List<Vector3> StageData = new System.Collections.Generic.List<Vector3> (); | |
12 | |
13 // Use this for initialization | |
14 void Start () { | |
15 Init (); | |
16 SetStage (); | |
17 CreateStages (10); | |
18 } | |
19 | |
20 void Init () { | |
21 baseStage = new GameObject (); | |
22 baseStage.name = "stage"; | |
23 baseStage.transform.position = Vector3.zero; | |
24 } | |
25 | |
26 void SetStage () { | |
27 object[] objects = Resources.LoadAll ("Prefabs"); | |
28 foreach (var obj in objects) { | |
29 GameObject gbj = (GameObject)obj; | |
30 stages.Add(gbj); | |
31 } | |
32 } | |
33 | |
34 // One. | |
35 public void CreateStage (int num, Vector3 pos) { | |
36 GameObject obj = Instantiate (stages[num]); | |
37 obj.GetComponent<Stage> ().SetPosition (pos); | |
38 obj.transform.SetParent (baseStage.transform); | |
39 } | |
40 | |
41 // Any. | |
42 public void CreateStages (int count) { | |
43 for (int x = 0; x < count; x++) { | |
44 for (int z = 0; z < count; z++) { | |
45 CreateStage (Random.Range (0, stages.Count), new Vector3 (x, Random.Range(-1, 1), z)); | |
46 } | |
47 } | |
48 } | |
49 | |
50 // Update is called once per frame | |
51 void Update () { | |
52 | |
53 } | |
54 } |