Exemple #1
0
 public override bool Detruire(Joueur joueur)
 {
     joueur.AjouterItem(new Terre_Item(1));
     return(true);
 }
Exemple #2
0
        public override Entite Charger(string path)
        {
            string name = File.ReadAllLines(path + "\\info.txt")[0];

            string[] coord = name.Split('/');
            Joueur   j     = new Joueur(float.Parse(coord[0]), float.Parse(coord[1]), int.Parse(coord[2]), float.Parse(coord[3]), int.Parse(coord[4])
                                        , new Inventaire(path + "\\INVENTAIRE.2.3"), new Inventaire(path + "\\BARRE.1.3"), new Inventaire(path + "\\CRAFT.2.2"));

            string[] folder = Directory.GetDirectories(path);
            if (!Directory.Exists(path + "\\Casque.null"))
            {
                foreach (string n in folder)
                {
                    string[] h = n.Split('\\');
                    string[] t = h[h.Length - 1].Split('.');
                    if (t[0] == "Casque")
                    {
                        j.casque = Item.Items()[t[1]].Charger(n) as Casque;
                        break;
                    }
                }
            }
            if (!Directory.Exists(path + "\\Plastron.null"))
            {
                foreach (string n in folder)
                {
                    string[] h = n.Split('\\');
                    string[] t = h[h.Length - 1].Split('.');
                    if (t[0] == "Plastron")
                    {
                        j.plastron = Item.Items()[t[1]].Charger(n) as Plastron;
                        break;
                    }
                }
            }
            if (!Directory.Exists(path + "\\Jambiere.null"))
            {
                foreach (string n in folder)
                {
                    string[] h = n.Split('\\');
                    string[] t = h[h.Length - 1].Split('.');
                    if (t[0] == "Jambiere")
                    {
                        j.jambiere = Item.Items()[t[1]].Charger(n) as Jambiere;
                        break;
                    }
                }
            }
            if (!Directory.Exists(path + "\\Botte.null"))
            {
                foreach (string n in folder)
                {
                    string[] h = n.Split('\\');
                    string[] t = h[h.Length - 1].Split('.');
                    if (t[0] == "Botte")
                    {
                        j.botte = Item.Items()[t[1]].Charger(n) as Botte;
                        break;
                    }
                }
            }
            return(j);
        }
Exemple #3
0
 public override Tuple <Ecrans, object> CliqueDroite(Joueur joueur)
 {
     return(new Tuple <Ecrans, object>(Ecrans.Marchand, this));
 }
Exemple #4
0
 public override Tuple <bool, Tuple <Ecrans, object> > CliqueDroite(Joueur joueur, int bx, int by, Block block, Entite entite, Monde monde)
 {
     //TODO : systeme de paré(se proteger)
     return(new Tuple <bool, Tuple <Ecrans, object> >(true, null));
 }
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="joueur"></param>
 /// <param name="bx"></param>
 /// <param name="by"></param>
 /// <param name="block"></param>
 /// <param name="monde"></param>
 /// <returns>true si effectue le clique droit sur block / entite</returns>
 public virtual Tuple <bool, Tuple <Ecrans, object> > CliqueDroite(Joueur joueur, int bx, int by, Block block, Entite entite, Monde monde)
 {
     return(new Tuple <bool, Tuple <Ecrans, object> >(true, null));
 }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="joueur"></param>
 /// <param name="bx"></param>
 /// <param name="by"></param>
 /// <param name="block"></param>
 /// <param name="monde"></param>
 /// <returns>
 /// true si effectue le clique droit sur block / entite</br>
 /// null pour rester dans l'ecran</br>
 /// </returns>
 public virtual Tuple <bool, Tuple <Ecrans, object> > CliqueGauche(Joueur joueur, int bx, int by, Block block, Entite entite, Monde monde)
 {
     //Attaquer et creuser
     return(new Tuple <bool, Tuple <Ecrans, object> >(true, null));
 }
Exemple #7
0
 public override Tuple <bool, Tuple <Ecrans, object> > CliqueDroit(Joueur joueur)
 {
     return(new Tuple <bool, Tuple <Ecrans, object> >(true, new Tuple <Ecrans, object>(Ecrans.Inventaire, new Inventaire[] { inventaire, joueur.Inventaire, joueur.Barre })));
 }
Exemple #8
0
 public override Tuple <bool, Tuple <Ecrans, object> > CliqueDroite(Joueur joueur, int bx, int by, Block block, Entite entite, Monde monde)
 {
     //ouvre inventaire
     return(new Tuple <bool, Tuple <Ecrans, object> >(false, new Tuple <Ecrans, object>(Ecrans.Inventaire, new Inventaire[] { inventaire, joueur.Inventaire, joueur.Barre })));
 }
