using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Eye : MonoBehaviour
{
    public float interval = 0.25f;
    public float chanceToWink = 0.1f;

    public Sprite eyeOpen;
    public Sprite eyeWink;
    public SpriteRenderer spriteRenderer;

    private float timer = 0;

    void Update() {
        timer += Time.deltaTime;
        if (timer >= interval) {
            timer -= interval;
            if (Random.value < chanceToWink) {
                spriteRenderer.sprite = eyeWink;
            } else {
                spriteRenderer.sprite = eyeOpen;
            }
        }
    }
}
