2023-07-28 11:48:57 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2023-10-20 13:29:44 +03:00
|
|
|
using UnityEngine.Events;
|
2023-07-28 11:48:57 +03:00
|
|
|
|
|
|
|
public class MonumentController : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private float _energyToUnlock;
|
|
|
|
[SerializeField]
|
2023-08-07 13:23:18 +03:00
|
|
|
private MonumentInfo _info;
|
2023-08-22 15:41:12 +03:00
|
|
|
|
2023-07-28 11:48:57 +03:00
|
|
|
private EnergyController _energyController;
|
|
|
|
private float _currentEnergy;
|
2023-08-22 15:41:12 +03:00
|
|
|
private ScoreController _scoreController;
|
2023-08-15 17:38:54 +03:00
|
|
|
private CockpitUIModule _cockpitUI;
|
2023-10-23 11:19:20 +03:00
|
|
|
private MonumentPreviewSound _previewSound;
|
2023-10-24 14:34:33 +03:00
|
|
|
private MonumentPreview _monumentPreview;
|
2023-08-07 13:23:18 +03:00
|
|
|
|
2023-10-20 13:29:44 +03:00
|
|
|
public UnityEvent OnUnlock;
|
|
|
|
|
2023-07-28 11:48:57 +03:00
|
|
|
private void Awake()
|
|
|
|
{
|
2023-10-24 14:34:33 +03:00
|
|
|
_monumentPreview = FindObjectOfType<MonumentPreview>();
|
2023-10-30 13:54:38 +03:00
|
|
|
_previewSound = GetComponent<MonumentPreviewSound>();
|
2023-08-22 15:41:12 +03:00
|
|
|
_scoreController = FindObjectOfType<ScoreController>();
|
2023-08-15 17:38:54 +03:00
|
|
|
_cockpitUI = FindObjectOfType<CockpitUIModule>();
|
2023-07-28 11:48:57 +03:00
|
|
|
_energyController = FindObjectOfType<EnergyController>();
|
|
|
|
_currentEnergy = _energyToUnlock;
|
|
|
|
}
|
|
|
|
|
2023-10-20 13:29:44 +03:00
|
|
|
[ContextMenu("Debug Unlock")]
|
2023-07-28 11:48:57 +03:00
|
|
|
public void UnlockMonument()
|
|
|
|
{
|
2023-10-20 13:29:44 +03:00
|
|
|
OnUnlock?.Invoke();
|
2023-10-24 11:14:23 +03:00
|
|
|
//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}");
|
|
|
|
//});
|
|
|
|
_scoreController.AddScore(_info.Score, false, false);
|
2023-08-15 17:38:54 +03:00
|
|
|
PlayerSetup.Instance.UnlockMonument(_info);
|
|
|
|
}
|
|
|
|
|
2023-10-27 17:29:01 +03:00
|
|
|
[ContextMenu("Show preview")]
|
2023-10-23 12:07:14 +03:00
|
|
|
public void PlaySound()
|
|
|
|
{
|
|
|
|
_previewSound.PlaySound(_info.LongClip);
|
2023-10-30 12:23:06 +03:00
|
|
|
//_monumentPreview.ShowInfo(_info.Name, _info.Image, _info.LongDescription, _info.LongDuration);
|
2023-10-23 12:07:14 +03:00
|
|
|
}
|
|
|
|
|
2023-10-27 17:29:01 +03:00
|
|
|
|
2023-08-15 17:38:54 +03:00
|
|
|
public void ShowPreview()
|
|
|
|
{
|
|
|
|
_cockpitUI.ShowInfo(_info.Image, _info.Description);
|
2023-07-28 11:48:57 +03:00
|
|
|
}
|
|
|
|
}
|