void OnTriggerEnter(Collider trigger) { if (trigger.tag == "hole" && trigger.transform.localScale.y > 0.1) { //if that collider is a branch turn off collision with it if (CurrentCollider != null) { if (CurrentCollider.tag == "branch") { Physics.IgnoreCollision(CL, CurrentCollider); } } } if (trigger.tag == "exit") { var uiScript = UIScore.GetComponent <uiScore>(); uiScript.addSavedUnit(); exitPoint exitPointScript = trigger.gameObject.GetComponent <exitPoint>(); exitPointScript.SpawnParticleEffect(transform.position); Destroy(gameObject); } if (trigger.tag == "killplane") { var uiScript = UIScore.GetComponent <uiScore>(); uiScript.addLostUnit(); Destroy(gameObject); } if (trigger.tag == "tunnel") { Debug.DrawRay(new Vector3(transform.position.x, transform.position.y + 0.125f, transform.position.z), MoveDir, Color.red, 0.5f); Ray ray = new Ray(new Vector3(transform.position.x, transform.position.y + 0.125f, transform.position.z), MoveDir); int layerMask = 1 << 9; RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit, 1.25f, layerMask)) { if (!_CollisionTimingCheck) { IgnoredCollider = hit.collider; Physics.IgnoreCollision(CL, IgnoredCollider); _CollisionTimingCheck = true; StartCoroutine(TimingCheck(0.05F)); } } } if (trigger.tag == "pickup") { var Pickup = trigger.GetComponent <AbilityPickup>(); _AbilityHandler.AddAbility(Pickup.Ability, Pickup.Count); Pickup.SpawnParticleEffect(); Destroy(trigger.gameObject); } }
public void resetGame() { GameObject[] agents = GameObject.FindGameObjectsWithTag("agent"); foreach (GameObject a in agents) { Destroy(a); } GameObject[] tunnels = GameObject.FindGameObjectsWithTag("tunnel"); foreach (GameObject t in tunnels) { Destroy(t); } GameObject[] holes = GameObject.FindGameObjectsWithTag("hole"); foreach (GameObject h in holes) { Destroy(h); } GameObject[] steps = GameObject.FindGameObjectsWithTag("step"); foreach (GameObject s in steps) { Destroy(s); } GameObject[] exitPoints = GameObject.FindGameObjectsWithTag("exit"); foreach (GameObject e in exitPoints) { exitPoint exitPointScript = e.GetComponent <exitPoint>(); exitPointScript.Reset(); } //respawn all the pickups RespawnPickups(); //reset abilities count var abilityScript = abilityHandler.GetComponent <abilityHandler>(); abilityScript.ResetUICount(); //reset score var scoreScript = gameObject.GetComponent <uiScore>(); scoreScript.resetScore(); scoreScript.startTimer(abilityScript.TimeLimit); //reset spawners GameObject[] spawners = GameObject.FindGameObjectsWithTag("spawner"); foreach (GameObject s in spawners) { spawner spawnerScript = s.GetComponent <spawner>(); if (spawnerScript) { spawnerScript.ResetSpawner(); } } if (!resultsScreen) { pauseGame(); } else { resultsScreen = false; resultsPanel.SetActive(false); abilityPanel.SetActive(true); star1.SetActive(false); star2.SetActive(false); star3.SetActive(false); nextButton.SetActive(false); resetButton2.SetActive(false); homeButton2.SetActive(false); pauseButton.SetActive(true); } }