//All the puzzle pieces should have a trigger on them, when enter, this function will be called void OnTriggerEnter(Collider other) { //checks to see if the object in our trigger is a player. if (other.gameObject.tag == Constants.PLAYER_STRING) { //Increase the intesnity of the players point light PlayerLightController playerLight = other.gameObject.GetComponent <PlayerLightController>(); if (playerLight != null) { playerLight.AddToIntesnity(); } //Tell GameData this peg was collected GameData.Instance.PuzzlePieceCollected(m_ID); //increment collectable counter m_CollectableManager.IncrementPuzzleCounter(); //Play the collected sound m_SFX.playSound(transform, Sounds.PuzzlePeice); //destroy this gameobject Destroy(this.gameObject); } }
//All the puzzle pieces should have a trigger on them, when enter, this function will be called void OnTriggerEnter(Collider other) { //Check if we are still spawning if (this.GetComponent <EnemyLightPegSpawn>() != null) { return; } //checks to see if the object in our trigger is a player. if (other.gameObject.tag == Constants.PLAYER_STRING) { //Increase the intesnity of the players point light PlayerLightController playerLight = other.gameObject.GetComponent <PlayerLightController>(); if (playerLight != null) { playerLight.AddToIntesnity(); } //Tell GameData this peg was collected GameData.Instance.LightPegCollected(m_ID); //increment collectable counter m_CollectableManager.IncrementCounter(); //Play Collected sound PlaySound(); for (int i = 0; i < m_Lights.Length; i++) { //Safety check so when light pegs that don't have lights but have array values //won't throw an error because some people might not have a clue how to set the prefab. if (m_Lights[i] != null) { m_Lights[i].AddToLightIntensity(AmountToAdd); } } //destroy this gameobject Destroy(this.gameObject); } }