Example #1
0
    IEnumerator Deal()
    {
        yield return(null);

        GameCard trumpCard = GameObjectUtils.AddAndPosition(CardPrefab, trumpCardPile, Vector3.zero).GetComponent <GameCard> ();

        trumpCard.GetComponent <GameCard> ().Initialize(deckController.TakeCardFromDeck());
    }
Example #2
0
    private IEnumerator TourPioche()
    {
        VousNePasserezPas2 = 0;
        VousNePasserezPas3 = 0;


        if (VousNePasserezPas == 0)     //VousNePasserezPas est là pour faire en sorte que le programme ne recalcule pas la position de fin au 2e passage
        {
            yield return(new WaitForSeconds(0.3f));

            currPioche          = manager.GetComponent <GameManager>().AfficherPioche();
            currPioche.cardFace = manager.GetComponent <GameManager>().getCardFace(currPioche.cardValue);
            currPioche.transform.SetSiblingIndex(47);

            Vector3 patate2 = new Vector3(180, 180, 180);
            iTween.RotateTo(currPioche.gameObject, patate2, 0.5f);
            currPioche.GetComponent <Image>().sprite = currPioche.cardFace;                      //on affiche le sprite de la pioche
            if (!((Partie.modeSoutenance == true) && (MenuManager.typeJeu == 2)))
            {
                manager.GetComponent <GameManager>().audioCardFlip.Play();
            }
            yield return(new WaitForSeconds(0.5f));

            NoPaires = false;
            VousNePasserezPas++;
            paire = manager.GetComponent <GameManager>().checkCards(currPioche, 2);          //on regarde si on peut faire une combinaison avec la carte tirée de la pioche
            if ((manager.GetComponent <GameManager>().Pli2Choix == true))
            {
                Debug.Log("Pli 2 choix Pioche");
                StartCoroutine(manager.GetComponent <GameManager>().CheckCards2choix(currPioche, 2));
                yield return(new WaitWhile(() => GameManager.pauseJeu2Choix));

                paire = GameManager.gameCard2choix;
            }
            J1_humain = GameManager.J1_humain;
            J2_IA     = GameManager.J2_IA;

            if (paire == null)
            {
                currPioche.endPosition = PasdePaires(currPioche);                           //cas où on ne peut pas faire de combinaisons (retourne un emplacement vide où on pourra poser la carte)
                NoPaires = true;
            }

            else
            {
                currPioche.endPosition = paire.gameObject.transform.position;               //cas où on peut faire combinaison
                paire.transform.SetSiblingIndex(46);
            }
        }

        currPioche.startPosition = currPioche.gameObject.transform.position;
        currPioche.journeyLength = Vector3.Distance(currPioche.startPosition, currPioche.endPosition);
        float distCovered = (Time.time - startTime) * speed;
        float fracJourney = distCovered / currPioche.journeyLength;

        if (currPioche.transform.position != currPioche.endPosition)
        {
            iTween.MoveTo(currPioche.gameObject, currPioche.endPosition, 1.0f);
            yield return(null);

            StartCoroutine(TourPioche());
        }


        else
        {                          //quand c'est terminé
            if (NoPaires == false) //si on a trouvé une combinaison, on peut ranger les 2 cartes
            {
                cptAudio = 0;
                StartCoroutine(RangerCartes(currPioche, 1));
            }

            else
            {                          //si y avait pas de combinaisons, on range rien et le tour de la pioche est terminé
                tourPioche        = false;
                VousNePasserezPas = 0;
                NoPaires          = false;
                if (J1_humain_plays == true)
                {
                    J1_humain.CompterPoints();
                    if ((J1_humain.nbrePoints > 0) && ((pointsJ1 != J1_humain.nbrePoints)))
                    {
                        StartCoroutine(PauseJeu(1));
                    }
                    else if ((manager.GetComponent <GameManager>().jeuHumain.Count == 0) && (manager.GetComponent <GameManager>().jeuIA.Count == 0))
                    {
                        FinMancheMatchNul(1);
                    }

                    else
                    {
                        J1_humain_plays = false;
                        StartCoroutine(TourIA());
                    }
                }
                else
                {
                    J2_IA.CompterPoints();
                    if ((J2_IA.nbrePoints > 0) && ((pointsJ2 != J2_IA.nbrePoints)))
                    {
                        StartCoroutine(PauseJeu(2));
                    }
                    else if ((manager.GetComponent <GameManager>().jeuHumain.Count == 0) && (manager.GetComponent <GameManager>().jeuIA.Count == 0))
                    {
                        FinMancheMatchNul(2);
                    }
                    else
                    {
                        J1_humain_plays = true;
                        if (MenuManager.typeJeu == 1)
                        {
                            manager.GetComponent <GameManager>().DesactiverOuActiverBoutons(false);
                        }
                        else
                        {
                            TourJoueurIA();
                        }
                    }
                }
            }
        }
    }
