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/SpawnStaticRemnant.cs | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 GameCode/SpawnStaticRemnant.cs (limited to 'GameCode/SpawnStaticRemnant.cs') diff --git a/GameCode/SpawnStaticRemnant.cs b/GameCode/SpawnStaticRemnant.cs new file mode 100644 index 0000000..9e0a67e --- /dev/null +++ b/GameCode/SpawnStaticRemnant.cs @@ -0,0 +1,52 @@ +using UnityEngine; + +public class SpawnStaticRemnant : MonoBehaviour +{ + public GameObject remnantSource; + + private AttackLevel level; + + private Color remnantColor; + + private void Start() + { + remnantColor = PlayerSkinBank.GetPlayerSkinColors(base.transform.GetComponentInParent().playerID).winText; + level = GetComponent(); + } + + public void Go() + { + GameObject gameObject = Object.Instantiate(remnantSource, base.transform.position, base.transform.rotation); + SpriteRenderer[] componentsInChildren = base.transform.root.GetComponentsInChildren(); + for (int i = 0; i < componentsInChildren.Length; i++) + { + if (componentsInChildren[i].transform.lossyScale.x != 0f && componentsInChildren[i].transform.lossyScale.y != 0f && componentsInChildren[i].transform.lossyScale.z != 0f && (!(componentsInChildren[i].transform.parent.name != "Art") || !(componentsInChildren[i].transform.parent.parent.name != "Face"))) + { + Vector3 lossyScale = componentsInChildren[i].transform.lossyScale; + GameObject gameObject2 = Object.Instantiate(componentsInChildren[i].gameObject, componentsInChildren[i].transform.position, componentsInChildren[i].transform.rotation, gameObject.transform.GetChild(0)); + gameObject2.transform.localScale = lossyScale; + Strip(gameObject2); + SpriteRenderer component = gameObject2.GetComponent(); + component.enabled = true; + component.color = remnantColor; + SpriteMask component2 = gameObject2.GetComponent(); + if ((bool)component2) + { + Object.Destroy(component2); + } + } + } + gameObject.GetComponentInChildren().startColor = PlayerSkinBank.GetPlayerSkinColors(base.transform.GetComponentInParent().playerID).particleEffect; + gameObject.AddComponent().spawner = base.transform.root.GetComponent(); + gameObject.transform.localScale *= 1f + (float)(level.attackLevel - 1) * 0.3f; + } + + private void Strip(GameObject go) + { + MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren(); + for (int i = 0; i < componentsInChildren.Length; i++) + { + Object.Destroy(componentsInChildren[i]); + } + } +} -- cgit v1.1-26-g67d0