private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "DoorTrigger") { if (states.EndItemFound) { other.gameObject.GetComponent <TriggerDoor>().ActivateDoor(); } } else if (other.gameObject.tag == "MultipleDoorTrigger") { if (other.GetComponent <Renderer>().material.color != Color.red) { other.GetComponent <Renderer>().material.color = Color.red; } } else if (other.gameObject.tag == "BreakableTrigger") { other.gameObject.GetComponent <BreakDoorTrigger>().ActivateDoor(); } else if (other.gameObject.tag == "TrapTrigger") { TrapTimer tt = other.gameObject.GetComponent <TrapTimer>(); tt.StartTimer(); } }
// Use this for initialization void Start() { myTransform = this.transform; //Gets the trap position from the global timer timer = GameObject.FindGameObjectWithTag("Timer").GetComponent <TrapTimer>(); }
IEnumerator SpawnTraps(float spawnTime) { yield return(new WaitForSeconds(spawnTime)); if (_ativo) { if (trapCount < 4) { trapCount += 1; } else { trapCount = 4; } for (int i = 0; i < trapCount; i++) { if (trapPool.Count > 0) { //Instantiate(trap, GetRandomPositionInsidePoly(hexagonArray), Quaternion.identity); GameObject trapy = trapPool[0]; trapPool.Remove(trapy); trapy.transform.position = GetRandomPositionInsidePolyDistantFromPlayer(hexagonArray, 2f); trapy.SetActive(true); TrapTimer fpm = trapy.GetComponent <TrapTimer>(); fpm.StartTrap(); activeTrapPool.Add(trapy); } //Instantiate(trap, GetRandomPositionInsidePoly(hexagonArray), Quaternion.identity); //Vector3 randomPosition = GetRandomPosition(); //Debug.Log(ContainsPoint(hexagonArray, new Vector2(randomPosition.x, randomPosition.y))); //Debug.Log(new Vector2(randomPosition.x, randomPosition.y)); //Debug.Log(PointInPolygon(hexagonArray, new Vector2(randomPosition.x, randomPosition.y))); //Instantiate(trap, randomPosition, Quaternion.identity); } StartCoroutine(SpawnTraps(this.trapSpawnTime)); } }