using UnityEngine;
using System.Collections;

public class CameraShake : MonoBehaviour {
    Vector3 originPosition;
    Quaternion originRotation;
    public float shakeIntensity;

    void Start()
    {
       originPosition = transform.position;
       originRotation = transform.localRotation;
        shakeIntensity = 0;
    }

    void Update()
    {
        if (shakeIntensity > 0)
        {
            Vector2 shakeVec = Random.insideUnitCircle;
            Vector3 shakeVec3 = new Vector3(shakeVec.x, shakeVec.y, 0);
            transform.localPosition = originPosition + shakeVec3 * shakeIntensity;

            shakeIntensity -= Time.deltaTime;
           /* transform.localRotation = new Quaternion(
            originRotation.x + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.y + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.z + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.w + Random.Range(-shakeIntensity, shakeIntensity) * .2f);*/
            /*transform.position = originPosition + Random.insideUnitSphere * shakeIntensity;
            transform.rotation = new Quaternion(
            originRotation.x + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.y + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.z + Random.Range(-shakeIntensity, shakeIntensity) * .2f,
            originRotation.w + Random.Range(-shakeIntensity, shakeIntensity) * .2f);*/
        }
    }

}
