//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); } }
// Start is called before the first frame update void Start() { active = false; rb = this.gameObject.GetComponent <Rigidbody>(); forceDirection = Vector3.zero; plc = this.gameObject.GetComponent <PlayerLightController>(); StartCoroutine(GiveControl()); }
//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); } }
// Use this for initialization void Start() { Characters currentCharacter; switch (transform.parent.name) { case Constants.ALEX_STRING: currentCharacter = Characters.Alex; break; case Constants.DEREK_STRING: currentCharacter = Characters.Derek; break; case Constants.ZOE_STRING: currentCharacter = Characters.Zoe; break; default: #if DEBUG || UNITY_EDITOR Debug.LogError("parent is named wrong"); #endif currentCharacter = Characters.Zoe; break; } //Check if player one if (GameData.Instance.PlayerOneCharacter == currentCharacter) { m_Player = 1; } else { m_Player = 2; } //gets reference to sound manager m_SFX = SFXManager.Instance; //Gets reference to hud m_Hud = GameObject.FindGameObjectWithTag(Constants.HUD).GetComponent <Hud>(); //setting initial values for the timers m_HealthRegenTimer = HealthRegenTime; m_InvulnerabilityTimer = InvulnerabilityTimer; //setting the total health m_TotalHealth = m_Health; //Set Health in hud m_Hud.SetHealth(m_TotalHealth, m_Player); m_PlayerRenderer = gameObject.GetComponentInChildren <SkinnedMeshRenderer>(); //Get the players movement for knockback m_Movement = GetComponent <BaseMovementAbility> (); #if DEBUG || UNITY_EDITOR if (i_InvulnerableMaterial == null) { Debug.LogError("put the invulnerable material on this script"); } #endif m_DefaultMaterial = m_PlayerRenderer.materials[0]; //Load player light m_PlayerLight = GetComponent <PlayerLightController>(); }
// Use this for initialization void Start() { Characters currentCharacter; switch (transform.parent.name) { case Constants.ALEX_STRING: currentCharacter = Characters.Alex; break; case Constants.DEREK_STRING: currentCharacter = Characters.Derek; break; case Constants.ZOE_STRING: currentCharacter = Characters.Zoe; break; default: #if DEBUG || UNITY_EDITOR Debug.LogError("parent is named wrong"); #endif currentCharacter = Characters.Zoe; break; } //Check if player one if (GameData.Instance.PlayerOneCharacter == currentCharacter) { m_Player = 1; } else { m_Player = 2; } //gets reference to sound manager m_SFX = SFXManager.Instance; //Gets reference to hud m_Hud = GameObject.FindGameObjectWithTag(Constants.HUD).GetComponent<Hud>(); //setting initial values for the timers m_HealthRegenTimer = HealthRegenTime; m_InvulnerabilityTimer = InvulnerabilityTimer; //setting the total health m_TotalHealth = m_Health; //Set Health in hud m_Hud.SetHealth (m_TotalHealth, m_Player); m_PlayerRenderer = gameObject.GetComponentInChildren<SkinnedMeshRenderer>(); //Get the players movement for knockback m_Movement = GetComponent<BaseMovementAbility> (); #if DEBUG || UNITY_EDITOR if(i_InvulnerableMaterial == null) { Debug.LogError("put the invulnerable material on this script"); } #endif m_DefaultMaterial = m_PlayerRenderer.materials[0]; //Load player light m_PlayerLight = GetComponent<PlayerLightController>(); }