Mercurial > hg > Members > kazuma > JungleforUnity
diff Assets/Application/Scripts/StageManager.cs @ 0:e5ef0342d00b
First commit
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 00:39:49 +0900 |
parents | |
children | 2dd40b4412e4 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Application/Scripts/StageManager.cs Mon Nov 07 00:39:49 2016 +0900 @@ -0,0 +1,54 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +public class StageManager : MonoBehaviour { + + // stages["Attribute"]で取れる + public System.Collections.Generic.List<GameObject> stages = new System.Collections.Generic.List<GameObject>(); + private GameObject baseStage; + + public System.Collections.Generic.List<Vector3> StageData = new System.Collections.Generic.List<Vector3> (); + + // Use this for initialization + void Start () { + Init (); + SetStage (); + CreateStages (10); + } + + void Init () { + baseStage = new GameObject (); + baseStage.name = "stage"; + baseStage.transform.position = Vector3.zero; + } + + void SetStage () { + object[] objects = Resources.LoadAll ("Prefabs"); + foreach (var obj in objects) { + GameObject gbj = (GameObject)obj; + stages.Add(gbj); + } + } + + // One. + public void CreateStage (int num, Vector3 pos) { + GameObject obj = Instantiate (stages[num]); + obj.GetComponent<Stage> ().SetPosition (pos); + obj.transform.SetParent (baseStage.transform); + } + + // Any. + public void CreateStages (int count) { + for (int x = 0; x < count; x++) { + for (int z = 0; z < count; z++) { + CreateStage (Random.Range (0, stages.Count), new Vector3 (x, Random.Range(-1, 1), z)); + } + } + } + + // Update is called once per frame + void Update () { + + } +}