summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/CrystalBehaviour.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/CrystalBehaviour.cs')
-rw-r--r--Client/Assembly-CSharp/CrystalBehaviour.cs110
1 files changed, 110 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/CrystalBehaviour.cs b/Client/Assembly-CSharp/CrystalBehaviour.cs
new file mode 100644
index 0000000..ebb7b2b
--- /dev/null
+++ b/Client/Assembly-CSharp/CrystalBehaviour.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Collections;
+using UnityEngine;
+
+public class CrystalBehaviour : MonoBehaviour
+{
+ public CrystalBehaviour Above;
+
+ public CrystalBehaviour Below;
+
+ public CrystalBehaviour.Parentness ParentSide;
+
+ public SpriteRenderer Renderer;
+
+ public BoxCollider2D Collider;
+
+ public FloatRange Padding;
+
+ private const float Speed = 15f;
+
+ private const float FloatMag = 0.05f;
+
+ private const float FloatSpeed = 0.35f;
+
+ public enum Parentness
+ {
+ None,
+ Above,
+ Below
+ }
+
+ private void Update()
+ {
+ Vector3 position = base.transform.position;
+ Vector3 vector;
+ if (this.ParentSide == CrystalBehaviour.Parentness.Above)
+ {
+ if (!this.Above)
+ {
+ return;
+ }
+ vector = this.Above.transform.position - new Vector3(0f, this.Above.Padding.min + this.Padding.max, 0f);
+ }
+ else
+ {
+ if (this.ParentSide != CrystalBehaviour.Parentness.Below)
+ {
+ return;
+ }
+ if (!this.Below)
+ {
+ return;
+ }
+ vector = this.Below.transform.position + new Vector3(0f, this.Below.Padding.max + this.Padding.min, 0f);
+ }
+ float num = Time.time / 0.35f;
+ vector.x += (Mathf.PerlinNoise(num, position.z * 20f) * 2f - 1f) * 0.05f;
+ vector.y += (Mathf.PerlinNoise(position.z * 20f, num) * 2f - 1f) * 0.05f;
+ vector.z = position.z;
+ position.x = Mathf.SmoothStep(position.x, vector.x, Time.deltaTime * 15f);
+ position.y = Mathf.SmoothStep(position.y, vector.y, Time.deltaTime * 15f);
+ base.transform.position = position;
+ }
+
+ public void FlashUp(float delay = 0f)
+ {
+ base.StopAllCoroutines();
+ base.StartCoroutine(CrystalBehaviour.Flash(this, delay));
+ if (this.Above)
+ {
+ this.Above.FlashUp(delay + 0.1f);
+ }
+ }
+
+ public void FlashDown(float delay = 0f)
+ {
+ base.StopAllCoroutines();
+ base.StartCoroutine(CrystalBehaviour.Flash(this, delay));
+ if (this.Below)
+ {
+ this.Below.FlashDown(delay + 0.1f);
+ }
+ }
+
+ private static IEnumerator Flash(CrystalBehaviour c, float delay)
+ {
+ for (float time = 0f; time < delay; time += Time.deltaTime)
+ {
+ yield return null;
+ }
+ Color col = Color.clear;
+ for (float time = 0f; time < 0.1f; time += Time.deltaTime)
+ {
+ float t = time / 0.1f;
+ col.r = (col.g = (col.b = Mathf.Lerp(0f, 1f, t)));
+ c.Renderer.material.SetColor("_AddColor", col);
+ yield return null;
+ }
+ for (float time = 0f; time < 0.1f; time += Time.deltaTime)
+ {
+ float t2 = time / 0.1f;
+ col.r = (col.g = (col.b = Mathf.Lerp(1f, 0f, t2)));
+ c.Renderer.material.SetColor("_AddColor", col);
+ yield return null;
+ }
+ col.r = (col.g = (col.b = 0f));
+ c.Renderer.material.SetColor("_AddColor", col);
+ yield break;
+ }
+}