Ejemplo n.º 1
0
    void EnableButton()
    {
        GameObject.Find("Stop Dices").SetActive(false);

        Dice1      = Random.Range(0, 5);
        Dice2      = Random.Range(0, 5);
        TotalValue = Dice1 + Dice2;
        if (TotalValue == 0)
        {
            Dice1 = Random.Range(1, 5); TotalValue = Dice1 + Dice2;
        }

        //save.Set_nextmove(100); //pour tester
        save.Set_nextmove(TotalValue);
    }
Ejemplo n.º 2
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);
                    }
                }
            }
        }
    }