void OnTriggerExit2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("goal"))
     {
         //Time.timeScale = 0;
         bar.SetActive(false);
         slider.SetActive(false);
         miniEnable = false;
         Miss1.SetActive(false);
         Miss2.SetActive(false);
         Miss3.SetActive(false);
         img0.SetActive(false);
         img1.SetActive(false);
         img2.SetActive(false);
         img3.SetActive(false);
         img4.SetActive(false);
         img5.SetActive(false);
     }
     if (other.gameObject.CompareTag("start"))
     {
         isDetectable = true;
     }
     if (other.gameObject.CompareTag("Shady Merchant"))
     {
         gameMessage.text = "Steal the test answers: " + successCount.ToString() + "/" + successLimit.ToString();
         portrait.SetActive(false);
     }
 }
 void missCounter(int misses)
 {
     if (misses == 1)
     {
         Miss1.SetActive(true);
     }
     if (misses == 2)
     {
         Miss2.SetActive(true);
     }
     if (misses == 3)
     {
         Miss3.SetActive(true);
     }
 }
    void Slider(bool stop)
    {
        float leftZone  = 2.274f;
        float rightZone = 2.5f;

        bar.SetActive(true);
        slider.SetActive(true);
        RectTransform rectT      = bar.GetComponent <RectTransform> ();
        float         leftBound  = bar.transform.position.x - rectT.rect.width / 2;
        float         rightBound = bar.transform.position.x + rectT.rect.width / 2;
        Vector3       start      = bar.transform.position;
        Vector3       curPos     = slider.transform.position;

        goalCounter(goal.goalCount);
        missCounter(missedCount);

        if (goal.goalCount < 5)
        {
            if (!stop)
            {
                if (slider.transform.position.x > leftBound && direction == Vector3.left)
                {
                    curPos.x -= sliderSpeed * Time.deltaTime;
                    slider.transform.position = curPos;
                }
                else if (slider.transform.position.x < leftBound)
                {
                    direction = Vector3.right;
                    slider.transform.position = new Vector3((leftBound + .003f), 0.3f, 0);
                }
                if (slider.transform.position.x < rightBound && direction == Vector3.right)
                {
                    curPos.x += sliderSpeed * Time.deltaTime;
                    slider.transform.position = curPos;
                }
                else if (slider.transform.position.x > rightBound)
                {
                    direction = Vector3.left;
                    slider.transform.position = new Vector3((rightBound - .003f), (.3f - .223103f), 0);
                }
            }
            else if (slider.GetComponent <RectTransform> ().position.x >= leftZone && slider.GetComponent <RectTransform> ().position.x <= rightZone)
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    successCount++;
                    goal.goalCount++;
                    Ding.Play();

                    /*if (successCount == 5) {
                     *             img4.SetActive (false);
                     *             img5.SetActive (true);
                     *             img6.SetActive (true);
                     *     }*/
                    //Time.timeScale = 0;
                    sliderSpeed     += .1f;
                    gameMessage.text = "Steal the test answers: " + goal.goalCount.ToString() + "/" + successLimit.ToString();
                }
            }
            else if (!(slider.GetComponent <RectTransform> ().position.x >= leftZone && slider.GetComponent <RectTransform> ().position.x <= rightZone))
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    missedCount++;
                    progressTimer.text = missedCount.ToString();
                    Error.Play();
                }
                if (missedCount >= missedLimit)
                {
                    ComputerController c = GameObject.Find("Prefect_0").GetComponent <ComputerController> ();
                    c.isAlerted    = true;
                    goal.isAlerted = true;
                    Detected.Play();
                    //activate GameObject for exclamation point over Smart Kid
                    for (int i = 0; i < alerts.Length; i++)
                    {
                        SpriteRenderer sp = alerts [i].GetComponent <SpriteRenderer> ();
                        sp.enabled = true;
                    }
                }
            }
        }
        else
        {
            //goalCount = 0;
            miniEnable = false;
            bar.SetActive(false);
            slider.SetActive(false);
            Miss1.SetActive(false);
            Miss2.SetActive(false);
            Miss3.SetActive(false);
        }
    }
    void KeyNotePress(Vector3 mouse)
    {
        Ray        castPoint = Camera.main.ScreenPointToRay(mouse);
        RaycastHit hit;

        if (Physics.Raycast(castPoint, out hit, Mathf.Infinity))
        {
            Vector3 touchLocation = hit.point;
            touchLocation.y = GameObject.FindGameObjectWithTag("Player").transform.position.y;
            GameObject closestEnemy = FindClosestEnemy();
            if (closestEnemy != null)
            {
                float differenceX = touchLocation.x - closestEnemy.transform.position.x;
                float differenceY = touchLocation.y - closestEnemy.transform.position.y;


                Vector3 diff        = closestEnemy.transform.position - touchLocation;
                float   curDistance = diff.sqrMagnitude;

                //if close to not (within 1.5)
                if (curDistance < 2f && closestEnemy != null)
                {
                    MusicInfront.mute = false;
                    HitSlash.Play();
                    Camera.main.GetComponentInChildren <ScoreHandler>().AddStreak(1f);
                    Instantiate(ParticleExplosion, closestEnemy.transform.position, Quaternion.Euler(Vector3.up));
                    LineRenderer.GetComponent <LineAnimator>().HitEvent();


                    int playerHealth = gameObject.GetComponentInChildren <PlayerHealthController>().HealthValue;
                    if (playerHealth > 0)
                    {
                        gameObject.GetComponentInChildren <PlayerHealthController>().HealthValue -= 1;
                    }

                    //perfect hit range
                    if (curDistance < 1f)
                    {
                        HitRatingText.text = "PERFECT";
                    }
                    else
                    {
                        {
                            //if note is in front, early
                            if (closestEnemy.transform.position.y > touchLocation.y)
                            {
                                HitRatingText.text = "EARLY";
                            }
                            //if note is behind, late
                            if (closestEnemy.transform.position.y < touchLocation.y)
                            {
                                HitRatingText.text = "LATE";
                            }
                        }
                    }
                    Destroy(closestEnemy.GetComponent <HitModifier>()._hitMarkerCreated);
                    Destroy(closestEnemy.GetComponent <HitModifier>()._hitMarkerCreatedInner);
                    Destroy(closestEnemy);
                }
                else
                {
                    int choice = Random.Range(1, 2);
                    switch (choice)
                    {
                    case 1:
                        Miss.Play();
                        break;

                    case 2:
                        Miss2.Play();
                        break;
                    }
                    Camera.main.GetComponentInChildren <ScoreHandler>().DestroyMultiplier();
                    Camera.main.GetComponentInChildren <ScoreHandler>().Streak = 0f;
                    Camera.main.GetComponentInChildren <ScoreHandler>().DestroyStreak();
                }
            }
        }
    }