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

public class GiroPlato : MonoBehaviour {

    public float turnspeed, currentTurnSpeed, timeSpin;
    private int[] speedArray = { -30, -20, -14, 0, 14, 20, 30 };

	// Use this for initialization
	void Start () {
        do
        {
            turnspeed = speedArray[Random.Range(0, speedArray.Length)];
        } while (turnspeed == 0);
        
        Invoke("ChangeSpeed", timeSpin);
    }
	
	// Update is called once per frame
	void Update () {
        currentTurnSpeed = Mathf.Lerp(currentTurnSpeed, turnspeed, Time.deltaTime);
        transform.Rotate(Vector3.up * currentTurnSpeed * Time.deltaTime);
	}

    private void ChangeSpeed()
    {
        turnspeed = speedArray[Random.Range(0, speedArray.Length)];
        Invoke("ChangeSpeed", timeSpin);
    }
}
