using SHADE; using System; public class Item : Script { public enum ItemCategory { LIGHT, MEDIUM, HEAVY } public int Score = 10; public ItemCategory currCategory; public bool returnBack { get; set; } private Transform transform; private bool playSound = false; private bool caputurePos = false; public Vector3 firstPostion; protected override void awake() { transform = GetComponent(); returnBack = false; } protected override void update() { if (returnBack) { transform.LocalPosition = firstPostion; returnBack = false; } } protected override void onCollisionEnter(CollisionInfo info) { if (!caputurePos) { firstPostion = transform.LocalPosition; caputurePos = true; } if (playSound) { if(currCategory == ItemCategory.LIGHT) Audio.PlaySFXOnce2D("event:/Props/impact_elastic"); else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY) Audio.PlaySFXOnce2D("event:/Props/impact_hard"); playSound = false; } } protected override void onCollisionExit(CollisionInfo info) { playSound = true; } }