Exemple #9
0
 public override bool Detruire(Joueur joueur)
 {
     return(false);
 }
Exemple #10
0
 /// <summary>
 /// qu'est-ce que le block veux faire avant de ce faire mettre a null</br>
 /// ce mettre dans l'inventaire du joueur (par default)</br>
 /// </summary>
 /// <param name="joueur"></param>
 /// <returns>si tu peux le mettre a null</returns>
 public abstract bool Detruire(Joueur joueur);
Exemple #11
0
 /// <summary>
 /// event clique droit
 /// </summary>
 /// <param name="joueur"></param>
 /// <returns>null ou le ChangerEcrans que tu doit faire</returns>
 public virtual Tuple <bool, Tuple <Ecrans, object> > CliqueDroit(Joueur joueur)
 {
     return(null);
 }
Exemple #12
0
        /// <summary>
        /// Permet de Charger un monde</br>
        /// System.IO.Directory.GetCurrentDirectory() pour recuperer le dossier de l'application</br>
        /// le monde recuperer (si le dossier du monde exists) il sera dans Sauvegarde.monde</br>
        /// le joueur sera initer avec le monde
        /// </summary>
        /// <param name="path"></param>
        public static void ChargerMonde(string path)
        {
            if (Directory.Exists(path))
            {
                string[]   mondeOptions = File.ReadAllLines(path + "\\info.txt");
                long       seed         = long.Parse(mondeOptions[1].Split(':')[1]);
                Generateur generateur   = null;
                switch (mondeOptions[0].Split(':')[1])
                {
                case "GenerateurParDefault":
                    generateur = new GenerateurParDefault(new Noise(seed));
                    break;

                case "VoidGenerateur":
                    generateur = new VoidGenerateur(new Noise(seed));
                    break;

                case "FlatGenerateur":
                    generateur = new FlatGenerateur(new Noise(seed));
                    break;
                }
                if (generateur != null)
                {
                    string[] ents = Directory.GetDirectories(path + "\\Entities");
                    int      max  = -1;
                    List <KeyValuePair <int, Entite> > entities = new List <KeyValuePair <int, Entite> >();
                    foreach (string entpath in ents)
                    {
                        string[] n   = entpath.Split('\\');
                        string[] a   = n[n.Length - 1].Split('.');
                        Entite   ent = Entite.Entites()[a[1]].Charger(entpath);
                        int      i   = int.Parse(a[0]);
                        if (i > max)
                        {
                            max = i;
                        }
                        entities.Add(new KeyValuePair <int, Entite>(i, ent));
                        if (ent is Joueur j)
                        {
                            joueur = j;
                        }
                    }

                    Entite[] entites = new Entite[max + 1];
                    foreach (KeyValuePair <int, Entite> ent in entities)
                    {
                        entites[ent.Key] = ent.Value;
                    }

                    monde = new Monde(generateur, entites.ToList());

                    string[] chunks = Directory.GetDirectories(path + "\\Chunks");
                    foreach (string cpath in chunks)
                    {
                        string[] blocksFile = Directory.GetDirectories(cpath);

                        Block[,] blocks = new Block[16, 16];

                        foreach (string blockfile in blocksFile)
                        {
                            string[] bnom   = blockfile.Split('\\');
                            string[] bcoord = bnom[bnom.Length - 1].Split('.');
                            int      bx     = int.Parse(bcoord[0]);
                            int      by     = int.Parse(bcoord[1]);
                            Block    block  = Block.Blocks()[bcoord[2]].Charger(blockfile);
                            blocks[bx, by] = block;
                        }

                        string[] cnom    = cpath.Split('\\');
                        string[] coord   = cnom[cnom.Length - 1].Split('.');
                        int      cx      = int.Parse(coord[0]);
                        int      cy      = int.Parse(coord[1]);
                        bool     generer = bool.Parse(coord[2]);
                        monde.SetChunk(cx, cy, new Chunk(blocks, generer));
                    }
                }
            }
        }
Exemple #13
0
 public override Tuple <bool, Tuple <Ecrans, object> > CliqueDroit(Joueur joueur)
 {
     return(new Tuple <bool, Tuple <Ecrans, object> >(true, new Tuple <Ecrans, object>(Ecrans.Four, new KeyValuePair <Four_Block, Inventaire[]>(this, new Inventaire[] { inventaire, joueur.Inventaire, joueur.Barre }))));
 }