Beispiel #1
0
 public switch_map(GamePlayer Player/*, gamemain Main*/, Donjon donjon, string directori)
 {
     player = Player;
     //main = Main;
        Directorie = directori;
     listes_map = new Map[5, 5];
     for (int i = 0; i < 5; i++)
         for (int j = 0; j < 5; j++)
             listes_map[i, j] = donjon.Map[i, j];
     x = (int)donjon.map.X;
     y = (int)donjon.map.Y;
     active_map = listes_map[x, y];
        // active_map.mob = donjon.Map[x, y].mob;
        // active_map.load_mob(@"Donjons\" + @Directorie + @"\Map" + active_map.Nb + @"\creature" + @".txt", main);
 }
Beispiel #2
0
 //creer le donjon (le dossier + la premiere map)
 public void creation_donjon(string path)
 {
     try
     {
         string nombre;
         if (nb < 10)
             nombre = "0" + Convert.ToString(nb);
         else
             nombre = Convert.ToString(nb);
         System.IO.Directory.CreateDirectory(@"Donjons\" + @text.Saisie + @"\Map" + @nombre);
         Stream sr = new FileStream(@"Donjons\" + @text.Saisie + @"\autre.txt", FileMode.Create);
         sr.Close();
         Donjon = new Donjon(path, true);
         Donjon.Ajout_map(0, 0, 0, text.Saisie);
         text.Is_shown = false;
     }
     catch (Exception)
     {
         //l'affiche sur la deuxieme sortie car sinon ca valide
         message.Saisie = op3;
     }
 }
Beispiel #3
0
 public void SendDungeon(Donjon donj)
 {
     Sentstream = Client.GetStream();
     BinaryWriter t = new BinaryWriter(Sentstream);
     for (int i = 0; i < 5; i++)
     {
         for (int j = 0; j < 5; j++)
         {
             if (donj.Map[i, j] != null)
             {
                 t.Write(1);
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].Coffres);
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].colision);
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].mob);
                 t.Write(donj.Map[i, j].monstre.Count);
                 foreach (NPC q in donj.Map[i, j].monstre)
                 {
                     t.Write(q.Frame_start);
                     Serialiseur.Serialize(Sentstream, q.position);
                 }
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].objet);
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].tiles);
                 Serialiseur.Serialize(Sentstream, donj.Map[i, j].Tilelist);
             }
             else
             {
                 t.Write(0);
             }
         }
     }
     Serialiseur.Serialize(Sentstream, donj.map);
     Serialiseur.Serialize(Sentstream, donj.position_J);
 }
Beispiel #4
0
 public Donjon ReceiveDungeon(gamemain main)
 {
     Thread.Sleep(500);
     MemoryStream m = new MemoryStream();
     Donjon sol = new Donjon();
     Sentstream = client.GetStream();
     BinaryReader t;
     for (int i = 0; i < 5; i++)
     {
         for (int j = 0; j < 5; j++)
         {
             t = new BinaryReader(Sentstream);
             if (t.ReadInt32() == 1)
             {
                 Map transit = new Map();
                 transit.Coffres = /*(Templar.Coffre[,])*/Serialiseur.Deserialize(Sentstream) as Templar.Coffre[,];
                 transit.colision = (int[,])Serialiseur.Deserialize(Sentstream);
                 transit.mob = (Vector2[,])Serialiseur.Deserialize(Sentstream);
                 int caca = t.ReadInt32();
                 for (int k = 0; k < caca; k++)
                 {
                     int a = t.ReadInt32();
                     Vector2 re = (Vector2)Serialiseur.Deserialize(Sentstream);
                     transit.monstre.Add(new NPC(32, 48, 4, 3, a, 15, 2, re, ressource.mob, main.player, transit));
                 }
                 transit.objet = (Vector2[,])Serialiseur.Deserialize(Sentstream);
                 transit.tiles = (Vector2[,])Serialiseur.Deserialize(Sentstream);
                 transit.Tilelist = (Tile[,])Serialiseur.Deserialize(Sentstream);
                 sol.Map[i, j] = transit;
             }
             else
                 sol.Map[i, j] = null;
         }
     }
     sol.map = (Vector2)Serialiseur.Deserialize(client.GetStream());
     sol.position_J = (Vector2)Serialiseur.Deserialize(client.GetStream());
     return sol;
 }
Beispiel #5
0
        public gamemain(Game game, SpriteBatch spriteBatch, GameScreen activescreen, Donjon donjon, bool is2p, string ip, string name_donjon, bool language)
            : base(game, spriteBatch)
        {
            victoire = false;
            langue = language;
            nom_donjon = name_donjon;
            fenetre = new Rectangle(0, 0, game.Window.ClientBounds.Width, game.Window.ClientBounds.Height); //taille de la fenetre
            text = new textbox(new Rectangle(0, 18 * 32 + 7, 200, 100));
            text.Is_shown = false;
            #region init du jeu
            x = new Random();
            keyboard = new KeyboardState();
            liste_sort = new List<sort>();
            //ICI POUR LOADMOB
            //FIN ICI
            Walls = new List<wall>();
            personnage = new List<Personnage>();
            liste_objet_map = new List<potion>();
            if (is2p)
            {
                position_joueur = new Vector2(32, 32);
                localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language);
                localPlayer.Niveau = 1;
            }
            if (!is2p)
            {
                position_joueur = donjon.position_J;
                localPlayer = new GamePlayer(32, 48, 4, 8, 2, 15, 2, position_joueur, ressource.sprite_player, this, text, language);
                localPlayer.Niveau = 1;
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (donjon.Map[i, j] != null)
                            donjon.Map[i, j].load_mob(@"Donjons\" + @name_donjon + @"\Map" + donjon.Map[i, j].Nb + @"\creature" + @".txt", this);
                    }
                }
            }
            donj = donjon;

            if (!is2p)
            {

                map = new switch_map(localPlayer/*, this*/, donjon, name_donjon);
                map.x = (int)donjon.map.X;
                map.y = (int)donjon.map.Y;
                mapx = map.x;
                mapy = map.y;
                list_zombi = map.Active_Map.monstre;
                HUD = new HUD(localPlayer, this);
            }
            pop_time = 0;
            score = 0;
            count_dead_zombi = 0;
            #endregion init du jeu
            # region media_player;
            MediaPlayer.Play(ressource.main_theme);
            MediaPlayer.Volume = 0.56f;
            MediaPlayer.IsRepeating = true;
            # endregion
            noir.A = 200;
            noir.B = noir.G = noir.R = 0;
            white = Color.White;
            white.A = 120;
            effect = new BasicEffect(game.GraphicsDevice);
            same_map = true;
        }