private void Start()
 {
     RightKey.DeActivateKey();
     UpKey.DeActivateKey();
     DownKey.DeActivateKey();
     LeftKey.DeActivateKey();
     RKey.DeActivateKey();
     GameManager.AddInfection(this);
 }
 private void EndGame()
 {
     gameCodes.Clear();
     gameStarted = false;
     RightKey.DeActivateKey();
     UpKey.DeActivateKey();
     DownKey.DeActivateKey();
     LeftKey.DeActivateKey();
     RKey.DeActivateKey();
 }
    public void OnTriggerExit2D(Collider2D collision)
    {
        Player p = collision.gameObject.GetComponent <Player>();

        if (p == null)
        {
            return;
        }
        entered = false;
        Debug.Log("Exited range of infection :(");
        Player.EnableCure(false);
        Player.UnSubscribePlayerKeyPressEvent(OnPlayerKeyPress);
        RightKey.DeActivateKey();
        UpKey.DeActivateKey();
        DownKey.DeActivateKey();
        LeftKey.DeActivateKey();
        RKey.DeActivateKey();
        if (gameStarted)
        {
            gameStarted = false;
        }
    }
    private IEnumerator MiniGameEnumeration()
    {
        currentCheck = KeyCode.None;
        float currentCooldown = GameProperties.GetCheckTime();

        while (gameStarted)
        {
            //get new check
            if (currentCheck == KeyCode.None)
            {
                currentCheck = gameCodes.Dequeue();
            }

            switch (currentCheck)
            {
            case KeyCode.UpArrow:
                RightKey.DeActivateKey();
                UpKey.ActivateKey();
                DownKey.DeActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.RightArrow:
                RightKey.ActivateKey();
                UpKey.DeActivateKey();
                DownKey.DeActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.DownArrow:
                RightKey.DeActivateKey();
                UpKey.DeActivateKey();
                DownKey.ActivateKey();
                LeftKey.DeActivateKey();
                RKey.DeActivateKey();
                break;

            case KeyCode.LeftArrow:
                RightKey.DeActivateKey();
                UpKey.DeActivateKey();
                DownKey.DeActivateKey();
                LeftKey.ActivateKey();
                RKey.DeActivateKey();
                break;
            }

            //start timer
            currentCooldown = GameProperties.GetCheckTime();

            while (currentFramePressed != currentCheck)
            {
                yield return(new WaitForEndOfFrame());

                currentCooldown -= Time.fixedDeltaTime;
                if (currentCooldown < 0)
                {
                    Debug.Log("FAIL");
                    EndGame();
                    yield break;
                }
            }

            currentCheck = KeyCode.None;
            //check if any left
            if (gameCodes.Count == 0)
            {
                Debug.Log("WIN");
                GameManager.RemoveInfection(this);
                transform.parent.GetComponent <SpriteRenderer>().enabled = false;
                Destroy(gameObject);
                yield break;
            }
        }
    }