Пример #1
0
 void OnTriggerEnter(Collider other)         // -> On trigger Enter
 {
     if (other.transform.tag == "Ball")      // If it is a ball
     {
         if (b_Trigger_Open)                 // If it is the trigger taht open the gate
         {
             target.Desactivate_Object();
         }
         else                                                                                // if it the trigger that close the gate
         {
             target.Activate_Object();
         }
     }
 }
Пример #2
0
    void Update()
    {
        if (!Pause)                                                                                                                                                                     // --> Update function
        {
            if (!b_Part_1)                                                                                                                                                              // Part 1 : Part Before the ball go to the respawn position
            {
                if (!Mission_Kickback)
                {
                    tmp_Ball.transform.position =                                                                                                                               // the ball disappears into the ground
                                                  Vector3.MoveTowards(tmp_Ball.transform.position,
                                                                      transform.position + Vector3.down * .023f, Time.deltaTime * 0.4f);
                }

                if (tmp_Ball.transform.position == transform.position + Vector3.down * .023f || Mission_Kickback)                                       // The ball has disappeared
                {
                    tmp_Time = Mathf.MoveTowards(tmp_Time, Part_1_TimeToRespawn,
                                                 Time.deltaTime);
                    if (tmp_Time == Part_1_TimeToRespawn)                                                                                                       // Wait for Part_1_TimeToRespawn
                    {
                        tmp_Time = 0;
                        b_Part_1 = true;
                        b_Part_2 = false;                                                                                               // Start Part 2
                        if (!Mission_Kickback)                                                                                          // if it's not a kickback mission
                        {
                            tmp_Ball.transform.position = Spawn.position + RespawnDir * .023f;                                          // the ball go to his spawn position
                            rb.velocity = new Vector3(0, 0, 0);
                            if (Sfx_Ball_Respawn)
                            {
                                sound_.PlayOneShot(Sfx_Ball_Respawn);                                                                           // play a sound : Sfx_Ball_Respawn
                            }
                        }
                    }
                }
            }

            if (!b_Part_2)                                                                                                                                                              // Part 1 : Part before adding force to the ball after the respawn
            {
                Box_Col.enabled = false;


                tmp_Ball.transform.position
                    = Vector3.MoveTowards(tmp_Ball.transform.position,
                                          Spawn.position, Time.deltaTime * 0.4f);

                if (tmp_Ball.transform.position == Spawn.position)                                                                                      // the ball appears into the ground
                {
                    tmp_Time_2 = Mathf.MoveTowards(tmp_Time_2,
                                                   Part_2_TimeBeforeAddingForce, Time.deltaTime);

                    if (tmp_Time_2 == Part_2_TimeBeforeAddingForce)                                                                                     // Wait for Part_2_TimeBeforeAddingForce
                    {
                        tmp_Time_2 = 0;
                        b_Part_2   = true;
                        Ball_AddForceExplosion();                                                                                                                               // Add a force to the ball
                        if (Mission_Kickback)
                        {
                            b_Part_3 = false;                                                                                                                   // if it is kickback mission start Part 3
                        }
                    }
                }
            }

            if (!b_Part_3)                                                                                                                                                              // Time to wait before you close the door
            {
                tmp_Time_3 = Mathf.MoveTowards(tmp_Time_3, Part_3_TimeBeforeActivateObjTarget,
                                               Time.deltaTime);
                if (tmp_Time_3 == Part_3_TimeBeforeActivateObjTarget)                                                                           // Wait for Part_3_TimeBeforeActivateObjTarget
                {
                    tmp_Time_3 = 0;
                    b_Part_3   = true;
                    if (obj_Target)
                    {
                        target.Activate_Object();                                                                                                               // Close the door
                    }
                    if (Mission_Kickback)
                    {
                        Box_Col.isTrigger = false;
                    }
                }
            }
        }
    }