public void Update(float timer)
        {
            if (!_out_of_time && !_adversaire_refuse && !_ping_partie)
            {
                if (_timer.IncreaseTimer(timer))
                {
                    _server.Client_Valid_Or_Refuse_Game(_id, _id_partie_found, _code, "0");
                    _out_of_time = true;
                    _ping_partie = false;
                    Reset_Bouton_Phase_2();
                }
            }

            if (_server.Echange_en_cours)
            {
                _loading.Update(timer);
            }
            if (_server.Info_Attente_Check())
            {
                string   blbl = _server.Recuperer_Info();
                string[] data = blbl.Split(' ');
                if (data [0] == "ok")
                {
                    statut = Statut_Pop_Up.Refuse;
                }
                else if (data [0] == "ERREUR" || data [0] == "4")
                {
                    _out_of_time = true;
                    _ping_partie = false;
                    Reset_Bouton_Phase_2();
                }
                else if (data [0] == "3")
                {
                    _adversaire_refuse = true;
                    _ping_partie       = false;
                    Reset_Bouton_Phase_2();
                }
                else if (data [0] == "2")
                {
                    statut = Statut_Pop_Up.Partie_found;
                    data_game.Add(data [1]);
                    data_game.Add(data [2]);
                    data_game.Add(data [3]);
                    data_game.Add(data [4]);
                    data_game.Add(data [5]);
                    data_game.Add(data [6]);
                    data_game.Add(data [7]);
                }
                else if (data [0] == "1")
                {
                    _ping_partie = true;
                }
            }

            if (_ping_partie && _timer_ping.IncreaseTimer(timer))
            {
                _server.Client_Valid_Or_Refuse_Game(_id, _id_partie_found, _code, "1");
            }
        }
