Exemplo n.º 1
0
        static void Main()
        {
            string optionPath = System.IO.Directory.GetCurrentDirectory() + "\\Option.txt";

            if (System.IO.File.Exists(optionPath))
            {
                Sauvegarde.ChargerOption(optionPath);
            }
            else
            {
                Sauvegarde.SauvegarderOption(optionPath);
            }

            Sauvegarde.ChargerMonde(System.IO.Directory.GetCurrentDirectory() + "\\Mon_Monde");

            if (Sauvegarde.monde == null)
            {
                Memoire.CreateWorld();
            }


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Memoire.form = new Minecrafting();
            EcranDeJeu.ChangerEcran(Ecrans.Jeu, null);
            EcranDeJeu.Afficher(Sauvegarde.joueur, Sauvegarde.monde);
            Application.Run(Memoire.form);
        }
Exemplo n.º 2
0
        public void DansAutreInventaire(List <UI_Item> Uitems)
        {
            Inventaire inv  = EcranDeJeu.inventaires[0];
            UI_Item    anul = null;

            foreach (UI_Item init in Uitems)
            {
                Point p  = Memoire.ScreenToInv(init.Location.X, init.Location.Y);
                int   ix = (p.X - 7) / 18;
                int   iy = ((p.Y - 53) / 18) * -1;
                if (ix >= 0 && ix < inv.Longueur && iy >= 0 && iy < inv.Hauteur)
                {
                    int i = ix + (iy * inv.Longueur);
                    if (inv.Nom == "SacADos" && init.item != null && init.item.id() == "SacADos")
                    {
                        anul = init;
                        continue;
                    }
                    inv.SetItem(i, init.item);
                }
            }
            if (anul != null)
            {
                AnnulerMove(anul);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nx"></param>
        /// <returns> true si le joueur est bloquee</returns>
        private bool BougerThread(float nx, int ny)
        {
            //nx /= 1.25f;
            bool a = Sauvegarde.joueur.Bouger(nx, ny, Sauvegarde.monde);

            if (Sauvegarde.joueur.Vie <= 0)
            {
                Memoire.CreateWorld();
                return(true);
            }
            return(a);
        }
Exemplo n.º 4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //20 tick second
            if (Sauvegarde.joueur.Faim == 0)
            {
                if (Sauvegarde.joueur.Vie == 0)
                {
                    Memoire.CreateWorld();
                    return;
                }
                else
                {
                    Sauvegarde.joueur.Vie -= 0.01f;
                }
            }
            else
            {
                Sauvegarde.joueur.Faim -= 0.01f;
            }

            bool actu = false;

            foreach (Entite ent in Sauvegarde.monde.Entites)
            {
                if (ent.Comportement(Sauvegarde.monde))
                {
                    actu = true;
                }
            }

            if (EcranDeJeu.Ecran == Ecrans.Jeu)
            {
                //des fois il faisait des erreur et crashait
                try
                {
                    EcranDeJeu.ActuHotBarre();
                }
                catch (Exception)
                {
                }
            }
            if (actu)
            {
                Actualiser();
            }
        }
Exemplo n.º 5
0
        public void DansFour(List <UI_Item> Uitems)
        {
            UI_Item[] inv = new UI_Item[3];
            foreach (UI_Item init in Uitems)
            {
                Point p = Memoire.ScreenToInv(init.Location.X, init.Location.Y);
                if (p.X == 55)
                {
                    if (p.Y == 16)
                    {
                        EcranDeJeu.four.Inventaire.SetItem(0, init.item);
                        inv[0] = init;
                    }
                    else if (p.Y == 52)
                    {
                        EcranDeJeu.four.Inventaire.SetItem(1, init.item);
                        inv[1] = init;
                    }
                }
                if (p.X == 116 && p.Y == 35)
                {
                    EcranDeJeu.four.Inventaire.SetItem(2, init.item);
                    inv[2] = init;
                }
            }
            if (inv[0] != null && inv[1] != null && inv[2] != null)
            {
                EcranDeJeu.four.Update();

                for (int i = 0; i <= 2; i++)
                {
                    Memoire.items.Remove(inv[i]);
                    Memoire.form.Controls.Remove(inv[i]);
                }

                UI_Item it1 = new UI_Item(EcranDeJeu.four.Inventaire.GetItem(0), Memoire.InvToScreen(55, 16));
                Memoire.items.Add(it1);
                Memoire.form.Controls.Add(it1);
                UI_Item it2 = new UI_Item(EcranDeJeu.four.Inventaire.GetItem(1), Memoire.InvToScreen(55, 52));
                Memoire.items.Add(it2);
                Memoire.form.Controls.Add(it2);
                UI_Item it3 = new UI_Item(EcranDeJeu.four.Inventaire.GetItem(2), Memoire.InvToScreen(116, 35));
                Memoire.items.Add(it3);
                Memoire.form.Controls.Add(it3);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// place les items du joueur sur l'ecran
        /// </summary>
        public static void OuvrireInventaire()
        {
            Memoire.items = new List <UI_Item>();
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Barre.GetItem(0), Memoire.InvToScreen(7, 141)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Barre.GetItem(1), Memoire.InvToScreen(25, 141)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Barre.GetItem(2), Memoire.InvToScreen(43, 141)));

            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(0), Memoire.InvToScreen(7, 119)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(1), Memoire.InvToScreen(25, 119)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(2), Memoire.InvToScreen(43, 119)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(3), Memoire.InvToScreen(7, 101)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(4), Memoire.InvToScreen(25, 101)));
            Memoire.items.Add(new UI_Item(Sauvegarde.joueur.Inventaire.GetItem(5), Memoire.InvToScreen(43, 101)));

            foreach (UI_Item it in Memoire.items)
            {
                Memoire.form.Controls.Add(it);
            }

            Memoire.selected = new UI_Item(null, new Point(Memoire.form.ClientSize.Width / 2, Memoire.form.ClientSize.Height / 2));
            Memoire.form.Controls.Add(Memoire.selected);
        }