Example #3
0
    //TRES IMPORTANT: Update() est appelée à chaque frame (seule fonction de Unity qui fait ca, elle est indispensable)
    //CONSEQUENCES: Update() va plus vite que le compilateur!!! Il est possible que le programme recommence la fonction avant qu'il ait finit de la parcourir
    //Cela nécessite beaucoup de booleens et de conditions d'arrets pour éviter que le programme tourne en boucle



    private IEnumerator TourJoueur(GameCard c)
    {
        tourPioche        = false;
        VousNePasserezPas = 0;

        if (VousNePasserezPas3 == 0)
        {
            if (MenuManager.typeJeu == 2)
            {
                yield return(new WaitForSeconds(0.5f));

                manager.GetComponent <GameManager>().GriserBouttons(1, false);
                manager.GetComponent <GameManager>().GriserBouttons(2, true);
            }

            NoPaires = false;
            VousNePasserezPas3++;
            paire = manager.GetComponent <GameManager>().checkCards(c, 1);    //on regarde dans la défosse si y a une paire correspondante
            if ((manager.GetComponent <GameManager>().Pli2Choix == true))
            {
                Debug.Log("Pli 2 choix Joueur");
                StartCoroutine(manager.GetComponent <GameManager>().CheckCards2choix(c, 1));
                yield return(new WaitWhile(() => GameManager.pauseJeu2Choix));

                paire = GameManager.gameCard2choix;
            }
            J1_humain = GameManager.J1_humain;
            J2_IA     = GameManager.J2_IA;
            c.GetComponent <Button>().enabled = false;
            c.transform.SetSiblingIndex(47);
            if (MenuManager.typeJeu == 1)
            {
                manager.GetComponent <GameManager>().DesactiverOuActiverBoutons(true);
            }

            if (paire != null)
            {
                if (paire.Proprietes.Id == c.Proprietes.Id)
                {
                    Debug.Log("VCBN?QGDHQJKTEYQKGHDQJDS");
                    StartCoroutine(manager.GetComponent <GameManager>().CheckCards2choix(c, 1));
                    yield return(new WaitWhile(() => GameManager.pauseJeu2Choix));

                    paire = GameManager.gameCard2choix;
                }
            }


            if (paire == null)
            {                        //Si il n'y en a pas, on va aller poser la carte joueur dans un emplacement vide
                Debug.Log("Pas de paires");
                c.endPosition = PasdePaires(c);
                NoPaires      = true;
            }

            else
            {
                c.endPosition = paire.gameObject.transform.position;          //Si il y a une combinaison possible, on retourne la position de cette carte
                paire.transform.SetSiblingIndex(46);
            }
        }

        c.startPosition = c.gameObject.transform.position;
        c.journeyLength = Vector3.Distance(c.startPosition, c.endPosition);
        float distCovered = (Time.time - startTime) * speed;
        float fracJourney = distCovered / c.journeyLength;

        if (c.transform.position != c.endPosition)
        {
            iTween.MoveTo(c.gameObject, c.endPosition, 1.0f);
            yield return(null);

            StartCoroutine(TourJoueur(c));
        }

        else //une fois que le sprite a été bougé
        {
            manager.GetComponent <GameManager>().ResizeJeu();
            VousNePasserezPas3 = 0;
            if (NoPaires == false) //Si on a fait une combinaison, on doit maintenant ranger les cartes
            {
                StartCoroutine(RangerCartes(c, 1));
            }

            else    //Si on a pas fait de combinaisons, on ne range rien et on passe au tour de la pioche
            {
                tourPioche = true;
                NoPaires   = false;
                StartCoroutine(TourPioche());
            }

            startTime = Time.time;
        }
    }
