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

public class BoostRocketScript : MonoBehaviour {

	public RacerScript racer;
	public KartController kart;
	public bool called = false;

	// Start is called before the first frame update
	void Start() {

	}

	// Update is called once per frame
	void Update() {
		if (Input.GetKeyDown (KeyCode.LeftShift) || Input.GetKeyDown (KeyCode.RightShift)) {
			if (!called) {
				called = true;
				racer.itemCanvas.itemActivated = true;
				if (kart) {
					kart.CallBlur ();
				}
				StartCoroutine (BoostKart ());
			}
		}
	}

	IEnumerator BoostKart () {
		racer.kart.acceleration += 100f;
		yield return new WaitForSeconds (3f);
		racer.kart.acceleration -= 100f;
		called = false;
		racer.SetActiveItem (-1);
	}
	/*
	public IEnumerator BoostBlur () {
		lapSounds.PlayOneShot (rocketBoost);
		boostVisual.Play ();
		if (postProfile) {
			postProfile.GetSetting<LensDistortion> ().intensity.value = -45;
			postProfile.GetSetting<MotionBlur> ().enabled.value = true;
		}
		float t = 0f;
		engineEffect = 1.5f;//(driftMode == 3) ? 1.5f : (driftMode == 2) ? 1.25f : 1f;
		while (t < 1) {
			t += Time.deltaTime;
			engineEffect = Mathf.Lerp (engineEffect, 0f, t);
			yield return null;
		}
		boostCalled = false;
		t = 0f;
		if (postProfile) {
			float currentInt = postProfile.GetSetting<LensDistortion> ().intensity.value;
			while (t < 1) {
				if (boostCalled) {
					postProfile.GetSetting<LensDistortion> ().intensity.value = -45;
					yield break;
				}
				if (t > 0.5f) {
					postProfile.GetSetting<MotionBlur> ().enabled.value = false;
					Debug.Log ("finalHit");
				}
				t += Time.deltaTime;
				postProfile.GetSetting<LensDistortion> ().intensity.Interp (currentInt, 0, t);
				yield return null;
			}
		}
		canReset = true;

		yield return null;

	}
	*/
}
