rabidus-test/Assets/Scripts/MonumentController.cs

49 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class MonumentController : MonoBehaviour
{
[SerializeField]
private float _energyToUnlock;
[SerializeField]
private MonumentInfo _info;
private ScoreController _scoreController;
private MonumentPreviewSound _previewSound;
private MonumentPreview _monumentPreview;
public UnityEvent OnUnlock;
private void Awake()
{
_monumentPreview = FindObjectOfType<MonumentPreview>();
_previewSound = GetComponent<MonumentPreviewSound>();
_scoreController = FindObjectOfType<ScoreController>();
}
[ContextMenu("Debug Unlock")]
public void UnlockMonument()
{
OnUnlock?.Invoke();
//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);
PlayerSetup.Instance.UnlockMonument(_info);
}
[ContextMenu("Show preview")]
public void ShowPreview()
{
_previewSound.PlaySound(_info.LongClip);
_monumentPreview.ShowInfo(_info.Name, _info.Image, _info.Description, _info.LongDuration);
}
}