- Increased SFX pool size from 8 to 16 in AudioManager - Enabled preloadAudioData for multiple SFX files - Removed unused VisualScripting import from Checkpoint script - Reordered using statements in several scripts for consistency - Added CoinCollectible component to Coin prefab with pickup effects - Updated sorting layers and mesh LOD settings in Coin prefabs - Fixed typo in Interfaces.cs: optionaAttachPoint to optionalAttachPoint - Modified AddCoin method to accept count parameter and handle coin overflow - Moved projectile scripts (BasicProjectile, EnemyBasicProjectile, PhysicsProjectile, PickableProjectile) - Cleaned up unused namespaces and imports across various scripts
35 lines
992 B
C#
35 lines
992 B
C#
using UnityEngine;
|
|
using UnityEngine.VFX;
|
|
|
|
using RR.Common.Interfaces;
|
|
using RR.Common.Audio;
|
|
using RR.Game2D.Core.Managers;
|
|
|
|
[RequireComponent(typeof(Collider2D))]
|
|
public class Collectible : MonoBehaviour, IPickable
|
|
{
|
|
[SerializeField] private SoundEffect pickupSFX;
|
|
[SerializeField] private VisualEffect pickupVFX;
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if (other.CompareTag("Player")) TryPickup(other.gameObject);
|
|
}
|
|
|
|
public virtual bool TryPickup(GameObject newOwner, Transform optionalAttachPoint = null)
|
|
{
|
|
if (pickupSFX.sound != null)
|
|
GameManager.Instance.Audio.PlaySfxAt(pickupSFX.sound, transform.position,
|
|
pickupSFX.volume, pickupSFX.pitch);
|
|
|
|
if (pickupVFX != null)
|
|
{
|
|
pickupVFX.transform.position = transform.position;
|
|
pickupVFX.Play();
|
|
pickupVFX.Stop();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|