using UnityEngine;
using UnityStandardAssets.ImageEffects;

public class EatShrooms : Button {

    [SerializeField] private Camera mainCam = null;

    private const float fadePitchTime = 3f;

    private const float fps = 10f;

    private static float pitch = 1f;

    private static Camera mainCamera = null;

    private static Vortex vortexCam = null;

    protected override void Start() {
        base.Start();
        vortexCam = mainCam.GetComponent<Vortex>();
    }

    protected override void DoActionUp() {
        base.DoActionUp();
        GetComponent<Renderer>().enabled = false;
        SoundManager.PlaySound("EatShrooms");
        InvokeRepeating("PitchMusic", 0, 1 / fps);
    }

    void PitchMusic() {
        pitch -= 1 / (FadeManager.fadeDurationStatic * fps);
        vortexCam.radius = Vector2.one * (1 - pitch) / 5f;
        SoundManager.ChangePitchMusic(pitch);
        if (pitch <= 0) {
            Sun.FadeToNight();
            CancelInvoke("PitchMusic");
            pitch = 1;
            SoundManager.ChangePitchMusic(pitch);
        }
    }
}
