IEnumerator DistancesInSecs(GameObject obj, Vector3 start, List <Vector3> points) { float sumDist = SumDistance(); obj.transform.position = start; float subDist = 0f; float time = 1.1f; int count = spline.GetPointCount(); obj.GetComponent <DaSiTrainScript>().Run(); for (int i = 0; i < count; i++) { if (i < count - 1) { subDist = Mathf.Abs(Vector3.Distance(spline.GetPosition(i), spline.GetPosition(i + 1))); time = (subDist / sumDist) * 1.1f; } while (Mathf.Abs(Vector3.Distance(obj.transform.position, spline.GetPosition(i) + startingPoint)) > Mathf.Epsilon) { obj.transform.position = Vector3.MoveTowards(obj.transform.position, spline.GetPosition(i) + startingPoint, (subDist / time) * Time.deltaTime); yield return(new WaitForEndOfFrame()); } } GameLoader.AddScore((int)Mathf.Clamp(obj.GetComponent <DaSiTrainScript>().NumHit(), 0f, 10f)); infoText.GetComponent <DaSiIntroScript>().GameOver(obj.GetComponent <DaSiTrainScript>().NumHit() >= 10); yield return(new WaitForSeconds(0.9f)); GameLoader.gameOn = false; }
void SetScoreText() { scoreText.text = "Cards Matched: " + score.ToString(); if (score == 6) { GameLoader.AddScore(10); winText.text = "You Win 10 Points!"; win.Play(); StartCoroutine(ByeAfterDelay(2)); } }
void OnCollisionEnter(Collision other) { if (other.gameObject.CompareTag("Alien")) { other.gameObject.SetActive(false); //Add one to the current value of our count variable. count = count + 1; // add a point to the game GameLoader.AddScore(1); //Update the currently displayed count by calling the SetCountText function. SetCountText(); } }
//OnTriggerEnter2D is called whenever this object overlaps with a trigger collider. void OnTriggerEnter2D(Collider2D other) { //Check the provided Collider2D parameter other to see if it is tagged "PickUp", if it is... if (other.gameObject.CompareTag("PickUp")) { other.gameObject.SetActive(false); //Add one to the current value of our count variable. count = count + 1; // add a point to the game GameLoader.AddScore(1); //Update the currently displayed count by calling the SetCountText function. SetCountText(); } }
private void Update() { if (timer > 0 && isAlive == true) { timer = timer - Time.deltaTime; } else if (timer <= 0 || isAlive == false) { int wholeTime = (int)timer; endText.text = "YOU SURVIVED FOR " + (10 - wholeTime) + " SECONDS!"; GameLoader.AddScore(wholeTime); StartCoroutine(ByeAfterDelay(2)); } }
//OnTriggerEnter2D is called whenever this object overlaps with a trigger collider. void OnTriggerEnter2D(Collider2D other) { //Check the provided Collider2D parameter other to see if it is tagged "PickUp", if it is... if (other.gameObject.CompareTag("PickUp")) { //... then set the other object we just collided with to inactive. other.gameObject.SetActive(false); } //Add one to the current value of our count variable. GameLoader.AddScore(1); count = count + 1; //Update the currently displayed count by calling the SetCountText function. SetCountText(); float vol = Random.Range(volLowRange, volHighRange); source.PlayOneShot(coins); }
// Update is called once per frame void Update() { //This does a timer before ending the game after 10 seconds. timer = timer + Time.deltaTime; if (timer >= 10 && incompletePhoneNumber == true) { endText.text = "You Lose!"; canMove = false; canPressU = false; GameLoader.AddScore(numberCount); StartCoroutine(ByeAfterDelay(2)); } //Checks if player has u held if (canMove == true && incompletePhoneNumber == true) { //Movement through array if (Input.GetKeyDown("up")) { if (row - 1 < 0) { row = 3; buttonArray[0, col].isNormal(); } else { row--; buttonArray[row + 1, col].isNormal(); } } if (Input.GetKeyDown("down")) { if (row + 1 > MAXROW) { row = 0; buttonArray[3, col].isNormal(); } else { row++; buttonArray[row - 1, col].isNormal(); } } if (Input.GetKeyDown("left")) { if (col - 1 < 0) { col = 2; buttonArray[row, 0].isNormal(); } else { col--; buttonArray[row, col + 1].isNormal(); } } if (Input.GetKeyDown("right")) { if (col + 1 > MAXCOL) { col = 0; buttonArray[row, 2].isNormal(); } else { col++; buttonArray[row, col - 1].isNormal(); } } } //Every frame, if u is held then current button is set to be pressed, or hilighted if not pressed //Stops players from moving if u is held //Gets value from current button if u is pressed if (Input.GetButton("u") && canPressU == true) { buttonArray[row, col].isPressed(); canMove = false; if (uHeld == false) { //Add to playerPhoneNumber strings barePlayerPhoneNumber += buttonArray[row, col].value; if (numberCount == 3) { displayPlayerPhoneNumber += ") "; } else if (numberCount == 6) { displayPlayerPhoneNumber += "-"; } displayPlayerPhoneNumber += buttonArray[row, col].value; inputNumText.text = displayPlayerPhoneNumber; //Check if current number is correct //If not, restart char playerTemp = barePlayerPhoneNumber[numberCount]; char randomTemp = bareGeneratedPhoneNumber[numberCount]; if (playerTemp != randomTemp) { music.PlayOneShot(buzz); displayPlayerPhoneNumber = "("; barePlayerPhoneNumber = ""; numberCount = 0; uHeld = false; return; } music.PlayOneShot(boop); numberCount++; uHeld = true; //Check victory at 10 characters if (numberCount == 10) { incompletePhoneNumber = false; canPressU = false; cthulhu.SetActive(true); particleSystem.Play(); music.PlayOneShot(victorySound); endText.text = "You Win!"; GameLoader.AddScore(numberCount); ByeAfterDelay(2); } } } else { buttonArray[row, col].isHilighted(); canMove = true; uHeld = false; } //Escape if (Input.GetKey("escape")) { Application.Quit(); } }
public void AddScore() { Debug.Log("more points"); GameLoader.AddScore(1); }