Example #1
0
File: Map.cs Project: kylox/Templar
 public Map()
 {
     monstre = new List<NPC>();
     prev_coffre = new Coffre(new Vector2(0, 0));
     tiles = new Vector2[25, 18];
     objet = new Vector2[25, 18];
     Coffres = new Coffre[25, 18];
     for (int i = 0; i < objet.GetLength(0); i++)
         for (int j = 0; j < objet.GetLength(1); j++)
             objet[i, j] = new Vector2(15, 15);
     tilelist = new Tile[25, 18];
     colision = new int[25, 18];
     mob = new Vector2[25, 18];
     iscreate = false;
     visited = false;
     message = "";
     isfirst = false;
 }
Example #2
0
        public void action(switch_map map)
        {
            XmlReader reader;

            reader = XmlReader.Create("Francais.xml");
            if (!langue)
            {
                reader = XmlReader.Create("English.xml");
            }
            string op1 = "", op2 = "";
            while (reader.Read())
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    reader.Read();
                    if (reader.Name == "bouquins")
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                            if (reader.NodeType == XmlNodeType.Text)
                                op1 = reader.Value.ToString();
                        }
                        reader.Read();
                    }
                    if (reader.Name == "tonneaux")
                    {
                        while (reader.NodeType != XmlNodeType.EndElement)
                        {
                            reader.Read();
                            if (reader.NodeType == XmlNodeType.Text)
                                op2 = reader.Value.ToString();
                        }
                        reader.Read();
                    }
                }
            if (Data.keyboardState.IsKeyDown(Keys.E) && Data.prevKeyboardState.IsKeyUp(Keys.E))
            {
                if (main.princess != null && position == main.princess.position)
                    main.victoire = true;
                switch (frameline)
                {
                    // en haut
                    case 3:

                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(2, 2))
                        {
                            text.Is_shown = true;
                            text.Saisie = op1;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 - 1] == new Vector2(0, 0))
                        {
                            map.Active_Map.Coffres[(int)position.X / 32, (int)position.Y / 32 - 1].is_open = true;
                            Coffre_ouvert = map.Active_Map.Coffres[(int)position.X / 32, (int)position.Y / 32 - 1];
                            in_action = true;
                        }
                        break;
                    // en bas
                    case 1:
                        if (map.Active_Map.objet[(int)position.X / 32, (int)position.Y / 32 + 1] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                    // a gauche
                    case 2:
                        if (map.Active_Map.objet[(int)position.X / 32 - 1, (int)position.Y / 32] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                    // a droite
                    case 4:
                        if (map.Active_Map.objet[(int)position.X / 32 - 1, (int)position.Y / 32] == new Vector2(0, 3))
                        {
                            text.Is_shown = true;
                            text.Saisie = op2;
                            text.Fenetre.Width = (int)ressource.ecriture.MeasureString(text.Saisie).X + 10;
                        }
                        break;
                }
            }
        }
Example #3
0
File: Map.cs Project: kylox/Templar
 public void Update(GameTime gametime, string path, string path_coll, string path_message, string path_mob, string path_box, string path_coffre, textbox text)
 {
     lastKeyboardState = keyboardState;
     keyboardState = Keyboard.GetState();
     if (Data.mouseState.RightButton == ButtonState.Pressed &&
         Data.prevMouseState.RightButton == ButtonState.Released &&
         new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 0, 16 * 25, 16 * 18))
         && text.Is_shown == false)
     {
         if (Coffres[Data.mouseState.X / 16, Data.mouseState.Y / 16] != null)
         {
             cursor.position = false;
             cursor.selected = false;
             cursor.selec_obj = false;
             if (active_coffre != null)
                 active_coffre.is_open = false;
             prev_coffre = active_coffre;
             cursor.selec_obj = false;
             cursor.selected_mob = false;
             Coffres[Data.mouseState.X / 16, Data.mouseState.Y / 16].is_open = true;
             active_coffre = Coffres[Data.mouseState.X / 16, Data.mouseState.Y / 16];
         }
     }
     if (Data.mouseState.LeftButton == ButtonState.Pressed &&
         Data.prevMouseState.LeftButton == ButtonState.Released &&
         !new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(100, 100, 32 * 5, 32 * 5))
         && !new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(27 * 16, 48, 32 * 7, 32 * 7))
         && text.Is_shown == false && cursor.position == false && active_coffre != null && active_coffre.is_open == true)
     {
         active_coffre.is_open = false;
     }
     else
         if (Data.mouseState.LeftButton == ButtonState.Pressed &&
             Data.prevMouseState.LeftButton == ButtonState.Released &&
             new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 0, 16 * 25, 16 * 18))
             && text.Is_shown == false && cursor.position == false && cursor.selected == true)
         {
             objet[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = cursor.iD;
             if (cursor.iD != new Vector2(0, 2) && cursor.iD != new Vector2(1, 2) &&
                 cursor.iD != new Vector2(0, 4) && cursor.iD != new Vector2(0, 7) &&
                 cursor.iD != new Vector2(0, 5) && cursor.iD != new Vector2(1, 4) &&
                 cursor.iD != new Vector2(0, 6) && cursor.iD != new Vector2(1, 7) &&
                 cursor.iD != new Vector2(1, 6) && cursor.iD != new Vector2(1, 5) &&
                 cursor.iD != new Vector2(1, 0) && cursor.iD != new Vector2(1, 4) &&
                 cursor.iD != new Vector2(2, 0))
             {
                 // tilelist[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = new Tile((int)cursor.iD.X, (int)cursor.iD.Y, 1);
                 colision[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = 1;
                 if (cursor.iD == new Vector2(0, 0))
                 {
                     Coffres[Data.mouseState.X / 16, Data.mouseState.Y / 16] = new Coffre(new Vector2(Data.mouseState.X - Data.mouseState.X % 32, Data.mouseState.Y - Data.mouseState.Y % 32));
                     cursor.ecrire_coffre(path_coffre, this);
                 }
             }
             else
             {
                 // tilelist[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = new Tile((int)cursor.iD.X, (int)cursor.iD.Y, 0);
                 colision[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = 0;
             }
             cursor.ecrire_coffre(path_coffre, this);
             ecrire_objet(path);
             ecrire_coll(path_coll);
             ecrire_message(path_message);
             ecrire_box(path_box);
         }
         else
             if (Data.mouseState.LeftButton == ButtonState.Pressed &&
                Data.prevMouseState.LeftButton == ButtonState.Released &&
                new Rectangle(Data.mouseState.X, Data.mouseState.Y, 1, 1).Intersects(new Rectangle(0, 0, 16 * 25, 16 * 18))
                && text.Is_shown == false && cursor.position == false && cursor.selected_mob == true)
             {
                 mob[(int)(Data.mouseState.X) / 16, (int)(Data.mouseState.Y) / 16] = cursor.iD;
                 ecrire_mob(path_mob);
             }
 }
Example #4
0
 public void load_objet(string path, Coffre coffre)
 {
     StreamReader sr = new StreamReader(path);
     int j = 0;
     string ligne = "";
     while ((ligne = sr.ReadLine()) != null)
     {
         for (int i = 0; i < ligne.Length; i++)
         {
             if (ligne[i] != cursor.vec_to_id(new Vector2(15, 15)))
                 coffre.tab[i, j] = new Items(cursor.id_to_vec(Convert.ToChar(ligne[i])), cursor.langue);
         }
         j++;
     }
 }