private void CreateBarrier() { var minNumber = LEVEL_BARRIER_MIN[difficulty]; var maxNumber = LEVEL_BARRIER_MAX[difficulty]; var wayDict = WorldHelper.RandomFixedXS(minNumber, maxNumber); var blockMinimum = 2; var blockCount = 0; foreach (var kv in wayDict) { var way = kv.Key; var x = kv.Value; var type = EBarrierType.BLOCK; if (++blockCount > blockMinimum) { type = (EBarrierType)MathKit.RandomType(CREATE_BARRIER_PROBS); } var gameObject = Object.Instantiate(stage.barrierPrefab, stage.barrierCanvas.transform); gameObject.transform.position = new Vector3(x, Screen.height + 100, 0); var barrier = gameObject.GetComponent <Barrier>(); barrier.Way = way; barrier.Morph(type); world.BarrierManager.Add(barrier); } }
private void CreateByDistance() { var type = ECreateDistance.NONE; do { type = (ECreateDistance)MathKit.RandomType(CREATE_DISTANCE_PROBS); if (type == lastCreateDistanceType) { ++lastCreateDistanceCount; } else { lastCreateDistanceType = type; lastCreateDistanceCount = 1; } } while (lastCreateDistanceCount > 2); switch (type) { case ECreateDistance.ENEMY: CreateBarrier(); break; case ECreateDistance.BARRIER: CreateBarrier(); break; case ECreateDistance.ROLLING: CreateBarrier(); break; default: break; } }