- 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
48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
using RR.Common.Interfaces;
|
|
|
|
namespace RR.Game2D.Behaviour
|
|
{
|
|
[System.Serializable]
|
|
public class Health : MonoBehaviour
|
|
{
|
|
[SerializeField] private float maxHealth = 3;
|
|
[SerializeField] private float currentHealth;
|
|
private IDamageable _owner;
|
|
|
|
public float MaxHealth => maxHealth;
|
|
public float CurrentHealth => currentHealth;
|
|
|
|
public void SetOwner(IDamageable healthOwner)
|
|
{
|
|
_owner = healthOwner;
|
|
}
|
|
|
|
public void SetMaxHealth(float value)
|
|
{
|
|
maxHealth = value;
|
|
currentHealth = maxHealth;
|
|
}
|
|
|
|
public void TakeDamage(float amount)
|
|
{
|
|
currentHealth -= amount;
|
|
if (currentHealth <= 0)
|
|
{
|
|
_owner?.Die();
|
|
}
|
|
}
|
|
|
|
public void Heal(float amount)
|
|
{
|
|
currentHealth = Mathf.Min(currentHealth + amount, maxHealth);
|
|
}
|
|
|
|
public void ResetHealth()
|
|
{
|
|
currentHealth = maxHealth;
|
|
}
|
|
}
|
|
}
|