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

public class ToggleBigLever : MonoBehaviour {
	public bool Right = true;
	public Sprite[] Frame = new Sprite[8];
	public GameObject Handle;

	protected float accumulator = 0f;
	protected bool IsAnimated = false;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	public void Clicked() {
		Right = !Right;
		StartCoroutine("Animate");
	}

	public IEnumerator Animate() {
		if(Right)
		{
			for(int i = 7; i >= 0; i--) {
				Handle.GetComponent<Image>().sprite = Frame[i];
				yield return new WaitForSeconds(0.02f);
			}
		} else {
			for(int i = 0; i <= 7; i++) {
				Handle.GetComponent<Image>().sprite = Frame[i];
				yield return new WaitForSeconds(0.02f);
			}
		}
	}
}