Example #4
0
    public IEnumerator TourIA()
    {
        tourPioche        = false;
        VousNePasserezPas = 0;

        if (VousNePasserezPas3 == 0)
        {
            VousNePasserezPas3++;
            yield return(new WaitForSeconds(0.3f));

            if (MenuManager.typeJeu == 2)
            {
                manager.GetComponent <GameManager>().GriserBouttons(1, true);
                manager.GetComponent <GameManager>().GriserBouttons(2, false);
            }

            carteJoueeIA          = manager.GetComponent <GameManager>().IACarteToGameCard();
            carteJoueeIA.cardFace = manager.GetComponent <GameManager>().getCardFace(carteJoueeIA.cardValue);
            if (MenuManager.typeJeu == 1)
            {
                Vector3 patate2 = new Vector3(180, 180, 180);
                iTween.RotateTo(carteJoueeIA.gameObject, patate2, 0.5f);
                carteJoueeIA.GetComponent <Image>().sprite = carteJoueeIA.cardFace;
                manager.GetComponent <GameManager>().audioCardFlip.Play();
                yield return(new WaitForSeconds(0.5f));
            }



            NoPaires = false;

            paire = manager.GetComponent <GameManager>().checkCards(carteJoueeIA, 1);    //on regarde dans la défosse si y a une paire correspondante
            if ((manager.GetComponent <GameManager>().Pli2Choix == true))
            {
                Debug.Log("Pli 2 choix IA");
                StartCoroutine(manager.GetComponent <GameManager>().CheckCards2choix(carteJoueeIA, 1));
                yield return(new WaitWhile(() => GameManager.pauseJeu2Choix));

                paire = GameManager.gameCard2choix;
            }
            J1_humain = GameManager.J1_humain;
            J2_IA     = GameManager.J2_IA;
            carteJoueeIA.GetComponent <Button>().enabled = false;
            carteJoueeIA.transform.SetSiblingIndex(47);
            if (MenuManager.typeJeu == 1)
            {
                manager.GetComponent <GameManager>().DesactiverOuActiverBoutons(true);
            }

            if (paire != null)
            {
                if (paire.Proprietes.Id == carteJoueeIA.Proprietes.Id)
                {
                    Debug.Log("GFHDJKGSHFJDKGFHSJKGHSQJKHQJDK");
                    StartCoroutine(manager.GetComponent <GameManager>().CheckCards2choix(carteJoueeIA, 1));
                    yield return(new WaitWhile(() => GameManager.pauseJeu2Choix));

                    paire = GameManager.gameCard2choix;
                }
            }


            if (paire == null)
            {                        //Si il n'y en a pas, on va aller poser la carte joueur dans un emplacement vide
                carteJoueeIA.endPosition = PasdePaires(carteJoueeIA);
                NoPaires = true;
            }

            else
            {
                carteJoueeIA.endPosition = paire.gameObject.transform.position;          //Si il y a une combinaison possible, on retourne la position de cette carte
                paire.transform.SetSiblingIndex(46);
            }
        }

        carteJoueeIA.startPosition = carteJoueeIA.gameObject.transform.position;
        carteJoueeIA.journeyLength = Vector3.Distance(carteJoueeIA.startPosition, carteJoueeIA.endPosition);
        float distCovered = (Time.time - startTime) * speed;
        float fracJourney = distCovered / carteJoueeIA.journeyLength;

        if (carteJoueeIA.transform.position != carteJoueeIA.endPosition)
        {
            iTween.MoveTo(carteJoueeIA.gameObject, carteJoueeIA.endPosition, 1.0f);
            yield return(null);

            StartCoroutine(TourIA());
        }

        else    //une fois que le sprite a été bougé
        {
            manager.GetComponent <GameManager>().ResizeJeu();
            VousNePasserezPas3 = 0;
            isCliked           = false;
            if (NoPaires == false)  //Si on a fait une combinaison, on doit maintenant ranger les cartes
            {
                cptAudio = 0;
                StartCoroutine(RangerCartes(carteJoueeIA, 1));
            }

            else
            {                  //Si on a pas fait de combinaisons, on ne range rien et on passe au tour de la pioche
                tourPioche = true;
                NoPaires   = false;
                StartCoroutine(TourPioche());
            }

            startTime = Time.time;
        }
    }