From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/Cluster.cs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 GameCode/Cluster.cs (limited to 'GameCode/Cluster.cs') diff --git a/GameCode/Cluster.cs b/GameCode/Cluster.cs new file mode 100644 index 0000000..2e5c648 --- /dev/null +++ b/GameCode/Cluster.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +public class Cluster : MonoBehaviour +{ + public float distanceToTravel = 8f; + + public float spread; + + public float velocitySpread; + + public int clusters = 3; + + private MoveTransform move; + + private void Start() + { + move = GetComponentInParent(); + } + + private void Update() + { + if (!(move.distanceTravelled > distanceToTravel)) + { + return; + } + for (int i = 0; i < clusters; i++) + { + GameObject obj = Object.Instantiate(base.transform.root.gameObject, base.transform.root.position, base.transform.root.rotation); + Cluster componentInChildren = obj.GetComponentInChildren(); + if ((bool)componentInChildren) + { + Object.Destroy(componentInChildren); + } + MoveTransform component = obj.GetComponent(); + if ((bool)component) + { + component.DontRunStart = true; + component.velocity = base.transform.root.GetComponent().velocity; + component.multiplier = base.transform.root.GetComponent().multiplier; + component.velocity += base.transform.right * Random.Range(0f - spread, spread); + component.velocity *= Random.Range(1f - velocitySpread * 0.01f, 1f + velocitySpread * 0.01f); + } + } + Object.Destroy(this); + } +} -- cgit v1.1-26-g67d0