diff options
| author | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
| commit | a22c505984697881f5f911a165ee022087b69e09 (patch) | |
| tree | d3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_1_0/Decompile/Coin.cs | |
| parent | 4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff) | |
Diffstat (limited to 'Thronefall_1_0/Decompile/Coin.cs')
| -rw-r--r-- | Thronefall_1_0/Decompile/Coin.cs | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/Thronefall_1_0/Decompile/Coin.cs b/Thronefall_1_0/Decompile/Coin.cs deleted file mode 100644 index 9ba06a2..0000000 --- a/Thronefall_1_0/Decompile/Coin.cs +++ /dev/null @@ -1,137 +0,0 @@ -using UnityEngine; - -public class Coin : MonoBehaviour -{ - public Transform mesh; - - public float maxSpeed = 20f; - - public float accelerationTime = 1f; - - public AnimationCurve accelerationCurve; - - public float spawnAnimationDuration = 1f; - - public float spawnAnimationScale = 10f; - - public AnimationCurve spawnAnimationCurve; - - public bool groundOnSpawn; - - public LayerMask groundLayer; - - public Vector3 groundingOffset; - - public bool registerInTagManager; - - public GameObject onPickUpParticles; - - private PlayerInteraction target; - - private Vector3 targetOffset = Vector3.up * 2f; - - private float pickupRange = 0.1f; - - private float spawnAnimationClock; - - private Vector3 initialPosition; - - private float accelerationClock; - - private bool grounded; - - private Vector3 groundingPos; - - private float groundingVelocity; - - private bool particlesSpawned; - - public bool IsFree => target == null; - - private void Start() - { - mesh.rotation = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)); - initialPosition = base.transform.position; - if (groundOnSpawn) - { - if (Physics.Raycast(new Ray(base.transform.position, Vector3.down), out var hitInfo, float.PositiveInfinity, groundLayer)) - { - groundingPos = hitInfo.point + groundingOffset; - initialPosition = groundingPos; - } - else - { - grounded = true; - } - } - if (registerInTagManager && (bool)TagManager.instance) - { - TagManager.instance.freeCoins.Add(this); - } - if ((bool)TagManager.instance) - { - TagManager.instance.coins.Add(this); - } - } - - private void Update() - { - mesh.Rotate(45f * Time.deltaTime, 120f * Time.deltaTime, 0f, Space.World); - if (groundOnSpawn && !grounded) - { - groundingVelocity += 9.81f * Time.deltaTime; - base.transform.position = Vector3.MoveTowards(base.transform.position, groundingPos, groundingVelocity); - if (Vector3.Distance(base.transform.position, groundingPos) < 0.05f) - { - base.transform.position = groundingPos; - grounded = true; - } - } - else if (spawnAnimationClock < spawnAnimationDuration) - { - spawnAnimationClock += Time.deltaTime; - base.transform.position = initialPosition + Vector3.up * spawnAnimationScale * spawnAnimationCurve.Evaluate(spawnAnimationClock / spawnAnimationDuration); - } - else - { - if (!target) - { - return; - } - accelerationClock += Time.deltaTime; - Vector3 vector = target.transform.position + targetOffset; - base.transform.position = Vector3.MoveTowards(base.transform.position, vector, maxSpeed * Time.deltaTime * accelerationCurve.Evaluate(accelerationClock / accelerationTime)); - if (!particlesSpawned && Vector3.Distance(vector, base.transform.position) < 3f) - { - if (onPickUpParticles != null) - { - Object.Instantiate(onPickUpParticles, vector, Quaternion.identity, target.transform); - } - particlesSpawned = true; - } - if (Vector3.Distance(vector, base.transform.position) < pickupRange) - { - target.AddCoin(); - ThronefallAudioManager.Oneshot(ThronefallAudioManager.AudioOneShot.CoinCollect); - Object.Destroy(base.gameObject); - } - } - } - - public void SetTarget(PlayerInteraction target) - { - this.target = target; - } - - private void OnDestroy() - { - if (registerInTagManager && (bool)TagManager.instance) - { - TagManager.instance.freeCoins.Remove(this); - } - if ((bool)TagManager.instance) - { - TagManager.instance.coins.Remove(this); - } - } -} |
