void Receive_ID_Script(ID_Settings_CS idScript) { // Called from "ID_Settings_CS" in tanks in the scene, when the tank is spawned. // Add the "ID_Settings_CS" to the list. idScriptsList.Add(idScript); // Create a new marker object. var markerObject = Instantiate(Marker_Prefab, canvas.transform); // Add the components to the dictionary. var newProp = new Position_Marker_Prop(); newProp.Marker_Image = markerObject.GetComponent <Image>(); newProp.Marker_Transform = newProp.Marker_Image.transform; newProp.Root_Transform = idScript.transform.root; newProp.Body_Transform = idScript.GetComponentInChildren <Rigidbody>().transform; newProp.AI_Script = idScript.GetComponentInChildren <AI_CS>(); markerDictionary.Add(idScript, newProp); }
bool Find_Target() { // Find "Camera_Points_Manager_CS" in the current selected tank. if (ID_Manager_CS.Instance == null) { Debug.LogWarning("RC Camera cannot find the target. There is no 'ID_Manager_CS' in this scene."); return(false); } for (int i = 0; i < ID_Manager_CS.Instance.ID_Scripts_List.Count; i++) { if (ID_Manager_CS.Instance.ID_Scripts_List[i].Is_Selected) { targetIDScript = ID_Manager_CS.Instance.ID_Scripts_List[i]; var cameraScript = targetIDScript.GetComponentInChildren <Camera_Points_Manager_CS>(); if (cameraScript == null) { Debug.LogWarning("RC Camera cannot find the target. The current selected tank has no 'Camera_Points_Manager_CS'."); targetIDScript = null; return(false); } // Get the components of the target. targetMainCamera = cameraScript.Main_Camera; targetMainAudioListener = cameraScript.Main_AudioListener; targetTransform = targetIDScript.GetComponentInChildren <Rigidbody>().transform; break; } } // Get the gun camera in the target. var targetGunCameraScript = targetTransform.GetComponentInChildren <Gun_Camera_CS>(); if (targetGunCameraScript) { targetGunCamera = targetGunCameraScript.Gun_Camera; } return(true); }