void Update() { if (nodeDeletionTime > 0) { nodeDeletionTime -= Time.deltaTime; foreach (GameObject node in nodesToBeDeleted) { node.GetComponentInChildren <Renderer>().material.SetFloat("_Metallic", maxNodeDeletionTime - nodeDeletionTime); } } else { for (int i = nodesToBeDeleted.Count - 1; i >= 0; i--) { GameObject node = nodesToBeDeleted[i]; Vector3 pos = node.transform.position; string nodeName = node.name.Replace("(Clone)", "").Trim().ToLower(); int index = Planets[nodeName]; if (RotationController.movesLeft != 20) { planetsLeft[index] = Mathf.Max(0, planetsLeft[index] - 1); texts[index].text = "x" + planetsLeft[index]; } Destroy(node); plopSound.Play(); MainController.instance.NewNode(pos); } bool gameWon = true; foreach (int left in planetsLeft) { if (left > 0) { gameWon = false; } } if (gameWon) { if (!ended) { ended = true; endGame.End(true); currentLevel++; } } if (nodesToBeDeleted.Count > 0) { StartCoroutine(LateCheck()); } nodesToBeDeleted.Clear(); } }
private void OnCollisionEnter2D(Collision2D collision) { Debug.Log("1"); if (collision.gameObject.CompareTag("Pipe")) { print("2"); isDead = true; FindObjectOfType <Score> ().OnDeath(); //FindObjectOfType <EndGame> ().End(); endGame.End(); } }
// wait for a few seconds, and if the players are still kissing then don't end the game, otherwise end IEnumerator waitThenEnd() { gameEnded = true; yield return(new WaitForSeconds(5f)); if (!isKissing) { end.End(); } else { gameEnded = false; } }
private void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("Death")) { anim.SetTrigger("Dead"); StartCoroutine("Death"); } if (col.CompareTag("End Game Trigger")) { anim.SetTrigger("Grounded"); this.enabled = false; anim.SetFloat("Speed", Mathf.Abs(0)); rb.velocity = Vector2.zero; endGame.End(); } if (col.CompareTag("Coins")) { coinSound.Play(); Destroy(col.gameObject); } }
private void EndGame() { Debug.LogWarning("EndGame" + "\nDishedCount: " + customersController.CountDished); endGame.End(customersController.GivedDishes, customersController.CountDished - 2); }
// Update is called once per frame void Update() { if (rotTimeLeft > 0) { foreach (GameObject go in filteredObjects) { go.transform.position = rot * go.transform.position; } rotTimeLeft--; } else if (rotTimeLeft == 0 && !isChecked) { CheckMatch.CheckAllNodes(); isChecked = true; } else if (CheckMatch.nodesToBeDeleted.Count == 0 && movesLeft > 0) { if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Vector3 pos = hit.transform.position; hitPos = hit.point; x = Mathf.RoundToInt(pos.x); y = Mathf.RoundToInt(pos.y); z = Mathf.RoundToInt(pos.z); mousePos = Input.mousePosition; } else { x = 0; y = 0; z = 0; } } if (Input.GetKeyUp(KeyCode.Mouse0)) { Vector2 newMousePos = Input.mousePosition; if (Vector2.Distance(newMousePos, mousePos) > 32) { if (x != 0 || y != 0 || z != 0) { Vector3 dragDir = Camera.main.transform.TransformDirection(newMousePos - mousePos); Vector3 hitDir = getGeneralDirection(hitPos); Vector3 axis = Vector3.Cross(dragDir, hitDir); axis = getGeneralDirection(axis); Rotate(x, y, z, axis); filteredObjects.Clear(); float E = 0.1f; foreach (GameObject go in MainController.allObjects) { if (axis.x != 0 && Mathf.Abs(go.transform.position.x - x) < E) { filteredObjects.Add(go); } else if (axis.y != 0 && Mathf.Abs(go.transform.position.y - y) < E) { filteredObjects.Add(go); } else if (axis.z != 0 && Mathf.Abs(go.transform.position.z - z) < E) { filteredObjects.Add(go); } } x = 0; y = 0; z = 0; } } } } if (CheckMatch.nodesToBeDeleted.Count == 0 && movesLeft == 0) { endGame.End(false); } }