﻿using UnityEngine;
using System.Collections;

public class randomMove : MonoBehaviour {


    moveControler m_move;


    IEnumerator DoIt()
    {
        yield return new WaitForSeconds(1);
        while (this.gameObject.activeInHierarchy)
        {


            float n = Random.Range(1.0f, 3.0f);
            Vector3 v1 = new Vector3();
            v1.x = Random.Range(-1.0f, 1.0f);
            v1.z = Random.Range(-1.0f, 1.0f);
            v1.Normalize();
            m_move.MoveTowardsDirection(v1);
            yield return new WaitForSeconds(n);
            n = Random.Range(1.0f, 3.0f);
            m_move.ToIdleState();

            yield return new WaitForSeconds(n);
        }
        yield return new WaitForSeconds(0);
    }
	// Use this for initialization
	void Start () {
        m_move = GetComponent<moveControler>();

        StartCoroutine(DoIt());
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
