summaryrefslogtreecommitdiff
path: root/GameCode/SpawnStaticRemnant.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/SpawnStaticRemnant.cs
+ init
Diffstat (limited to 'GameCode/SpawnStaticRemnant.cs')
-rw-r--r--GameCode/SpawnStaticRemnant.cs52
1 files changed, 52 insertions, 0 deletions
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<Player>().playerID).winText;
+ level = GetComponent<AttackLevel>();
+ }
+
+ public void Go()
+ {
+ GameObject gameObject = Object.Instantiate(remnantSource, base.transform.position, base.transform.rotation);
+ SpriteRenderer[] componentsInChildren = base.transform.root.GetComponentsInChildren<SpriteRenderer>();
+ 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<SpriteRenderer>();
+ component.enabled = true;
+ component.color = remnantColor;
+ SpriteMask component2 = gameObject2.GetComponent<SpriteMask>();
+ if ((bool)component2)
+ {
+ Object.Destroy(component2);
+ }
+ }
+ }
+ gameObject.GetComponentInChildren<ParticleSystem>().startColor = PlayerSkinBank.GetPlayerSkinColors(base.transform.GetComponentInParent<Player>().playerID).particleEffect;
+ gameObject.AddComponent<SpawnedAttack>().spawner = base.transform.root.GetComponent<Player>();
+ gameObject.transform.localScale *= 1f + (float)(level.attackLevel - 1) * 0.3f;
+ }
+
+ private void Strip(GameObject go)
+ {
+ MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>();
+ for (int i = 0; i < componentsInChildren.Length; i++)
+ {
+ Object.Destroy(componentsInChildren[i]);
+ }
+ }
+}