Exemple #1
0
    void Get_Static_Track(Static_Track_CS Temp_Script)
    { // Called from "Static_Track".
        Static_Track_Script = Temp_Script;
        Work_Flag           = true;
        // Set direction.
        if (This_Transform.localPosition.y > 0.0f)
        {
            Direction = true; // Left
        }
        else
        {
            Direction = false; // Right
        }
        // Set Rate.
        float This_Radius = GetComponent <MeshFilter>().mesh.bounds.extents.x + Radius_Offset;

        if (Direction)
        { // Left
            Rate = Static_Track_Script.Reference_Radius_L / This_Radius;
        }
        else
        { // Right
            Rate = Static_Track_Script.Reference_Radius_R / This_Radius;
        }
    }
 void StaticTrack_Linkage()        // Called from Damage_Control.
 {
     if (this.enabled)
     {
         // Reset parent script.
         if (Parent_Script)
         {
             Parent_Script.Rate_L = 0.0f;
             Parent_Script.Rate_R = 0.0f;
         }
         // Add Components into this piece.
         Add_Components(This_Transform);
         // Add Components into other pieces.
         Static_Track_CS Temp_Script = this;
         for (int i = 0; i < Number_of_Pieces; i++)
         {
             Transform Temp_Transform = Temp_Script.Front_Transform;
             Add_Components(Temp_Transform);
             Temp_Script = Temp_Script.Front_Script;
         }
         // Add HingeJoint into front pieces.
         Temp_Script = this;
         for (int i = 0; i < Number_of_Pieces - 1; i++)                   // Add HingeJoint except for this piece.
         {
             Transform Temp_Transform      = Temp_Script.Front_Transform;
             Transform Connected_Transform = Temp_Script.Front_Script.Front_Transform;
             Add_HingeJoint(Temp_Transform, Connected_Transform);
             Temp_Script = Temp_Script.Front_Script;
         }
         // Disable and Destroy the pieces on the same side.
         This_Transform.parent.BroadcastMessage("Disable_and_Destroy", Direction, SendMessageOptions.DontRequireReceiver);
     }
 }
 void Initial_Settings()
 {
     // Set direction.
     if (This_Transform.localPosition.y > 0.0f)
     {
         Direction = true;              // Left
     }
     else
     {
         Direction = false;              // Right
     }
     // Set Invert_Value.
     if (This_Transform.localEulerAngles.y > 90.0f && This_Transform.localEulerAngles.y < 270.0f)
     {
         Invert_Value = 180.0f;              // Upper.
     }
     else
     {
         Invert_Value = 0.0f;              // Lower.
     }
     // Set initial position and angle.
     Invisible_Pos = This_Transform.localPosition;
     Invisible_Ang = This_Transform.localRotation.eulerAngles.y;
     // Find Front, Rear, Parent scripts.
     if (Front_Transform)
     {
         Front_Script = Front_Transform.GetComponent <Static_Track_CS> ();
     }
     if (Rear_Transform)
     {
         Rear_Script = Rear_Transform.GetComponent <Static_Track_CS> ();
     }
     Parent_Script = This_Transform.parent.GetComponent <Static_Track_CS> ();
     // Get the half length of the piece.
     Half_Length = Parent_Script.Length * 0.5f;
     // Set Number_of_Pieces.
     for (int i = 0; i < This_Transform.parent.childCount; i++)
     {
         if (This_Transform.parent.GetChild(i).GetComponent <Static_Track_CS> ())
         {
             Number_of_Pieces += 1;
         }
     }
     Number_of_Pieces /= 2;
 }
Exemple #4
0
 // In case of "Static_Track".
 void Get_Static_Track(Static_Track_CS Temp_Script) // Called from "Static_Track".
 {
     if (Type == 0)                                 // Engine Sound.
     {
         Wheel_Transform_L = Temp_Script.Reference_L;
         Wheel_Transform_R = Temp_Script.Reference_R;
         if (Wheel_Transform_L && Wheel_Transform_R)
         {
             Wheel_RigidBody_L = Temp_Script.Reference_L.GetComponent <Rigidbody>();
             Wheel_RigidBody_R = Temp_Script.Reference_R.GetComponent <Rigidbody>();
             Circumference_L   = Temp_Script.Reference_L.GetComponent <SphereCollider> ().radius * 6.28f;
             Circumference_R   = Temp_Script.Reference_R.GetComponent <SphereCollider> ().radius * 6.28f;
         }
         else
         {
             Debug.LogWarning("Reference Wheels for the engine sound can not be found. (Physics Tank Maker)");
             Destroy(this);
         }
     }
 }