using UnityEngine; using System; namespace Fruitomation.Game { public class SpringBuilding : Building { [SerializeField] private TriggerDetector Trigger; private void Start() { Trigger.SetAction(other => { if (other.transform.parent.TryGetComponent(out Rigidbody2D body)) { Vector2 v0 = body.linearVelocity; float magnitude = Math.Max(v0.magnitude * 0.8f, 20f); Vector2 v1 = new Vector2(v0.x * 1.2f, Math.Abs(v0.y)).normalized * magnitude; body.linearVelocity = v1; } }, TriggerType.Enter); Trigger.SetAction(other => { if (other.transform.parent.TryGetComponent(out Rigidbody2D body)) { Vector2 v0 = body.linearVelocity; v0.y = Math.Max(1f, v0.y); body.linearVelocity = v0; } }, TriggerType.Stay); } } }