2023-07-28 11:48:57 +03:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class MonumentController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField]
|
|
|
|
|
private float _energyToUnlock;
|
|
|
|
|
[SerializeField]
|
2023-08-07 13:23:18 +03:00
|
|
|
|
private MonumentInfo _info;
|
2023-07-28 11:48:57 +03:00
|
|
|
|
private EnergyController _energyController;
|
|
|
|
|
private float _currentEnergy;
|
|
|
|
|
|
2023-08-15 17:38:54 +03:00
|
|
|
|
private CockpitUIModule _cockpitUI;
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
2023-07-28 11:48:57 +03:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2023-08-15 17:38:54 +03:00
|
|
|
|
_cockpitUI = FindObjectOfType<CockpitUIModule>();
|
2023-07-28 11:48:57 +03:00
|
|
|
|
_energyController = FindObjectOfType<EnergyController>();
|
|
|
|
|
_currentEnergy = _energyToUnlock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UnlockMonument()
|
|
|
|
|
{
|
|
|
|
|
var totalEnergy = _energyController.Energy;
|
|
|
|
|
|
2023-08-07 13:23:18 +03:00
|
|
|
|
LeanTween.value(totalEnergy, 0, 1).setEase(LeanTweenType.easeInOutSine).setOnUpdate((float x)=>
|
2023-07-28 11:48:57 +03:00
|
|
|
|
{
|
|
|
|
|
_energyController.Energy = x;
|
|
|
|
|
_currentEnergy = Mathf.Clamp(_energyToUnlock - (totalEnergy - x), 0, int.MaxValue);
|
|
|
|
|
Debug.Log($"Clamped energy value: {_currentEnergy / _energyToUnlock}");
|
|
|
|
|
});
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
|
|
|
|
//TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2023-08-15 17:38:54 +03:00
|
|
|
|
PlayerSetup.Instance.UnlockMonument(_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowPreview()
|
|
|
|
|
{
|
|
|
|
|
_cockpitUI.ShowInfo(_info.Image, _info.Description);
|
2023-07-28 11:48:57 +03:00
|
|
|
|
}
|
|
|
|
|
}
|