Exemplo n.º 7
0
        public void DansTableDeCraft(List <UI_Item> Uitems)
        {
            Inventaire invcraft = EcranDeJeu.inventaires[0];

            UI_Item[,] inv = new UI_Item[3, 3];
            UI_Item c = null;

            foreach (UI_Item init in Uitems)
            {
                Point p = Memoire.ScreenToInv(init.Location.X, init.Location.Y);
                if (p.X >= 28 && p.X <= 83 && p.Y >= 16 && p.Y <= 52)
                {
                    int i = (p.X - 29) / 18 + ((p.Y - 16) / 18 * invcraft.Longueur);
                    invcraft.SetItem(i, init.item);
                    inv[(p.X - 29) / 18, (p.Y - 16) / 18] = init;
                }
                if (p.X == 125 && p.Y == 36)
                {
                    c = init;
                }
            }
            Craft(inv, c, invcraft, Memoire.InvToScreen(125, 36), new Point(29, 16));
        }
Exemplo n.º 8
0
 /// <summary>
 /// sauvegarde l'inventaire du joueur (inventaire et barre)
 /// </summary>
 public static void SauvegarderInventaire()
 {
     foreach (UI_Item it in Memoire.items)
     {
         Point p = Memoire.ScreenToInv(it.Location.X, it.Location.Y);
         if (p.Y == 141)
         {
             int i = (p.X - 7) / 18;
             Sauvegarde.joueur.Barre.SetItem(i, it.Item);
         }
         else
         {
             int y;
             if (p.Y == 101)
             {
                 y = 1;
             }
             else if (p.Y == 119)
             {
                 y = 0;
             }
             else
             {
                 continue;
             }
             int i = ((p.X - 7) / 18) + (y * (Sauvegarde.joueur.Inventaire.Longueur + 1));
             Sauvegarde.joueur.Inventaire.SetItem(i, it.Item);
         }
     }
     if (Memoire.selected != null)
     {
         Memoire.selected = null;
     }
     Memoire.form.Controls.Clear();
     Memoire.items = null;
     ChangerEcran(Ecrans.Jeu, null);
 }
