Пример #1
0
        void Initialize()
        {
            // Check the anchor wheels.
            for (int i = 0; i < Anchor_Array.Length; i++)
            {
                if (Anchor_Array[i] == null)
                {
                    // Find the anchor wheel with reference to the name.
                    if (string.IsNullOrEmpty(Anchor_Names[i]) == false && string.IsNullOrEmpty(Anchor_Parent_Names[i]) == false)
                    {
                        Anchor_Array[i] = transform.parent.Find(Anchor_Parent_Names[i] + "/" + Anchor_Names[i]);
                    }
                    else
                    {
                        Debug.LogError("Anchor wheels of Scroll Track are not assigned.");
                        Destroy(this);
                        return;
                    }
                }
            }

            thisMesh        = GetComponent <MeshFilter>().mesh;
            currentVertices = new Vector3[Initial_Vertices.Length];
            bodyScript      = GetComponentInParent <MainBody_Setting_CS>();
        }
        void Initialize()
        {
            // Find the reference wheels.
            if (Reference_Wheel == null)
            {
                if (string.IsNullOrEmpty(Reference_Name) == false && string.IsNullOrEmpty(Reference_Parent_Name) == false)
                {
                    Reference_Wheel = transform.parent.Find(Reference_Parent_Name + "/" + Reference_Name);
                }
            }
            if (Reference_Wheel == null)
            {
                Debug.LogError("'Reference wheel' for Scroll_Track cannot be found.");
                Destroy(this);
                return;
            }

            // Send this reference to all the "Static_Wheel_Parent_CS" in the tank.
            Static_Wheel_Parent_CS[] staticWheelParentScripts = transform.parent.GetComponentsInChildren <Static_Wheel_Parent_CS>();
            for (int i = 0; i < staticWheelParentScripts.Length; i++)
            {
                staticWheelParentScripts[i].Prepare_With_Scroll_Track(this);
            }

            thisMaterial = GetComponent <Renderer>().material;
            bodyScript   = GetComponentInParent <MainBody_Setting_CS>();
        }
Пример #3
0
        void Initialize()
        {
            thisTransform = transform;
            bodyScript    = GetComponent <MainBody_Setting_CS>();

            // Check the tracks.
            if (Static_Track == null || Scroll_Track_L == null || Scroll_Track_R == null)
            {
                Debug.LogWarning("Track LOD system cannot work, because the tracks are not assigned.");
                Destroy(this);
                return;
            }

            // Set the tracks activations at the first time.
            frustumHeight = 2.0f * Vector3.Distance(thisTransform.position, Camera.main.transform.position) * Mathf.Tan(Camera.main.fieldOfView * 0.5f * Mathf.Deg2Rad);
            tankIsNear    = (frustumHeight < Threshold);
            if (tankIsNear)
            {
                Static_Track.SetActive(true);
                Scroll_Track_L.SetActive(false);
                Scroll_Track_R.SetActive(false);
            }
            else
            {
                Static_Track.SetActive(false);
                Scroll_Track_L.SetActive(true);
                Scroll_Track_R.SetActive(true);
            }
        }
Пример #4
0
        void Initialize()
        {
            var bodyTransform = transform.parent;

            bodyScript = bodyTransform.GetComponent <MainBody_Setting_CS>();

            // Find the reference wheels.
            if (Reference_L == null)
            { // The left reference wheel has been lost by modifying.
                if (string.IsNullOrEmpty(Reference_Name_L) == false && string.IsNullOrEmpty(Reference_Parent_Name_L) == false)
                {
                    Reference_L = bodyTransform.Find(Reference_Parent_Name_L + "/" + Reference_Name_L);
                }
            }
            if (Reference_R == null)
            { // The right reference wheel has been lost by modifying.
                if (string.IsNullOrEmpty(Reference_Name_R) == false && string.IsNullOrEmpty(Reference_Parent_Name_R) == false)
                {
                    Reference_R = bodyTransform.Find(Reference_Parent_Name_R + "/" + Reference_Name_R);
                }
            }

            // Set "Reference_Radius_#" for "Static_Wheel_Parent_CS", and set the angle rate for controlling the speed.
            if (Reference_L && Reference_R)
            {
                Reference_Radius_L = Reference_L.GetComponent <MeshFilter>().mesh.bounds.extents.x + Radius_Offset;
                leftAngRate        = 360.0f / ((2.0f * Mathf.PI * Reference_Radius_L) / Length);
                Reference_Radius_R = Reference_R.GetComponent <MeshFilter>().mesh.bounds.extents.x + Radius_Offset;
                rightAngRate       = 360.0f / ((2.0f * Mathf.PI * Reference_Radius_R) / Length);
            }
            else
            {
                Debug.LogError("'Reference wheels' for Static_Track cannot be found.");
                this.enabled = false;
                return;
            }

            // Send this reference to all the "Static_Wheel_Parent_CS" in the tank.
            var staticWheelParentScripts = bodyTransform.GetComponentsInChildren <Static_Wheel_Parent_CS>();

            for (int i = 0; i < staticWheelParentScripts.Length; i++)
            {
                staticWheelParentScripts[i].Prepare_With_Static_Track(this);
            }
        }
Пример #5
0
        void Set_Other_Components_Automatically()
        {
            // "MainBody_Setting_CS" (Increase the "Mass", and set the "SIC" to 10.)
            Transform           bodyTransform = thisTransform.parent;
            MainBody_Setting_CS bodyScript    = bodyTransform.GetComponent <MainBody_Setting_CS>();

            if (bodyScript.Body_Mass < Stored_Body_MassProp.floatValue)
            {
                bodyScript.Body_Mass = Stored_Body_MassProp.floatValue;
            }
            bodyScript.SIC = 10;

            // "Create_IdlerWheel_CS" (Enable the "Static_Flag")
            Create_IdlerWheel_CS[] idlerScripts = bodyTransform.GetComponentsInChildren <Create_IdlerWheel_CS>();
            for (int i = 0; i < idlerScripts.Length; i++)
            {
                idlerScripts [i].Static_Flag = true;
            }
            // "Create_SprocketWheel_CS" (Enable the "Static_Flag")
            Create_SprocketWheel_CS [] sprocketScripts = bodyTransform.GetComponentsInChildren <Create_SprocketWheel_CS> ();
            for (int i = 0; i < sprocketScripts.Length; i++)
            {
                sprocketScripts [i].Static_Flag = true;
            }
            // "Create_SupportWheel_CS" (Enable the "Static_Flag")
            Create_SupportWheel_CS [] supportScripts = bodyTransform.GetComponentsInChildren <Create_SupportWheel_CS> ();
            for (int i = 0; i < supportScripts.Length; i++)
            {
                supportScripts [i].Static_Flag = true;
            }
            // "Create_RoadWheel_CS" (Enable the "Fit_ST_Flag")
            Create_RoadWheel_CS [] roadWheeScripts = bodyTransform.GetComponentsInChildren <Create_RoadWheel_CS> ();
            for (int i = 0; i < roadWheeScripts.Length; i++)
            {
                roadWheeScripts [i].Fit_ST_Flag = true;
            }
        }
Пример #6
0
 void Start()
 {
     thisTransform = transform;
     bodyScript    = GetComponentInParent <MainBody_Setting_CS>();
 }
 void Initialize()
 {
     bodyScript = GetComponentInParent <MainBody_Setting_CS>();
 }