using System.Collections; using System.Collections.Generic; using UnityEngine; public class RandomStone : MonoBehaviour { [Range(1,100)] public int seed = 1; [Header("随机范围")] [Range(5,20)] public float Range = 5; [Header("随机比例")] [Range(1.5f, 5)] public float ScaleRange = 2; public void Init() { GameObject thiskuang = GameObject.Instantiate(Resources.Load("Prefab/kuang"), Level3Manager.Instance.kuangParent); thiskuang.GetComponent()._camera = Level3Manager.Instance.cameraGroup[0]; thiskuang.GetComponent().target = this.transform; thiskuang.transform.localScale = this.transform.localScale; for (int i = 0; i < seed; i++) { GameObject go = GameObject.Instantiate(this.gameObject, this.transform.parent); go.transform.position = this.transform.position += new Vector3(Random.Range(-Range,Range), Random.Range(-Range, Range)*0.5f, Random.Range(-Range, Range)*0.1f); go.transform.localScale = new Vector3(Random.Range(1f, ScaleRange), Random.Range(1f, ScaleRange), Random.Range(1f, ScaleRange)); Level3Manager.Instance.StartTimeAction(2.5f, () => { go.GetComponent().enabled = true; }); GameObject kuang = GameObject.Instantiate(Resources.Load("Prefab/kuang"),Level3Manager.Instance.kuangParent); kuang.GetComponent()._camera = Level3Manager.Instance.cameraGroup[0]; kuang.GetComponent().target =go.transform; kuang.transform.localScale = go.transform.localScale; } Level3Manager.Instance.StartTimeAction(2.5f, () => { this.GetComponent().enabled = true; }); } }