/// <summary> /// Checks if the player was spotted before camouflaging /// </summary> /// <param name="hit">Result of the raycast</param> /// <returns>true if spotted, false otherwise</returns> public bool SpottedCheck(Collider2D hit) { if (playerState == null) { playerState = hit.GetComponent <Camouflage>(); } else { return(spottedBeforeCamouflage); } spottedBeforeCamouflage = !playerState.IsCamouflaged(); return(spottedBeforeCamouflage); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == Names.Tags.Player.ToString()) { if (playerState == null) { playerState = collision.GetComponent <Camouflage>(); } if (spottedCheck.WasSpottedBeforeCamouflage() || !playerState.IsCamouflaged()) { EventManager.TriggerEvent(Names.Events.PlayerHit); spottedCheck.SetToDefault(); } } }