using UnityEngine;

public class Body : MonoBehaviour
{
    public Transform facePivot;
    public SpriteRenderer body;

    public Color[] bodyColors;
    public Sprite[] bodySprites;
    public string[] mAnimatorsType;

    public Animator highlightAnimator;

    [HideInInspector]
    public Animator animator;

    private void Awake()
    {
        this.animator = this.GetComponent<Animator>();
    }

    public void setBody()
    {
        this.body.sprite = this.sort(this.bodySprites);
        this.body.color = this.bodyColors[Random.Range(0, this.bodyColors.Length)];
        this.animator.Play(mAnimatorsType[Random.Range(0, this.mAnimatorsType.Length)]);
    }

    private Sprite sort(Sprite[] spriteList)
    {
        Sprite result = null;

        if (spriteList != null && spriteList.Length > 0)
        {
            result = spriteList[Random.Range(0, spriteList.Length)];
        }

        return result;
    }
}