first commit

This commit is contained in:
2026-06-04 21:37:43 +03:00
commit a6ea987b0d
152 changed files with 34059 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
using UnityEngine;
namespace OTG.Lab06.Core
{
public interface IDamageable
{
Transform Transform { get; }
bool IsAlive { get; }
void TakeDamage(float amount);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3f3e434b30daf3198c7069ec1b9dc34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+73
View File
@@ -0,0 +1,73 @@
using System;
using UnityEngine;
namespace OTG.Lab06.Core
{
[Serializable]
public sealed class ResourceStat
{
[SerializeField] private float maxValue = 100f;
[SerializeField] private float currentValue = 100f;
public event Action<float, float> Changed;
public float Current => currentValue;
public float Max => maxValue;
public float Normalized => maxValue <= 0f ? 0f : currentValue / maxValue;
public ResourceStat(float maxValue)
{
this.maxValue = Mathf.Max(1f, maxValue);
currentValue = this.maxValue;
}
public void Initialize(float value)
{
maxValue = Mathf.Max(1f, value);
currentValue = maxValue;
Changed?.Invoke(currentValue, maxValue);
}
public bool TrySpend(float amount)
{
if (amount <= 0f)
{
return true;
}
if (currentValue < amount)
{
return false;
}
SetCurrent(currentValue - amount);
return true;
}
public void Add(float amount)
{
if (amount <= 0f)
{
return;
}
SetCurrent(currentValue + amount);
}
public void Subtract(float amount)
{
if (amount <= 0f)
{
return;
}
SetCurrent(currentValue - amount);
}
private void SetCurrent(float value)
{
currentValue = Mathf.Clamp(value, 0f, maxValue);
Changed?.Invoke(currentValue, maxValue);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b3c84173aeb6f4b08a1a9e547f70a17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: