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

public class JetPackScript : MonoBehaviour {

    public Transform cloud;
    public float timer = 0;
    public float subtimer = 0;

    // Use this for initialization
    void Start () {
        if (PlayerPrefs.GetInt("HasPack") == 0) Destroy(gameObject);
    }

    // Update is called once per frame
    void Update () {
		if (timer > 0)
        {
            subtimer -= Time.deltaTime;
            timer -= Time.deltaTime;
            if (subtimer < 0)
            {
                subtimer = 0.05f;
                MakeCloud();
            }

        }
	}

    public void StartCloud() {
        timer = 1f;
    }

    public void MakeCloud()
    {
        Transform t = Instantiate(cloud, new Vector3(this.transform.position.x + Random.Range(-0.1f, 0.1f), this.transform.position.y - 0.2f, -3), Quaternion.identity);
        t.Rotate(new Vector3(0, 0, Random.Range(-90, 90)));
    }

}
