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

public class HoneyWave : MonoBehaviour {
    private IEnumerator MyCoRoutine;
    Button storeCloseButton;
    public bool runningAnimation = false;
    public GameManager gm;

    public void DoWaveAnimation()
    {
        Vector2 endPosition = new Vector2(transform.position.x - 90, transform.position.y);
        MyCoRoutine = DoMove(transform.position, endPosition, 2f);
        StartCoroutine(MyCoRoutine);
    }

    IEnumerator	DoMove(Vector2 startPosition, Vector2 endPosition, float time)
    {
        gm.um.buttons[6].interactable = false;
        runningAnimation = true;
        float elapsedTime = 0;
        while (elapsedTime < time)
        {
            transform.position = Vector2.Lerp(startPosition, endPosition, (elapsedTime / time));
            elapsedTime += Time.deltaTime;
            yield return new WaitForEndOfFrame();
        }

        transform.position = startPosition;
        runningAnimation = false;
        gm.um.buttons[6].interactable = true;
    }
}