예제 #2
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.ExitScreen();
                ScreenManager.AddScreen(new Name_Screen(true));
            }

            float timer = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (server.Test_Connection(timer))
            {
                server.CloseConnection();
            }

            Execution_Screen();
            transition.Update_Transition(timer);


            if (server.Info_Attente_Check())
            {
                string   data       = server.Recuperer_Info();
                string[] data_array = data.Split(' ');


                if (id != null)
                {
                    if (data_array [0] == "false")
                    {
                        id = null;
                        Random _rand = new Random();
                        int    blblb = _rand.Next(1, 1000000);
                        if (langue.lang == "FR")
                        {
                            IsolatedStorageSettings.ApplicationSettings ["name"] = "Joueur" + blblb.ToString();
                            player_name = "Joueur" + blblb.ToString();
                        }
                        else
                        {
                            IsolatedStorageSettings.ApplicationSettings ["name"] = "Guest" + blblb.ToString();
                            player_name = "Guest" + blblb.ToString();
                        }
                        server.Check_Name(player_name);
                    }
                    else
                    {
                        for (int i = 0; i < data_array.Length; i++)
                        {
                            if (data_array [i] == null)
                            {
                                data_array [i] = "0";
                            }
                        }

                        red_win     = data_array [0];
                        green_win   = data_array [1];
                        player_game = data_array [2];
                        player_win  = data_array [3];
                        player_elo  = data_array [4];
                        player_rank = data_array [5];

                        IsolatedStorageSettings.ApplicationSettings ["red_win"]     = red_win;
                        IsolatedStorageSettings.ApplicationSettings ["green_win"]   = green_win;
                        IsolatedStorageSettings.ApplicationSettings ["elo"]         = player_elo;
                        IsolatedStorageSettings.ApplicationSettings ["player_game"] = player_game;
                        IsolatedStorageSettings.ApplicationSettings ["rank"]        = player_rank;
                        IsolatedStorageSettings.ApplicationSettings ["player_win"]  = player_win;

                        //ADRESS PORT SERVER
                        if (data_array.Length > 6)
                        {
                            IsolatedStorageSettings.ApplicationSettings ["adresse_ip"] = data_array [6];
                            IsolatedStorageSettings.ApplicationSettings ["port"]       = data_array [7];
                        }
                    }
                }
                else if (!_name_check)
                {
                    if (data_array [0] == "false")
                    {
                        _name_check = true;
                        server.Nouveau_Joueur(player_name, side);
                    }
                    else
                    {
                        Random _rand = new Random();
                        int    blblb = _rand.Next(1, 1000000);
                        if (langue.lang == "FR")
                        {
                            IsolatedStorageSettings.ApplicationSettings ["name"] = "Joueur" + blblb.ToString();
                            player_name = "Joueur" + blblb.ToString();
                        }
                        else
                        {
                            IsolatedStorageSettings.ApplicationSettings ["name"] = "Guest" + blblb.ToString();
                            player_name = "Guest" + blblb.ToString();
                        }
                        server.Check_Name(player_name);
                    }
                }
                else if (_name_check && !_envoie_name)
                {
                    string code = "0";                     //ASSIGNE
                    id   = data_array [0].ToString();
                    code = data_array [1].ToString();
                    IsolatedStorageSettings.ApplicationSettings ["id"]   = id;
                    IsolatedStorageSettings.ApplicationSettings ["code"] = code;
                }
            }

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
예제 #3
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            float timer = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            _no_co.Update(timer, server);

            //KEYBOARD
            if (_statut_bouton == Statut_Bouton.Normal || _statut_bouton == Statut_Bouton.Attente_Confirmation || _statut_bouton == Statut_Bouton.Deja_Pris)
            {
                if (keyboard._tapped)
                {
                    if (keyboard._type_tapped == Keyboard.TypeLettre.Lettre)
                    {
                        if (_name.Length < nombre_max_name)
                        {
                            if (_name.Length == 0)
                            {
                                keyboard.Changer_en_MIN();
                                isMaj = false;
                            }
                            _name += keyboard._letter_tapped;
                            _error_nbr_letters = false;
                            if (_statut_bouton == Statut_Bouton.Deja_Pris || _statut_bouton == Statut_Bouton.Attente_Confirmation)
                            {
                                Statut_Normal();
                            }
                        }
                        else
                        {
                            _error_trop_de_letters = true;
                        }
                    }
                    else if (keyboard._type_tapped == Keyboard.TypeLettre.Effacer)
                    {
                        if (_name.Length > 0)
                        {
                            _name = _name.Remove(_name.Length - 1, 1);
                            if (_statut_bouton == Statut_Bouton.Attente_Confirmation || _statut_bouton == Statut_Bouton.Deja_Pris)
                            {
                                Statut_Normal();
                            }
                        }
                    }
                    else if (keyboard._type_tapped == Keyboard.TypeLettre.Maj_Min)
                    {
                        Inverser_MAJ();
                    }

                    keyboard.Reboot_Variable();
                }
            }

            if (server.Info_Attente_Check())
            {
                if (_statut_bouton == Statut_Bouton.Attente_Verification)
                {
                    string data   = server.Recuperer_Info();
                    bool   result = false;

                    if (data == "true")
                    {
                        result = true;
                    }
                    else if (data == "false")
                    {
                        result = false;
                    }

                    if (result)
                    {
                        Statut_Already_Take();
                    }
                    else
                    {
                        Statut_Bon();
                    }
                }
                else if (_statut_bouton == Statut_Bouton.Envoie_Confirmation)
                {
                    string   data       = server.Recuperer_Info();
                    string[] data_array = data.Split(' ');

                    string id = "0", code = "0";                     //ASSIGNE
                    id   = data_array [0].ToString();
                    code = data_array [1].ToString();
                    IsolatedStorageSettings.ApplicationSettings ["id"]   = id;
                    IsolatedStorageSettings.ApplicationSettings ["code"] = code;

                    Valider();
                }
            }

            if (_name.Length < nombre_max_name)
            {
                _error_trop_de_letters = false;
            }

            if (_loading != null & _statut_bouton == Statut_Bouton.Attente_Verification || _statut_bouton == Statut_Bouton.Envoie_Confirmation)
            {
                _loading.Update(timer);
            }

            keyboard.Update_Timer(timer);

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.ExitScreen();
                ScreenManager.AddScreen(new MainMenuScreen());
            }

            float timer = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            transition.Update_Transition(timer);

            _no_co.Update(timer, server);

            if (!popup.is_active)
            {
                _loading.Update(timer);
            }
            else
            {
                GestionFin_Popup();
                popup.Update(timer);
            }

            if (!popup.is_active)
            {
                if (server.Info_Attente_Check())
                {
                    string   blbl = server.Recuperer_Info();
                    string[] data = blbl.Split(' ');

                    if (!is_dans_salle_attente)
                    {
                        if (data [0] == "true")
                        {
                            is_dans_salle_attente = true;
                            server.Verifier_Partie_trouver(_id, _code);
                        }
                        else
                        {
                            server.Ajout_Joueur_Liste_Attente(_id, _code);
                        }
                    }
                    else
                    {
                        if (data [0] == "true")
                        {
                            Adversaire_Found(data [1]);
                        }
                    }
                }
                if (is_dans_salle_attente)
                {
                    if (!server.Echange_en_cours && _timer_ping_partie.IncreaseTimer(timer))
                    {
                        server.Verifier_Partie_trouver(_id, _code);
                    }
                }
            }



            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }