示例#1
0
        public void mettreAJour()
        {
            DateTime      temps_actuel   = DateTime.Now;
            List <Joueur> joueurs_en_vie = joueurs.FindAll((j) => !j.estMort());

            // Si il ne reste aucun joueur en vie c'est la fin de la manche
            if (joueurs_en_vie.Count < 1)
            {
                if (tempsFinManche == DateTime.MinValue)
                {
                    tempsFinManche = temps_actuel;
                    // Arrêter la musique
                    Sfx.ArreterJouerMusique();
                }
            }
            // Si le temps est écoulé c'est la fin de la manche
            if (tempsImparti - (temps_actuel - tempsDebutManche).TotalSeconds < -1)
            {
                if (tempsFinManche == DateTime.MinValue)
                {
                    tempsFinManche = temps_actuel;
                    // Arrêter la musique
                    Sfx.ArreterJouerMusique();
                    // On joue le son temps_ecoule en cas de fin de manche par temps écoulé
                    Sfx.JouerSon("temps_ecoule");
                }
            }
            // Si il reste un joueur en vie il est déclaré vainqueur
            if (joueurs_en_vie.Count == 1)
            {
                if (tempsFinManche == DateTime.MinValue)
                {
                    tempsFinManche = temps_actuel;
                    // Arrêter la musique
                    Sfx.ArreterJouerMusique();
                    // Un joueur a gagné
                    raisonFinManche = joueurs_en_vie[0].getId();
                }
            }

            // On met à jour la map si la fin de manche n'est pas signalé
            if (tempsFinManche == DateTime.MinValue)
            {
                tempsRestant = tempsImparti - (long)(temps_actuel - tempsDebutManche).TotalSeconds;
                map.mettreAJour();
            }
            else
            {
                // On passe à la manche suivante au bout de 10 secondes
                if ((temps_actuel - tempsFinManche).TotalSeconds >= 10)
                {
                    tempsFinManche = DateTime.MinValue;
                    finDeLaManche();
                }
            }
        }
示例#2
0
        public Ecran_Titre() : base("TNTMan", null)
        {
            Size resolution = Gfx.getResolution();

            arrierePlan = Gfx.images["fond_ecran"];
            boutons.Add(new Bouton(0, resolution.Width / 2 - 100, resolution.Height / 2 - 100, 18, "Nouvelle Partie"));
            boutons.Add(new Bouton(1, resolution.Width / 2 - 100, resolution.Height / 2 - 50, 18, "Instructions"));
            //boutons.Add(new Bouton(2, resolution.Width / 2 - 100, resolution.Height / 2, 18, "Options"));
            boutons.Add(new Bouton(100, resolution.Width / 2 - 100, resolution.Height / 2 + 150, 18, "Quitter"));
            Sfx.ArreterJouerMusique();
            Sfx.JouerMusique("titre");
            boutonSel = 0;
        }
示例#3
0
        public Session(int nb_joueurs, int id_map, int nb_manches, long temps_imparti, long temps_mort_subite)
        {
            PointApparition pointApparition = null;

            musique = @"jeu_" + Program.random.Next(1, 3);
            joueurs = new List <Joueur>();
            map     = new Map();
            map.chargerMap(id_map);
            for (int i = 0; i < nb_joueurs; i++)
            {
                pointApparition = map.pointApparitions[i];
                switch (i)
                {
                case 0:
                    joueurs.Add(new Joueur(1, 0.5f + pointApparition.X, 0.5f + pointApparition.Y, map, SDL.SDL_Scancode.SDL_SCANCODE_W, SDL.SDL_Scancode.SDL_SCANCODE_S, SDL.SDL_Scancode.SDL_SCANCODE_A, SDL.SDL_Scancode.SDL_SCANCODE_D, SDL.SDL_Scancode.SDL_SCANCODE_E));
                    break;

                case 1:
                    joueurs.Add(new Joueur(2, 0.5f + pointApparition.X, 0.5f + pointApparition.Y, map, SDL.SDL_Scancode.SDL_SCANCODE_UP, SDL.SDL_Scancode.SDL_SCANCODE_DOWN, SDL.SDL_Scancode.SDL_SCANCODE_LEFT, SDL.SDL_Scancode.SDL_SCANCODE_RIGHT, SDL.SDL_Scancode.SDL_SCANCODE_RETURN));
                    break;

                case 2:
                    joueurs.Add(new Joueur(3, 0.5f + pointApparition.X, 0.5f + pointApparition.Y, map, SDL.SDL_Scancode.SDL_SCANCODE_U, SDL.SDL_Scancode.SDL_SCANCODE_J, SDL.SDL_Scancode.SDL_SCANCODE_H, SDL.SDL_Scancode.SDL_SCANCODE_K, SDL.SDL_Scancode.SDL_SCANCODE_I));
                    break;

                case 3:
                    joueurs.Add(new Joueur(4, 0.5f + pointApparition.X, 0.5f + pointApparition.Y, map, SDL.SDL_Scancode.SDL_SCANCODE_KP_5, SDL.SDL_Scancode.SDL_SCANCODE_KP_2, SDL.SDL_Scancode.SDL_SCANCODE_KP_1, SDL.SDL_Scancode.SDL_SCANCODE_KP_3, SDL.SDL_Scancode.SDL_SCANCODE_KP_6));
                    break;

                default:
                    Program.MessageErr("Nombre de joueurs incorrect!");
                    break;
                }
            }
            foreach (var joueur in joueurs)
            {
                map.ajoutEntite(joueur);
            }
            mancheActuelle   = 1;
            nbManches        = nb_manches;
            tempsDebutManche = DateTime.Now;
            tempsImparti     = temps_imparti;
            tempsMortSubite  = temps_mort_subite;
            Sfx.ArreterJouerMusique();
            Sfx.JouerMusique(musique);
        }