using UnityEngine;
using System.Collections;

public class MarksScript : MonoBehaviour {

    public float[] _durations;

    private Animator _animator;
    private SpriteRenderer _spriteRenderer;
    private float _time = 0;
    private bool _animating = false;
    private int _state;

	// Use this for initialization
	void Start () {
        _animator = GetComponent<Animator>();
        _spriteRenderer = GetComponent<SpriteRenderer>();
	}
	
	// Update is called once per frame
	void Update () {
	    
        if (_animating && _state != 0)
        {
            _time += Time.deltaTime;

            if (_time >= _durations[_state])
            {
                _time = 0;
                setMarkAnimation(0);
            }
        }

	}

    public void setMarkAnimation(int state)
    {
        _state = state;

        if (state == 0)
        {
            _spriteRenderer.enabled = false;
        }
        else
        {
            _spriteRenderer.enabled = true;
            _animator.SetInteger("State", state);
            _animating = true;
        }
    }
}
