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

public class PlayerDisease : MonoBehaviour
{

    public bool hasDisease;
    public PlayerDisease otherPlayer;
    public float maxTimer;
    private float currentTimer;
    public string inputName;
    public GameObject diseaseSmall;
    public GameObject diseaseBig;
    public GameObject readyToTransmit;

    public bool canShoot = true;
    // Use this for initialization
    void Start()
    {
        currentTimer = maxTimer;
    }

    // Update is called once per frame
    void Update()
    {
        if (hasDisease == true)
        {
            currentTimer -= Time.deltaTime;
            if (currentTimer <= 0)
            {
                canShoot = false;

                diseaseSmall.SetActive(false);
                readyToTransmit.SetActive(true);
                if (Input.GetButtonDown(inputName))
                {
                    Transmit();
                }



                //Disease starts hitting here
            }
            else
            {
                diseaseSmall.SetActive(true);
                if (Input.GetButtonDown(inputName))
                {
                    Penalty();
                }
            }
        }
    }

    public void Transmit()
    {
        if (otherPlayer != null)
        {
            currentTimer = maxTimer;
            readyToTransmit.SetActive(false);
            diseaseBig.SetActive(false);
            diseaseSmall.SetActive(false);
            hasDisease = false;
            otherPlayer.hasDisease = true;
            otherPlayer.gameObject.GetComponent<PlayerHealth>().ModifyHealth(10);
            canShoot = true;
        }
    }
    public void Penalty()
    {
        //this.gameObject.GetComponent<PlayerHealth>().ModifyHealth(-5, true);
        //Gotta figure this one out
    }
}
