using UnityEngine;

public class MarchingRitual : Ritual
{

    public int shortestMarch = 40; // frames
    public int longestMarch = 80; // frames
    public int shortestStop = 40; // frames
    public int longestStop = 80; // frames

    private bool marching;
    private int framesBeforeChange;

    // Use this for initialization
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (framesBeforeChange > 0)
        {
            framesBeforeChange--;
        }
        else
        {
            marching = !marching;
            if (marching)
            {
                Monk.Direction dir = Monk.Direction.None;
                switch (Random.Range(0, 4))
                {
                    case 0:
                        dir = Monk.Direction.Left;
                        break;
                    case 1:
                        dir = Monk.Direction.Right;
                        break;
                    case 2:
                        dir = Monk.Direction.Up;
                        break;
                    case 3:
                        dir = Monk.Direction.Down;
                        break;
                }
                GetComponent<Monk>().Move(dir);
                framesBeforeChange = Random.Range(shortestMarch, longestMarch);
            }
            else
            {
                GetComponent<Monk>().Stop();
                framesBeforeChange = Random.Range(shortestStop, longestStop);
            }
        }
    }

}