﻿using UnityEngine;
using System.Collections;

public class GhostSceneManager : MonoBehaviour
{
    [SerializeField]Animator playerAnimator;
    public bool summoning;
    public float summoningTime;
    public bool idle;
    public int itensTaken;
    public float timeToChangeScene;

    void Awake()
    {
        summoning = true;
        TakeItem();
    }

    void Update()
    {
        PlayerAnimHandle();
        timeToChangeScene -= Time.deltaTime;
        if (timeToChangeScene <= 0 || Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Horizontal") != 0)
        {
            //Application.LoadLevel("Cena da fase");
        }
    }


    void TakeItem()
    {
        PlayerPrefs.SetInt("GhostItens", playerAnimator.gameObject.GetComponent<Inventory>().qtd);
        playerAnimator.gameObject.GetComponent<Inventory>().qtd = 0;
    }

    void PlayerAnimHandle()
    {
        if (summoning)
        {
            summoningTime -= Time.deltaTime;
            if (summoningTime <= 0)
            {
                summoning = false;
            }
        }
        playerAnimator.SetBool("summoning", summoning);
    }
}
