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);
        }
Esempio n. 2
0
        public void Remove_ID(ID_Settings_CS idScript)
        { // Called from "ID_Settings_CS", just before the tank is removed from the scene.
            // Set the element to false.
            if (idScript.Tank_ID != 0)
            { // The tank is selectable.
                usedIDList[idScript.Tank_ID - 1] = false;
            }

            // Remove the "ID_Settings_CS" from the list.
            ID_Scripts_List.Remove(idScript);

            // Check the ID.
            if (idScript.Tank_ID == currentID)
            {                  // The current selected tank will be removed soon.
                // Change the current ID to "1".
                currentID = 1; // (Note.) Please do not remove the tank with ID "1".
                Broadcast_Current_ID();
            }
        }
        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);
        }
Esempio n. 4
0
 void Get_Components()
 {         // This function is called at the fisrst time, and also when the tank is respawned.
     ID_Script      = GetComponent <ID_Settings_CS>();
     Body_Transform = GetComponentInChildren <Rigidbody>().transform;
     AI_Script      = GetComponentInChildren <AI_CS>();
 }
 void Receive_ID_Script(ID_Settings_CS idScript)
 { // Called from "ID_Settings_CS" in tanks in the scene, when the tank is spawned.
     // Store the "ID_Settings_CS".
     idScriptsList.Add(idScript);
 }
 public void Remove_ID(ID_Settings_CS idScript)
 { // Called from "ID_Settings_CS", just before the tank is removed from the scene.
     // Remove the "ID_Settings_CS" from the list.
     idScriptsList.Remove(idScript);
 }
        public override void Detect_Collider(Transform detectedTransform)
        { // Called from "Trigger_Collider_CS".
            // Find "ID_Settings_CS" script in the "detectedTransform".
            ID_Settings_CS idScript = detectedTransform.GetComponentInChildren <ID_Settings_CS>();

            if (idScript == null)
            {
                return;
            }

            // Check the trigger.
            switch (eventControllerScript.Trigger_Setting_Type)
            {
            case 1:   // "Any hostile tank"
                if (idScript.Relationship == 1)
                {     // Hostile
                    break;
                }
                else
                {
                    return;
                }

            case 2:   // "Any friendly tank"
                if (idScript.Relationship == 0)
                {     // Friendly
                    break;
                }
                else
                {
                    return;
                }

            case 3:     // "Any tank"
                break;

            default:
                return;
            }

            // The "detectedTransform" is the trigger.
            if (eventControllerScript.Trigger_Itself_Flag == true)
            { // The trigger should be the target of the events.
                switch (eventControllerScript.Event_Type)
                {
                case 2:     // "Change AI Settings"
                case 3:     // "Remove Tank"
                case 5:     // "Destroy Tank"
                    // Make the trigger the target of the event.
                    eventControllerScript.Target_Tanks[0] = detectedTransform;

                    if (eventControllerScript.Wait_For_All_Triggers == true)
                    {     // Keep this event until all the triggers touch the collider.
                          // Start the event waiting other triggers
                        eventControllerScript.Start_Event();
                        return; // Keep checking the triggers.
                    }           // No need to wait for other triggers.
                          // Start the event in the following lines.
                    break;
                }
            }

            // Remove this reference in the "Event_Controller_CS".
            eventControllerScript.Trigger_Script = null; // (Note.) The "Trigger_Script" must be set to null before starting the event.
            Destroy(this);

            // Start the event.
            eventControllerScript.Start_Event();
        }