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); } }
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); } }
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)); }
/// <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); }
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); } }
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)); }