IEnumerator CreateStage(StageData stageData) { _initialized = false; _boss = Instantiate <EnemyBoss>(_prefabEnemyBosses [stageData.StageNo]); _boss.transform.localPosition = stageData.BossPos; _boss.transform.SetParent(_gameUnitWorld.transform, false); foreach (StageDataObject stageDataObject in stageData.Objects) { StageObject prefab = null; switch (stageDataObject.Type) { case StageDataObject.DataType.Scaffold: prefab = _prefabObjectScaffolds[stageDataObject.Size]; break; case StageDataObject.DataType.Block: prefab = _prefabObjectBlocks[stageDataObject.Size]; break; } if (prefab != null) { StageObject stageObject = Instantiate <StageObject> (prefab); stageObject.Setup(stageDataObject); stageObject.transform.SetParent(_gameUnitWorld.transform, false); } } yield return(0); yield return(0); foreach (StageDataEnemy stageDataEnemy in stageData.Enemies) { EnemyBase prefab = null; switch (stageDataEnemy.Type) { case StageDataEnemy.DataType.Grounder: prefab = _prefabEnemyGrounders [stageDataEnemy.Level]; break; case StageDataEnemy.DataType.Floater: prefab = _prefabEnemyFloters [stageDataEnemy.Level]; break; case StageDataEnemy.DataType.Liner: prefab = _prefabEnemyLiners [stageDataEnemy.Level]; break; } if (prefab != null) { EnemyBase enemy = Instantiate <EnemyBase> (prefab); enemy.transform.localPosition = stageDataEnemy.Pos; enemy.transform.SetParent(_gameUnitWorld.transform, false); } } _stageData = stageData; _initialized = true; }