public void Generate() { GroundMaker gm = null; Vector3 nextAnchor = Vector3.zero; while (_segments.Count > segments) { GroundMaker segment = _segments[_segments.Count - 1]; _segments.Remove(segment); Destroy(segment.gameObject); } for (int i = 0; i < segments; i++) { if (_segments.Count < i + 1) { GameObject go = new GameObject(); go.name = string.Format("Terrain Ground {0}", i); gm = go.AddComponent <GroundMaker>(); _segments.Add(gm); } else { gm = _segments[i]; } gm.debug = debug; float terrainP = terrainAccProbability.Max() * Random.value; int idT = 0; while (terrainP > terrainAccProbability[idT] && idT < terrainAccProbability.Count) { idT++; } gm.stepSize = Random.Range(terrainSegmentStepSizeMin[idT], terrainSegmentStepSizeMax[idT]); gm.Build(terrainType[idT], Random.Range(terrainSegmentLengthMin[idT], terrainSegmentLengthMax[idT]), Random.Range(terrainSegmentStepChaosMin[idT], terrainSemgentStepChaosMax[idT]), Random.Range(terrainSegmentAmplitudeMin[idT], terrainSegmentAmplitudeMax[idT])); //nextAnchor -= gm.anchorLeft; gm.transform.position = nextAnchor - gm.anchorLeft; nextAnchor = gm.anchorRight + gm.transform.localPosition; } levelTarget.position = nextAnchor + levelTargetOffset; }
//PropertyField[] m_fields; public void OnEnable() { m_Instance = target as GroundMaker; //m_fields = ExposeProperties.GetProperties( m_Instance ); }