public void Set_Target(AI_Headquaters_Helper_CS targetAIHelperScript) { // Called from "AI_Headquaters_CS" in the scene. if (Target_Transform == targetAIHelperScript.Body_Transform) { // The sent target is the same as the current target. return; } // Reset the values. Lost_Target(); Target_Transform = targetAIHelperScript.Body_Transform; targetRootTransform = targetAIHelperScript.Body_Transform.root; targetUpperOffset = targetAIHelperScript.Visibility_Upper_Offset; }
public void Remove_From_List(AI_Headquaters_Helper_CS helperScript) { // Called from "AI_Headquaters_Helper_CS", just before the tank is removed. switch (helperScript.ID_Script.Relationship) { case 0: Friendly_Tanks_List.Remove(helperScript); break; case 1: Hostile_Tanks_List.Remove(helperScript); break; } }
public void Receive_Helpers(AI_Headquaters_Helper_CS helperScript) { // Called from "AI_Headquaters_Helper_CS", when the tank is spawend. // Add the script into the lists according to the relationship. switch (helperScript.ID_Script.Relationship) { case 0: Friendly_Tanks_List.Add(helperScript); break; case 1: Hostile_Tanks_List.Add(helperScript); break; } }
void Share_Target() { // Get "AI_Headquaters_Helper_CS" of the target. AI_Headquaters_Helper_CS targetAIHelperScript = commanderAimingScript.Target_Transform.GetComponentInParent <AI_Headquaters_Helper_CS>(); if (targetAIHelperScript == null) { // The target does not have "AI_Headquaters_Helper_CS". return; } // Start sharing the target. AI_Script.Is_Sharing_Target = true; // Send the target information to the "AI_CS". AI_Script.Set_Target(targetAIHelperScript); }
public bool Check_for_Assigning(AI_Headquaters_Helper_CS targetAIHelperScript) { // Called from "AI_Headquaters_CS" in the scene. // Check this tank can detect the target or not, by casting a line. Vector3 tempTargetPosition = targetAIHelperScript.Body_Transform.position + (targetAIHelperScript.Body_Transform.up * targetAIHelperScript.Visibility_Upper_Offset); RaycastHit raycastHit; if (Physics.Linecast(eyeTransform.position, tempTargetPosition, out raycastHit, Layer_Settings_CS.Layer_Mask)) { // The line hits anything. if (raycastHit.transform.root == targetAIHelperScript.Body_Transform.root) { // The line hits the target. return(true); } else { // The line hits other object. return(false); } } else { // The line does not hit anything. >> There is no obstacle between this eye and the target. return(true); } }