39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MonumentController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float _energyToUnlock;
|
|
[SerializeField]
|
|
private MonumentInfo _info;
|
|
|
|
private PlayerSetup _playerSetup;
|
|
private EnergyController _energyController;
|
|
private float _currentEnergy;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
_playerSetup = FindObjectOfType<PlayerSetup>();
|
|
_energyController = FindObjectOfType<EnergyController>();
|
|
_currentEnergy = _energyToUnlock;
|
|
}
|
|
|
|
public void UnlockMonument()
|
|
{
|
|
var totalEnergy = _energyController.Energy;
|
|
|
|
LeanTween.value(totalEnergy, 0, 1).setEase(LeanTweenType.easeInOutSine).setOnUpdate((float x)=>
|
|
{
|
|
_energyController.Energy = x;
|
|
_currentEnergy = Mathf.Clamp(_energyToUnlock - (totalEnergy - x), 0, int.MaxValue);
|
|
Debug.Log($"Clamped energy value: {_currentEnergy / _energyToUnlock}");
|
|
});
|
|
|
|
//TODO: ÐÀÇÁËÎÊÈÐÎÂÀÒÜ ÌÎÍÓÌÅÍÒ ÒÎËÜÊÎ ÅÑËÈ ÕÂÀÒÈËÎ ÝÍÅÐÃÈÈ
|
|
_playerSetup.UnlockMonument(_info, _currentEnergy);
|
|
}
|
|
}
|