You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/Compliment.cs

69 lines
1.0 KiB
C#

2 months ago
/*
http://www.cgsoso.com/forum-211-1.html
CG Unity3d Unity3d VIP
CGSOSO CG
daily assets update for try.
U should buy the asset from home store if u use it in your project!
*/
using UnityEngine;
using UnityEngine.UI;
public class Compliment : MonoBehaviour
{
public enum Type
{
None,
Amazing,
Good,
Welldone
}
public Animator anim;
public SpriteRenderer sRenderer;
public Sprite[] sprites;
public Text complimentText;
public static Compliment instance;
private void Awake()
{
instance = this;
}
public void Show(Type type)
{
if (IsAvailable2Show())
{
sRenderer.sprite = sprites[(int)(type - 1)];
anim.SetTrigger("show");
}
}
public void ShowRandom()
{
if (IsAvailable2Show())
{
sRenderer.sprite = CUtils.GetRandom(sprites);
anim.SetTrigger("show");
}
}
private bool IsAvailable2Show()
{
return anim.GetCurrentAnimatorStateInfo(0).IsName("Idle");
}
}