Exemple #1
0
    public void OnTriggerEnter(Collider other)
    {
        Movement.flag = false;
        if (!was_triggered)
        {
            was_triggered = true;

            if (Movement.advance == 0) //si il n'y a pas de sauvegarde
            {
                if (save.Get_nextmove() != 0)
                {
                    save.Set_counter(save.Get_counter() + 1);
                    save.Set_nextmove(save.Get_nextmove() - 1);
                }

                if (this.name.Length >= 10)
                {
                    Movement.path_counter += 1;

                    if (this.intersection == 1)     //Movement.pathname = "J1_" + Movement.path_counter + "_LEFT";
                    {
                        if (this.name.Equals("P6_ENDPATH") && save.Get_counter() == 52)
                        {
                            Move_counter();
                        }
                        if (save.Get_nextmove() != 0)     // si il reste des cases à bouger
                        {
                            //Debug.Log("case n° " + save.Get_counter());
                            if (save.Get_counter() != 46)     // si ce n'est pas la case immersion
                            {
                                StartCoroutine(Choice());
                            }
                            else
                            {
                                if (save.Get_imm())
                                {
                                    Movement.pathname = "J1_" + Movement.path_counter + "_LEFT";
                                }
                                else
                                {
                                    Movement.pathname = "J1_" + Movement.path_counter + "_RIGHT";
                                    Move_counter();
                                }

                                Movement.Play_iTween(GameObject.Find("Sphere_path"));
                            }
                        }
                        else
                        {
                            iTween.Pause();
                        }
                    }
                    else
                    {
                        Movement.pathname = "J1_" + Movement.path_counter;

                        if (save.Get_nextmove() != 0)
                        {
                            Movement.Play_iTween(GameObject.Find("Sphere_path"));
                        }
                        else
                        {
                            Movement.flag = true;
                        }

                        Move_counter();
                    }
                }

                if (save.Get_nextmove() == 0 || save.Get_counter() == 100) /// Avance until the dice number
                {
                    iTween.Pause();
                    StartCoroutine(Action_Case(0.8f)); //lancer l'action de la case
                }
                else if (IsStop())
                {
                    iTween.Pause();
                    StartCoroutine(Action_Case(0.8f));
                }
            }
            else // sauvegarde présente
            {
                if (Movement.advance == 100)
                {
                    SceneManager.LoadScene("End Game");
                }

                Movement.advance--;
                Movement.j++;
                if (Movement.advance == 0)
                {
                    iTween.Pause(); Sauvegarde.dices.gameObject.SetActive(true);
                }

                else
                {
                    if (this.name.Length >= 10) // ex : P1_ENDPATH
                    {
                        Movement.path_counter += 1;
                        if (this.intersection == 1)
                        {
                            if (this.name.Equals("P6_ENDPATH") && Movement.advance == 52)
                            {
                                Move_advance();
                            }
                            if (Isleft(save.Get_counter()))
                            {
                                Movement.pathname = "J1_" + Movement.path_counter + "_LEFT";
                            }
                            else
                            {
                                Movement.pathname = "J1_" + Movement.path_counter + "_RIGHT";
                                Move_advance();
                            }
                        }

                        else
                        {
                            Movement.pathname = "J1_" + Movement.path_counter;
                            Move_advance();
                        }

                        Movement.Play_iTween(other.gameObject);
                    }
                }
            }
        }
    }