54 lines
989 B
C#
54 lines
989 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FishNetStars : MonoBehaviour
|
|
{
|
|
public Sprite normalStarSprite;
|
|
|
|
public Sprite filledStarSprite;
|
|
|
|
public Sprite goldStarSprite;
|
|
|
|
public Image[] starsImage;
|
|
|
|
private bool isGoldStars;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
public void SetStarsByFishWeight(GameManager.FishSpecies fishSpecies, float weight)
|
|
{
|
|
float num = weight / GameManager.Instance.gameFish[(int)fishSpecies].maxWeight;
|
|
int num2 = Mathf.RoundToInt(num * 5f);
|
|
if (num > 0.9f)
|
|
{
|
|
isGoldStars = true;
|
|
GetComponent<Animator>().SetBool("isGlow", value: true);
|
|
}
|
|
for (int i = 0; i < starsImage.Length; i++)
|
|
{
|
|
if (i < num2)
|
|
{
|
|
if (isGoldStars)
|
|
{
|
|
starsImage[i].sprite = goldStarSprite;
|
|
starsImage[i].transform.parent.GetComponent<Image>().enabled = true;
|
|
}
|
|
else
|
|
{
|
|
starsImage[i].sprite = filledStarSprite;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
starsImage[i].sprite = normalStarSprite;
|
|
}
|
|
}
|
|
}
|
|
}
|