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); } }