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/DynamicParticles.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 GameCode/DynamicParticles.cs (limited to 'GameCode/DynamicParticles.cs') diff --git a/GameCode/DynamicParticles.cs b/GameCode/DynamicParticles.cs new file mode 100644 index 0000000..26a0cad --- /dev/null +++ b/GameCode/DynamicParticles.cs @@ -0,0 +1,50 @@ +using UnityEngine; + +public class DynamicParticles : MonoBehaviour +{ + public static DynamicParticles instance; + + public DynamicParticleSet[] bulletHit; + + private int spawnsThisFrame; + + private void Start() + { + instance = this; + } + + private void Update() + { + spawnsThisFrame = 0; + } + + public void PlayBulletHit(float damage, Transform spawnerTransform, HitInfo hit, Color projectielColor) + { + if ((float)spawnsThisFrame > 5f) + { + return; + } + spawnsThisFrame++; + int num = 0; + for (int i = 1; i < bulletHit.Length && !(bulletHit[i].dmg > damage); i++) + { + num = i; + } + GameObject[] array = ObjectsToSpawn.SpawnObject(base.transform, hit, bulletHit[num].objectsToSpawn, null, null); + if (!(projectielColor != Color.black)) + { + return; + } + for (int j = 0; j < array.Length; j++) + { + for (int k = 0; k < array[j].transform.childCount; k++) + { + ChangeColor componentInChildren = array[j].transform.GetChild(k).GetComponentInChildren(); + if ((bool)componentInChildren) + { + componentInChildren.GetComponent().material.color = projectielColor; + } + } + } + } +} -- cgit v1.1-26-g67d0