49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AchievementWidget : MonoBehaviour
|
|
{
|
|
public Text nameText;
|
|
|
|
public Text descriptionText;
|
|
|
|
public Image icon;
|
|
|
|
public Slider progressSlider;
|
|
|
|
private Achievement achievement;
|
|
|
|
public void SetSource(Achievement ach)
|
|
{
|
|
achievement = ach;
|
|
}
|
|
|
|
public void RefreshWidget()
|
|
{
|
|
if (achievement != null)
|
|
{
|
|
icon.sprite = ((!(achievement.icon != null)) ? AchievementManager.Instance.defaultIcon : achievement.icon);
|
|
icon.color = new Color(1f, 1f, 1f, (!achievement.isCompleted) ? 0.05f : 1f);
|
|
if (achievement.fishSpieces == Fish.Species.COUNT)
|
|
{
|
|
nameText.text = Utilities.GetTranslation("ACHIEVEMENTS/" + achievement.nameId + "_NAME");
|
|
descriptionText.text = Utilities.GetTranslation("ACHIEVEMENTS/" + achievement.descriptionId + "_DESC");
|
|
}
|
|
else
|
|
{
|
|
string translation = Utilities.GetTranslation(GlobalSettings.Instance.fishManager.GetFishDefinition(achievement.fishSpieces).fishPrefab.fishName);
|
|
nameText.text = translation;
|
|
descriptionText.text = Utilities.GetTranslation("ACHIEVEMENTS/FISH_CATCH_01_DESC") + ": " + translation;
|
|
}
|
|
progressSlider.gameObject.SetActive(achievement.progressGoal > 0 && !achievement.isCompleted);
|
|
if (achievement.progressGoal > 0 && !achievement.isCompleted)
|
|
{
|
|
progressSlider.minValue = 0f;
|
|
progressSlider.maxValue = achievement.progressGoal;
|
|
progressSlider.value = achievement.progressCurrent;
|
|
progressSlider.fillRect.gameObject.SetActive(achievement.progressCurrent > 0);
|
|
}
|
|
}
|
|
}
|
|
}
|