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

public class PlayerControls : MonoBehaviour {
    public GameManager gm;
    public PlayerManager pm;
    public EnemyManager em;
    public HoneyJar hj;
    public bool Cheat = false;
    public float forceMultiplier;
    public SplashScript ss;
    private bool creditsActive = false;

	// Update is called once per frame
	void Update () {
        if(Input.GetKeyDown(KeyCode.Escape))
        {
            //Debug.Log("Exiting Game");
            Application.Quit();
        }

        if (gm.lostGame)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                //Debug.Log("Exiting Game");
                Application.Quit();
            }
            return;
        }

        if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
        {
            if(creditsActive)
            {
                toggleCredits();
            }
            else
            {
                ss.PassBeginScreen();
                pm.ProcessHit();
            }
        }

        if(Cheat)
        {
            // Force to move right, big jump
            if (Input.GetKeyDown(KeyCode.Q))
                hj.Hit(true, 100 * forceMultiplier, "Bee");

            // Force to move right, small jump
            else if (Input.GetKeyDown(KeyCode.W))
                hj.Hit(true, 100 * (forceMultiplier/5), "Bee");

            // Force to move Left, small jump
            else if (Input.GetKeyDown(KeyCode.E))
                hj.Hit(false, 100 * (forceMultiplier/5), "Fly");

            // Force to move left, big jump
            else if (Input.GetKeyDown(KeyCode.R))
                hj.Hit(false, 100 * forceMultiplier, "Fly");
            else if(Input.GetKeyDown(KeyCode.M))
            {
                gm.sm.addPlayerHit(true);
            }
        }
    }

    public void toggleCredits()
    {
        creditsActive = gm.um.toggleCredits(creditsActive);
    }
}
