hellbound/Assets/Scripts/Game/UI/DailyRewardView.cs

81 lines
2.6 KiB
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using UnityEngine;
using UnityEngine.UI;
public class DailyRewardView : MonoBehaviour
{
[SerializeField] private Image _background = null;
[SerializeField] private Image _icon = null;
[SerializeField] private Text _message = null;
[SerializeField] private Text _time = null;
[Header("View")]
[SerializeField] private Sprite _defaultBackground = null;
[SerializeField] private Sprite _getBackground = null;
[SerializeField] private Sprite _currentBackground = null;
[SerializeField] private Sprite _lastDayBackground = null;
[SerializeField] private GameObject _newVFX = null;
[SerializeField] private GameObject _receivedMarker = null;
[Header("Colours")]
[SerializeField] private Color32 _defaultColour = default;
[SerializeField] private Color32 _currentColour = default;
[SerializeField] private Color32 _getColour = default;
[SerializeField] private Color32 _lastDayColour = default;
public void SetItemView(Sprite icon, string timeMessage)
{
_icon.sprite = icon;
_message.text = string.Empty;
_message.color = _defaultColour;
_background.sprite = _defaultBackground;
_time.text = timeMessage;
_time.color = _defaultColour;
}
public void SetReceivedView()
{
_message.gameObject.SetActive(false);
_time.color = _getColour;
_background.sprite = _getBackground;
_receivedMarker.SetActive(true);
}
public void SetNewView()
{
_icon.gameObject.SetActive(true);
_message.gameObject.SetActive(true);
_message.color = _defaultColour;
_time.color = _currentColour;
_background.sprite = _currentBackground;
_newVFX.SetActive(true);
_receivedMarker.SetActive(false);
}
public void ChangeBackground(BackgroundEnum bgr)
{
switch (bgr)
{
case BackgroundEnum.DEFAULT:
_background.sprite = _defaultBackground;
_time.color = _defaultColour;
break;
case BackgroundEnum.RECEIVED:
_background.sprite = _getBackground;
_message.gameObject.SetActive(false);
_receivedMarker.SetActive(true);
_time.color = _getColour;
break;
case BackgroundEnum.LAST_DAY:
_background.sprite = _lastDayBackground;
_time.color = _lastDayColour;
break;
}
}
public enum BackgroundEnum
{
DEFAULT,
RECEIVED,
LAST_DAY
}
}