/// <summary> /// Clear cache of the light that the enemy was under of and enable stun of an already activate stun light /// </summary> private void OnTriggerExit2D(Collider2D collision) { if (m_enemyCollider.IsTouching(collision) && collision.gameObject.CompareTag(Tags_JoaoBeijinho.m_stunLightTag)) { if (collision.GetComponent <SpriteRenderer>().enabled == true && m_stunLightFunctionalityScript.m_stunLight == false) { m_stunLightFunctionalityScript.m_stunLight = true; m_stun = false; } m_stunLightFunctionalityScript = null; m_collider = null; m_underLight = false; } }
/// <summary> /// Stun enemy if the stun light is activated /// Turn the stun function off so that the light needs to be reset to be able to stun again /// Check if the enemy is stunned, if it is, then disable stun /// After stun enable enemy stun so that the enemy can be stunned again /// </summary> private void OnTriggerStay2D(Collider2D collision) { if (m_enemyCollider.IsTouching(collision) && collision.gameObject.CompareTag(Tags_JoaoBeijinho.m_stunLightTag)) { m_stunLightFunctionalityScript = collision.GetComponent <ControlPanelActivateObject_JoaoBeijinho>(); if (m_stunLightFunctionalityScript.m_stunLight == true && m_stun == true) { m_stunLightFunctionalityScript.m_stunLight = false; m_stun = false; StartCoroutine(Stun()); } } }