/// <summary> /// Used for checking if the animal enables the action /// </summary> private void OnActionListener() { if (!oldAnimal) { return; //Skip if there's no animal } if (ActionDelay > 0) { Invoke("OnActionEvent", ActionDelay); //Invole the Event OnAction) } else { OnAction.Invoke(oldAnimal); //Invole the Event OnAction } if (Align && AlingPoint) { IEnumerator ICo = null; if (AlignLookAt) { ICo = MalbersTools.AlignLookAtTransform(oldAnimal.transform, AlingPoint, AlignTime, AlignCurve); //Align Look At the Zone } else { ICo = MalbersTools.AlignTransformsC(oldAnimal.transform, AlingPoint, AlignTime, AlignPos, AlignRot, AlignCurve); //Aling Transform to another transform } StartCoroutine(ICo); } StartCoroutine(CheckForCollidersOff()); }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (isFlying) { return; } if (Agent.isOnOffMeshLink && !EnterOFFMESH) //Check if the Agent is on a OFF MESH LINK { EnterOFFMESH = true; //Just to avoid entering here again while we are on a OFF MESH LINK OffMeshLinkData OMLData = Agent.currentOffMeshLinkData; if (OMLData.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { OffMeshLink CurrentOML = OMLData.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = CurrentOML.GetComponentInParent <ActionZone>(); if (OffMeshZone && !OnAction) //if the OffmeshLink is a zone and is not making an action { animal.Action = OnAction = true; //Activate the Action on the Animal return; } var DistanceEnd = (transform.position - CurrentOML.endTransform.position).sqrMagnitude; var DistanceStart = (transform.position - CurrentOML.startTransform.position).sqrMagnitude; var NearTransform = DistanceEnd < DistanceStart ? CurrentOML.endTransform : CurrentOML.startTransform; StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.15f, false, true)); //Aling the Animal to the Link Position if (CurrentOML.area == 2) { animal.SetJump(); //if the OffMesh Link is a Jump type } try { if (CurrentOML.CompareTag("Fly")) { animal.SetFly(true); isFlying = true; StartCoroutine(FlyTowardsTarget(CurrentOML.endTransform)); return; } } catch {} } else if (OMLData.linkType == OffMeshLinkType.LinkTypeJumpAcross) //Means that it has a OffMesh Link component { animal.SetJump(); } } }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (Agent.isOnOffMeshLink) { OffMeshLinkData CurrentOffmeshLink_Data = Agent.currentOffMeshLinkData; OffMeshLink CurrentOffMeshLink = CurrentOffmeshLink_Data.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = null; if (CurrentOffMeshLink) //Checking if the OffMeshLink is an Action Zone { OffMeshZone = CurrentOffMeshLink.GetComponentInChildren <ActionZone>(); if (!OffMeshZone) { OffMeshZone = CurrentOffMeshLink.GetComponentInParent <ActionZone>(); } } if (OffMeshZone) { if (!StartingAction) //If the Target is an Action Zone Start the Action { StartingAction = true; animal.Action = true; //Activate the Action on the Animal return; } } if (CurrentOffmeshLink_Data.linkType == OffMeshLinkType.LinkTypeManual) { Transform NearTransform = CurrentOffMeshLink.startTransform; if (CurrentOffMeshLink.endTransform.position == CurrentOffmeshLink_Data.startPos) //Verify the start point of the OffMeshLink { NearTransform = CurrentOffMeshLink.endTransform; } StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.5f, false, true)); //Aling the Animal to the Link if (CurrentOffMeshLink.area == 2) //if the OffMesh Link is a Jump type { animal.SetJump(); } } } }
/// <summary> /// Manage all Off Mesh Links /// </summary> protected virtual void CheckOffMeshLinks() { if (isFlying) { return; } if (Agent.isOnOffMeshLink) { OffMeshLinkData CurrentOffmeshLink_Data = Agent.currentOffMeshLinkData; OffMeshLink CurrentOffMeshLink = CurrentOffmeshLink_Data.offMeshLink; //Check if the OffMeshLink is a Custom Off Mesh Link ActionZone OffMeshZone = null; if (CurrentOffMeshLink) //Checking if the OffMeshLink is an Action Zone { OffMeshZone = CurrentOffMeshLink.GetComponentInChildren <ActionZone>(); if (!OffMeshZone) { OffMeshZone = CurrentOffMeshLink.GetComponentInParent <ActionZone>(); } } if (OffMeshZone) { if (!StartingAction) //If the Target is an Action Zone Start the Action { StartingAction = true; animal.Action = true; //Activate the Action on the Animal return; } } if (CurrentOffmeshLink_Data.linkType == OffMeshLinkType.LinkTypeManual) //Means that it has a OffMesh Link component { Transform NearTransform = CurrentOffMeshLink.startTransform; if (CurrentOffMeshLink.endTransform.position == CurrentOffmeshLink_Data.startPos) //Verify the start point of the OffMeshLink { NearTransform = CurrentOffMeshLink.endTransform; } StartCoroutine(MalbersTools.AlignTransformsC(transform, NearTransform, 0.5f, false, true)); //Aling the Animal to the Link try { if (CurrentOffMeshLink.CompareTag("Fly")) { animal.SetFly(true); isFlying = true; StartCoroutine(FlyTowardsTarget(CurrentOffMeshLink.endTransform)); return; } } catch { /*Debug.LogWarning("There's no Fly Tag");*/ } if (CurrentOffMeshLink.area == 2) //if the OffMesh Link is a Jump type { animal.SetJump(); } } } }