Exemplo n.º 9
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (EcranDeJeu.Ecran == Ecrans.Jeu)
            {
                int w = (Memoire.form.ClientSize.Width / (16 * Sauvegarde.zoom_Block)) * 16 * Sauvegarde.zoom_Block;
                int h = (Memoire.form.ClientSize.Height / (16 * Sauvegarde.zoom_Block)) * 16 * Sauvegarde.zoom_Block;
                int x = (int)Math.Round(Sauvegarde.joueur.X - (w / 2f - e.X) / (16f * Sauvegarde.zoom_Block));
                int y = (int)Math.Round(Sauvegarde.joueur.Y + (h / 2f - e.Y) / (16f * Sauvegarde.zoom_Block));

                Block block = Sauvegarde.monde.GetBlock(x, y, false);

                if (block != null)
                {
                    if (!EcranDeJeu.CanSeeBlock(x, y, Sauvegarde.monde))
                    {
                        block = null;
                    }
                }

                Entite ent     = Sauvegarde.monde.GetEntite(x, y);
                bool   doBlock = true;

                Item item = Sauvegarde.joueur.Barre.GetItem(Sauvegarde.joueur.Maindroite);
                if (item != null)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        Tuple <bool, Tuple <Ecrans, object> > b = item.CliqueDroite(Sauvegarde.joueur, x, y, block, ((x == Sauvegarde.joueur.X && y == Sauvegarde.joueur.Y) ? Sauvegarde.joueur : ent), Sauvegarde.monde);
                        doBlock = b.Item1;
                        if (item.Quantite <= 0)
                        {
                            Sauvegarde.joueur.Barre.SetItem(Sauvegarde.joueur.Maindroite, null);
                        }
                        if (b.Item2 != null)
                        {
                            EcranDeJeu.ChangerEcran(b.Item2.Item1, b.Item2.Item2);
                        }
                        else
                        {
                            Actualiser();
                            EcranDeJeu.ActuHotBarre();
                        }
                    }
                    if (e.Button == MouseButtons.Left)
                    {
                        Tuple <bool, Tuple <Ecrans, object> > b = item.CliqueGauche(Sauvegarde.joueur, x, y, block, ((x == Sauvegarde.joueur.X && y == Sauvegarde.joueur.Y) ? Sauvegarde.joueur : ent), Sauvegarde.monde);
                        doBlock = b.Item1;
                        if (b.Item2 != null)
                        {
                            EcranDeJeu.ChangerEcran(b.Item2.Item1, b.Item2.Item2);
                        }
                        else
                        {
                            Actualiser();
                            EcranDeJeu.ActuHotBarre();
                        }
                    }
                }


                if (ent != null && doBlock)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        Tuple <Ecrans, object> temp = ent.CliqueDroite(Sauvegarde.joueur);
                        if (temp != null)
                        {
                            EcranDeJeu.ChangerEcran(temp.Item1, temp.Item2);
                            doBlock = false;
                        }
                    }
                    if (e.Button == MouseButtons.Left)
                    {
                        if (ent.CliqueGauche(Sauvegarde.joueur, 1, Sauvegarde.monde))
                        {
                            if (!Sauvegarde.monde.Entites.Contains(Sauvegarde.joueur))
                            {
                                Memoire.CreateWorld();
                                return;
                            }
                            Actualiser();
                            EcranDeJeu.ActuHotBarre();
                        }
                    }
                }

                if (block != null && doBlock)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        if (block.Detruire(Sauvegarde.joueur))
                        {
                            Sauvegarde.joueur.Faim -= 0.1f;
                            Sauvegarde.monde.SetBlock(x, y, null);
                            Entite[] ents = Sauvegarde.monde.Entites.ToArray();
                            foreach (Entite enti in ents)
                            {
                                int i = -3;
                                while (true)
                                {
                                    Block b = Sauvegarde.monde.GetBlock((int)enti.X, (int)enti.Y - 1, false);
                                    if (b == null || b.CanPassThrough(enti, true))
                                    {
                                        i++;
                                        enti.Bouger(0, -1, Sauvegarde.monde);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                if (i > 0)
                                {
                                    enti.Vie -= i;
                                    if (enti.Vie <= 0)
                                    {
                                        if (enti == Sauvegarde.joueur)
                                        {
                                            Memoire.CreateWorld();
                                            return;
                                        }
                                        Sauvegarde.monde.Entites.Remove(enti);
                                    }
                                }
                            }
                            Actualiser();
                            EcranDeJeu.ActuHotBarre();
                        }
                    }
                    if (e.Button == MouseButtons.Right)
                    {
                        Tuple <bool, Tuple <Ecrans, object> > invs = block.CliqueDroit(Sauvegarde.joueur);
                        if (invs != null)
                        {
                            if (invs.Item1)
                            {
                                if (invs.Item2 != null)
                                {
                                    EcranDeJeu.ChangerEcran(invs.Item2.Item1, invs.Item2.Item2);
                                }
                                Actualiser();
                                if (EcranDeJeu.Ecran == Ecrans.Jeu)
                                {
                                    EcranDeJeu.ActuHotBarre();
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void Craft(UI_Item[,] items, UI_Item to, Inventaire invcraft, Point toCoord, Point start)
        {
            Craft craft = TableDeCraft.CheckAll(invcraft);

            if (craft != null)
            {
                for (int x = 0; x < items.GetLength(0); x++)
                {
                    for (int y = 0; y < items.GetLength(1); y++)
                    {
                        Memoire.items.Remove(items[x, y]);
                        Memoire.form.Controls.Remove(items[x, y]);
                    }
                }

                if (to != null)
                {
                    Memoire.items.Remove(to);
                    Memoire.form.Controls.Remove(to);

                    if (Memoire.selected.item == null && to.item != null)
                    {
                        Memoire.form.Controls.Remove(Memoire.selected);
                        Memoire.selected = to;
                        to = null;
                        Memoire.form.Controls.Add(Memoire.selected);
                    }
                }

                bool a = true;
                for (int x = 0; x < items.GetLength(0); x++)
                {
                    for (int y = 0; y < items.GetLength(1); y++)
                    {
                        Item item = invcraft.GetItem(x + (y * items.GetLength(0)));
                        if (Memoire.selected != null && Memoire.selected.item != null &&
                            craft.To.id() == Memoire.selected.item.id() &&
                            item != null && craft.From[x, y] != null)
                        {
                            item.Quantite -= craft.From[x, y].Quantite;
                            if (item.Quantite == 0)
                            {
                                a = false;
                                invcraft.SetItem(x + (y * items.GetLength(0)), null);
                                item = null;
                            }
                        }
                        UI_Item uit = new UI_Item(item, Memoire.InvToScreen(start.X + x * 18, start.Y + y * 18));
                        Memoire.items.Add(uit);
                        Memoire.form.Controls.Add(uit);
                    }
                }
                if (a)
                {
                    UI_Item cit = new UI_Item(craft.To.Clone(), toCoord);
                    Memoire.items.Add(cit);
                    Memoire.form.Controls.Add(cit);
                }
            }
            if (craft == null && to != null && to.item != null)
            {
                Memoire.items.Remove(to);
                Memoire.form.Controls.Remove(to);
            }
        }
Exemplo n.º 11
0
        public void DansMarchand(List <UI_Item> Uitems)
        {
            UI_Item UitV1 = null;
            UI_Item UitV2 = null;
            UI_Item itDo  = null;

            foreach (UI_Item init in Uitems)
            {
                Point p = Memoire.ScreenToInv(init.Location.X, init.Location.Y);
                if (p.Y == 14)
                {
                    if (p.X == 77)
                    {
                        UitV1 = init;
                    }
                    if (p.X == 95)
                    {
                        UitV2 = init;
                    }
                    if (p.X == 147)
                    {
                        itDo = init;
                    }
                }
            }

            if (Memoire.selected.item != null && itDo != null && itDo.item != null &&
                Memoire.selected.item.id() != itDo.item.id())
            {
                AnnulerMove(itDo);
                return;
            }

            if (UitV1.item == null && UitV2.item != null)
            {
                Point l1 = UitV1.Location;
                UitV1.Location = UitV2.Location;
                UitV2.Location = l1;

                UI_Item i1 = UitV1;
                UitV1 = UitV2;
                UitV2 = i1;
            }

            if (UitV1.item != null)
            {
                foreach (Echange echange in EcranDeJeu.marchand.Echanges)
                {
                    bool iv2 = echange.ItemVoulu2 == null;
                    bool i2  = UitV2.item == null;
                    if (echange.ItemVoulu != null &&
                        echange.ItemVoulu.id() == UitV1.item.id() && echange.ItemVoulu.Quantite <= UitV1.item.Quantite &&
                        (iv2 == i2) &&
                        ((
                             (!iv2 && !i2) &&
                             echange.ItemVoulu2.id() == UitV2.item.id() && echange.ItemVoulu2.Quantite <= UitV2.item.Quantite) ||
                         (iv2 && i2)))
                    {
                        if (itDo == null)
                        {
                            itDo = new UI_Item(echange.ItemDonne.Clone(), Memoire.InvToScreen(147, 14));
                            Memoire.items.Add(itDo);
                            Memoire.form.Controls.Add(itDo);
                        }
                        else
                        {
                            Memoire.items.Remove(itDo);
                            Memoire.form.Controls.Remove(itDo);

                            if (Memoire.selected.item == null && itDo.item != null)
                            {
                                Memoire.form.Controls.Remove(Memoire.selected);
                                Memoire.selected = new UI_Item(itDo.item, Memoire.selected.Location);
                                itDo.item        = null;
                                Memoire.form.Controls.Add(Memoire.selected);
                            }

                            if (Memoire.selected.item != null && Memoire.selected.item.id() == echange.ItemDonne.id())
                            {
                                bool a = true;
                                if (UitV1.item != null && echange.ItemVoulu != null)
                                {
                                    Memoire.items.Remove(UitV1);
                                    Memoire.form.Controls.Remove(UitV1);
                                    UitV1.item.Quantite -= echange.ItemVoulu.Quantite;

                                    if (UitV1.item.Quantite <= 0)
                                    {
                                        UitV1.item = null;
                                        a          = false;
                                    }
                                    UitV1 = new UI_Item(UitV1.item, UitV1.Location);
                                    Memoire.items.Add(UitV1);
                                    Memoire.form.Controls.Add(UitV1);
                                }
                                if (UitV2.item != null && echange.ItemVoulu2 != null)
                                {
                                    Memoire.items.Remove(UitV2);
                                    Memoire.form.Controls.Remove(UitV2);
                                    UitV2.item.Quantite -= echange.ItemVoulu2.Quantite;
                                    if (UitV2.item.Quantite <= 0)
                                    {
                                        UitV2.item = null;
                                        a          = false;
                                    }
                                    UitV2 = new UI_Item(UitV2.item, UitV2.Location);
                                    Memoire.items.Add(UitV2);
                                    Memoire.form.Controls.Add(UitV2);
                                }
                                if (a)
                                {
                                    itDo = new UI_Item(echange.ItemDonne.Clone(), itDo.Location);
                                    Memoire.items.Add(itDo);
                                    Memoire.form.Controls.Add(itDo);
                                }
                            }
                            else
                            {
                                itDo = new UI_Item(echange.ItemDonne.Clone(), itDo.Location);
                                Memoire.items.Add(itDo);
                                Memoire.form.Controls.Add(itDo);
                            }
                        }
                        return;
                    }
                }
            }
            if (itDo != null)
            {
                Memoire.form.Controls.Remove(itDo);
                Memoire.items.Remove(itDo);
            }
        }
Exemplo n.º 12
0
        public void DansJoueur(List <UI_Item> Uitems)
        {
            UI_Item[,] crafts = new UI_Item[2, 2];
            UI_Item tocraft  = null;
            UI_Item casque   = null;
            UI_Item plastron = null;
            UI_Item jambiere = null;
            UI_Item botte    = null;

            foreach (UI_Item init in Uitems)
            {
                Point p = Memoire.ScreenToInv(init.Location.X, init.Location.Y);
                if (p.X == 7)
                {
                    if (p.Y == 7)
                    {
                        casque = init;
                    }
                    if (p.Y == 25)
                    {
                        plastron = init;
                    }
                    if (p.Y == 43)
                    {
                        jambiere = init;
                    }
                    if (p.Y == 61)
                    {
                        botte = init;
                    }
                }
                if ((p.X == 97 || p.X == 115) && (p.Y == 17 || p.Y == 35))
                {
                    Sauvegarde.joueur.Crafting.SetItem((p.X - 97) / 18 + (((p.Y - 17) / 18) * 2), init.item);
                    crafts[(p.X - 97) / 18, (p.Y - 17) / 18] = init;
                }
                if (p.X == 153 && p.Y == 27)
                {
                    tocraft = init;
                }
            }

            if (casque.item is Casque c)
            {
                Sauvegarde.joueur.Casque = c;
            }
            else if (casque.item == null)
            {
                Sauvegarde.joueur.Casque = null;
            }
            else
            {
                Sauvegarde.joueur.Casque = null;
                AnnulerMove(casque);
            }
            if (plastron.item is Plastron pl)
            {
                Sauvegarde.joueur.Plastron = pl;
            }
            else if (plastron.item == null)
            {
                Sauvegarde.joueur.Plastron = null;
            }
            else
            {
                Sauvegarde.joueur.Plastron = null;
                AnnulerMove(plastron);
            }
            if (jambiere.item is Jambiere j)
            {
                Sauvegarde.joueur.Jambiere = j;
            }
            else if (jambiere.item == null)
            {
                Sauvegarde.joueur.Jambiere = null;
            }
            else
            {
                Sauvegarde.joueur.Jambiere = null;
                AnnulerMove(jambiere);
            }
            if (botte.item is Botte b)
            {
                Sauvegarde.joueur.Botte = b;
            }
            else if (botte.item == null)
            {
                Sauvegarde.joueur.Botte = null;
            }
            else
            {
                Sauvegarde.joueur.Botte = null;
                AnnulerMove(botte);
            }

            Craft(crafts, tocraft, Sauvegarde.joueur.Crafting, Memoire.InvToScreen(153, 27), new Point(97, 17));
        }
Exemplo n.º 13
0
        /// <summary>
        /// liste d'echange d'un marchand
        /// </summary>
        public static void AfficherMarchand()
        {
            AfficherMap(Sauvegarde.joueur, Sauvegarde.monde);
            Graphics gfx = Graphics.FromImage(Memoire.form.backGround);

            int w = Memoire.form.ClientSize.Width;
            int h = Memoire.form.ClientSize.Height;

            gfx.DrawImage(Properties.Resources.Inventaire_Marchand
                          , w / 32, h / 32, w - (w / 32) * 2, h - (h / 32) * 2);
            Size itsize = new Size((int)((16f / 177f) * (w - (w / 32) * 2)), (int)((16f / 166f) * (h - (h / 32) * 2)));

            for (int i = 0; i < 5; i++)
            {
                if (i >= marchand.Echanges.Length)
                {
                    break;
                }

                Echange echange = marchand.Echanges[i];
                if (echange.ItemVoulu != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemVoulu.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemVoulu.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemVoulu.Quantite > 1)
                    {
                        g.DrawString(echange.ItemVoulu.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(84, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
                if (echange.ItemVoulu2 != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemVoulu2.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemVoulu2.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemVoulu2.Quantite > 1)
                    {
                        g.DrawString(echange.ItemVoulu2.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(102, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
                if (echange.ItemDonne != null)
                {
                    Bitmap img = new Bitmap((Bitmap)Properties.Resources.ResourceManager.GetObject("Item_" + echange.ItemDonne.id()),
                                            itsize);
                    Graphics g = Graphics.FromImage(img);
                    SizeF    s = g.MeasureString(echange.ItemDonne.Quantite + "", SystemFonts.DefaultFont);
                    if (echange.ItemDonne.Quantite > 1)
                    {
                        g.DrawString(echange.ItemDonne.Quantite + "", SystemFonts.DefaultFont, Brushes.Black, new PointF(itsize.Width - s.Width, itsize.Height - s.Height));
                    }
                    Point start = Memoire.InvToScreen(140, 47 + i * 22);
                    gfx.DrawImage(img, start.X, start.Y, itsize.Width, itsize.Height);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// change l'ecran</br>
        /// IL FAUT ACTUALISE LE FORM
        /// </summary>
        /// <param name="necran"></param>
        public static void ChangerEcran(Ecrans necran, object autre)
        {
            if (ecran == necran)
            {
                return;
            }

            List <UI_Item> items = new List <UI_Item>();

            if (necran == Ecrans.Inventaire)
            {
                OuvrireInventaire();
                inventaires = (Inventaire[])autre;
                Inventaire inv = inventaires[0];
                if (inv.Hauteur > 3)
                {
                    throw new ArgumentException("inventaire trop haut");
                }
                if (inv.Longueur > 9)
                {
                    throw new ArgumentException("inventaire trop long");
                }
                for (int x = 0; x < inv.Longueur; x++)
                {
                    for (int y = 0; y < inv.Hauteur; y++)
                    {
                        items.Add(new UI_Item(inv.GetItem(x + (y * inv.Longueur)), Memoire.InvToScreen(7 + x * 18, 53 - y * 18)));
                    }
                }
            }
            if (necran == Ecrans.Joueur)
            {
                OuvrireInventaire();
                Joueur joueur = autre as Joueur;
                inventaires = new Inventaire[] { joueur.Inventaire, joueur.Barre };

                items.Add(new UI_Item(joueur.Casque, Memoire.InvToScreen(7, 7)));
                items.Add(new UI_Item(joueur.Plastron, Memoire.InvToScreen(7, 25)));
                items.Add(new UI_Item(joueur.Jambiere, Memoire.InvToScreen(7, 43)));
                items.Add(new UI_Item(joueur.Botte, Memoire.InvToScreen(7, 61)));

                items.Add(new UI_Item(joueur.Crafting.GetItem(0), Memoire.InvToScreen(97, 17)));
                items.Add(new UI_Item(joueur.Crafting.GetItem(2), Memoire.InvToScreen(97, 35)));
                items.Add(new UI_Item(joueur.Crafting.GetItem(1), Memoire.InvToScreen(115, 17)));
                items.Add(new UI_Item(joueur.Crafting.GetItem(3), Memoire.InvToScreen(115, 35)));
            }
            if (necran == Ecrans.Marchand)
            {
                OuvrireInventaire();
                marchand    = (Marchand)autre;
                inventaires = new Inventaire[] { Sauvegarde.joueur.Inventaire, Sauvegarde.joueur.Barre };

                items.Add(new UI_Item(null, Memoire.InvToScreen(77, 14)));
                items.Add(new UI_Item(null, Memoire.InvToScreen(95, 14)));
                //items.Add(new UI_Item(null, Memoire.InvToScreen(147, 14)));
            }
            if (necran == Ecrans.TableCraft)
            {
                OuvrireInventaire();
                Inventaire inv = ((Inventaire[])autre)[0];

                items.Add(new UI_Item(inv.GetItem(0), Memoire.InvToScreen(29, 16)));
                items.Add(new UI_Item(inv.GetItem(1), Memoire.InvToScreen(47, 16)));
                items.Add(new UI_Item(inv.GetItem(2), Memoire.InvToScreen(65, 16)));

                items.Add(new UI_Item(inv.GetItem(3), Memoire.InvToScreen(29, 34)));
                items.Add(new UI_Item(inv.GetItem(4), Memoire.InvToScreen(47, 34)));
                items.Add(new UI_Item(inv.GetItem(5), Memoire.InvToScreen(65, 34)));

                items.Add(new UI_Item(inv.GetItem(6), Memoire.InvToScreen(29, 52)));
                items.Add(new UI_Item(inv.GetItem(7), Memoire.InvToScreen(47, 52)));
                items.Add(new UI_Item(inv.GetItem(8), Memoire.InvToScreen(65, 52)));

                inventaires = (Inventaire[])autre;
            }
            if (necran == Ecrans.Four)
            {
                OuvrireInventaire();

                KeyValuePair <Four_Block, Inventaire[]> returne = (KeyValuePair <Four_Block, Inventaire[]>)autre;
                four        = returne.Key;
                inventaires = returne.Value;
                Inventaire inv = returne.Value[0];
                items.Add(new UI_Item(inv.GetItem(0), Memoire.InvToScreen(55, 16)));
                items.Add(new UI_Item(inv.GetItem(1), Memoire.InvToScreen(55, 52)));
                items.Add(new UI_Item(inv.GetItem(2), Memoire.InvToScreen(116, 35)));
            }
            if (necran == Ecrans.Jeu)
            {
                if (Memoire.items != null)
                {
                    SauvegarderInventaire();
                }
                inventaires = null;
                marchand    = null;
                four        = null;
                ActuHotBarre();
            }
            foreach (UI_Item it in items)
            {
                Memoire.items.Add(it);
                Memoire.form.Controls.Add(it);
            }

            if (ecran == Ecrans.Jeu)
            {
                Memoire.form.Controls.Remove(Memoire.barre);
                Memoire.form.Controls.Remove(Memoire.selector);
                Memoire.form.Controls.Remove(Memoire.coeur);
                Memoire.form.Controls.Remove(Memoire.nourriture);
            }

            ecran = necran;
            Memoire.form.Actualiser();
        }