// i = 49 ou 50 //Loohy public BoutonDeroulant(Rectangle rect_, int indexDico_) : base(rect_, new Rectangle(42,7,42,7)) { state = e_etatDeroulant.Ferme; tstate = e_pinceau.Plaine; tsize = e_toolSize.Standard; hauteur = 0; indexDico = indexDico_; }
public void updatePinceau(e_pinceau type_, e_toolSize taille_) { //brille(taille_); #region clic if (Mouse.GetState().LeftButton == ButtonState.Pressed) { int size; #region getsize switch (taille_) { case e_toolSize.XSmall: size = 1; break; case e_toolSize.Small: size = 2; break; case e_toolSize.Standard: size = 3; break; case e_toolSize.Medium: size = 4; break; case e_toolSize.Large: size = 5; break; case e_toolSize.XLarge: size = 6; break; default: size = 1; break; } #endregion #region Lissage if (type_ == e_pinceau.Lissage) { int moy = 0; int n = 1; moy += map[sourisI, sourisJ].altitude; for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { moy += map[sourisI + k, sourisJ + (portee_ - k)].altitude; n++; } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { moy += map[sourisI - k, sourisJ - (portee_ - k)].altitude; n++; } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { moy += map[sourisI + (portee_ - k), sourisJ - k].altitude; n++; } if (sourisI - (portee_ - k) >= 0 && sourisJ + k < largeur && sourisJ + k >= 0 && sourisJ + k < largeur) { moy += map[sourisJ - (portee_ - k), sourisJ + k].altitude; n++; } } } moy /= n; map[sourisI, sourisJ].appliquer(type_, this, moy, 16); for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { map[sourisI + k, sourisJ + (portee_ - k)].appliquer(type_, this, moy, 16 - portee_); } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { map[sourisI - k, sourisJ - (portee_ - k)].appliquer(type_, this, moy, 16 - portee_); } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { map[sourisI + (portee_ - k), sourisJ - k].appliquer(type_, this, moy, 16 - portee_); } if (sourisI - (portee_ - k) >= 0 && sourisI - (portee_ - k) < longueur && sourisJ + k >= 0 && sourisJ + k < largeur) { map[sourisI - (portee_ - k), sourisJ + k].appliquer(type_, this, moy, 16 - portee_); } } } } #endregion map[sourisI, sourisJ].appliquer(type_, this, r.Next(100), 16); for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { map[sourisI + k, sourisJ + (portee_ - k)].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { map[sourisI - k, sourisJ - (portee_ - k)].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { map[sourisI + (portee_ - k), sourisJ - k].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI - (portee_ - k) >= 0 && sourisI - (portee_ - k) < longueur && sourisJ + k >= 0 && sourisJ + k < largeur) { map[sourisI - (portee_ - k), sourisJ + k].appliquer(type_, this, r.Next(100), 16 - portee_); } } } } #endregion }
//Loohy public void UpdateEditeur(e_pinceau p_type_, e_toolSize p_taille_) { Camera(); #region Souris sourisI = -1; sourisJ = -1; for (int d = 0; d < 7; d++) { for (int i = (int)getCaseFromMouseAvecAltitude().X + 3; i >= (int)getCaseFromMouseAvecAltitude().X - 1; i--) { int j = (int)getCaseFromMouseAvecAltitude().Y - 1; if (i + d >= 0 && j + d >= 0 && i + d < longueur && j + d < largeur) { //if ((lastcamerax != camerax || lastcameray != cameray) && clicOrNot) //{ estCeLaSouris(i + d, j + d, new Rectangle(0, 0, 0, 0)); //} } } for (int j = (int)getCaseFromMouseAvecAltitude().Y + 3; j >= (int)getCaseFromMouseAvecAltitude().Y - 1; j--) { int i = (int)getCaseFromMouseAvecAltitude().X - 1; if (i + d >= 0 && j + d >= 0 && i + d < longueur && j + d < largeur) { //if ((lastcamerax != camerax || lastcameray != cameray) && clicOrNot) //{ estCeLaSouris(i + d, j + d, new Rectangle(0, 0, 0, 0)); //} } } } viderSurbrillance(); if (sourisI != -1) updatePinceau(p_type_, p_taille_); #endregion if (clicOrNot) { lastcamerax = camerax; lastcameray = cameray; } #region Clavier #region Back if (Keyboard.GetState().IsKeyDown(Keys.Back) && clicOrNot) { direction = (direction + 1) % 4; centrerSur(longueur / 2, largeur / 2); clicOrNot = false; } #endregion if (Keyboard.GetState().IsKeyUp(Keys.Back) && Keyboard.GetState().IsKeyUp(Keys.Up) && Keyboard.GetState().IsKeyUp(Keys.Down) && Keyboard.GetState().IsKeyUp(Keys.Left) && Keyboard.GetState().IsKeyUp(Keys.Right)) { clicOrNot = true; } #endregion }
//Loohy public override void Draw() { switch (state) { #region Ouvert case e_etatDeroulant.Ouvert: Contents.Draw("px", new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, hauteur), Color.DarkRed); Rectangle rect2 = new Rectangle(rect.X, rect.Y + rect.Height, 110, (int)(Contents.MeasureString("S").Y + 2)); //hauteur = (int)(font.MeasureString("S").Y + 2) * 15; Color c = Color.Red; #region Type if (indexDico == 49)// { e_pinceau tableau = e_pinceau.Plaine; while (tableau != e_pinceau.Rien) { Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tstate = tableau; //logBox_.ToLogBox("La brosse actuelle est : " + tstate.ToString()); state = e_etatDeroulant.Montant; } } rect2.Y += (int)(Contents.MeasureString("S").Y + 2); tableau++; } Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tstate = tableau; //logBox_.ToLogBox("La brosse actuelle est : " + tstate.ToString()); state = e_etatDeroulant.Montant; } } } #endregion #region Size else if (indexDico == 50)// { e_toolSize tableur = e_toolSize.XSmall; while (tableur != e_toolSize.XLarge) { Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tsize = tableur; //logBox_.ToLogBox("La taille de la brosse est : " + SizeText(tableur)); state = e_etatDeroulant.Montant; } } rect2.Y += (int)(Contents.MeasureString("S").Y + 2); tableur++; } Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tsize = tableur; //logBox_.ToLogBox("La taille de la brosse est : " + SizeText(tableur)); state = e_etatDeroulant.Montant; } } #endregion } goto default; #endregion #region Montant/Descendant case e_etatDeroulant.Montant: case e_etatDeroulant.Descendant: Contents.Draw("px", new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, hauteur), Color.DarkRed); goto default; #endregion #region Bouton default: int s; if (indexDico == 49) { s = ToolText(tstate); } else { s = SizeText(tsize); } if (!Contents.contientLaSouris(base.rect)) { Contents.Draw("px", rect, Color.Gray); Contents.DrawStringInBoxCentered(Dico.langues[Dico.current][indexDico] + " : " + Dico.langues[Dico.current][s], rect, Color.Black); } else { Contents.Draw("px", rect, Color.DarkRed); Contents.DrawStringInBoxCentered(Dico.langues[Dico.current][indexDico] + " : " + Dico.langues[Dico.current][s], rect); } break; #endregion } }
//Loohy private int ToolText(e_pinceau type_) { int text = 0; switch (type_) { case e_pinceau.Plaine: text = 33; break; case e_pinceau.Neige: text = 34; break; case e_pinceau.Banquise: text = 35; break; case e_pinceau.Sable: text = 36; break; case e_pinceau.Eau: text = 37; break; case e_pinceau.Route: text = 38; break; case e_pinceau.Riviere: text = 39; break; case e_pinceau.Bunker: text = 40; break; case e_pinceau.Foret: text = 41; break; case e_pinceau.Ruine: text = 42; break; case e_pinceau.Cratere: text = 43; break; case e_pinceau.Village: text = 44; break; case e_pinceau.Montagne: text = 45; break; case e_pinceau.Vallee: text = 46; break; case e_pinceau.Lissage: text = 47; break; default: text = 48; break; } return text; }
//Loohy public void UpdateDeroulantNicoTuFaitPasChier(ref e_toolSize tsize_, ref e_pinceau tstate_) { switch (state) { case e_etatDeroulant.Ouvert: if (Contents.contientLaSouris(base.rect) && Mouse.GetState().LeftButton == ButtonState.Pressed) { state = e_etatDeroulant.Montant; } break; case e_etatDeroulant.Montant: hauteur -= 10; if (hauteur < 0) { hauteur = 0; state = e_etatDeroulant.Ferme; } break; case e_etatDeroulant.Descendant: hauteur += 10; if (indexDico == 49) { if (hauteur > Contents.MeasureString("S").Y * 16) { hauteur = (int)(Contents.MeasureString("S").Y + 2) * 16; state = e_etatDeroulant.Ouvert; } } else { if (hauteur > Contents.MeasureString("S").Y * 6) { hauteur = (int)(Contents.MeasureString("S").Y + 2) * 6; state = e_etatDeroulant.Ouvert; } } break; default: if (Contents.contientLaSouris(base.rect) && Mouse.GetState().LeftButton == ButtonState.Pressed) { state = e_etatDeroulant.Descendant; } break; } if (indexDico == 49) { tstate_ = tstate; } else { tsize_ = tsize; } }
//Loohy public void appliquer(e_pinceau pinceau, MoteurGraphique moteurgraphique_, int r_, int center_) { Console.WriteLine("appliquer en " + i + ";" + j + " avec " + pinceau.ToString()); switch (pinceau) { case e_pinceau.Plaine: E_Sol = e_Typedesol.herbe; break; case e_pinceau.Neige: E_Sol = e_Typedesol.neige; break; case e_pinceau.Sable: E_Sol = e_Typedesol.sable; break; case e_pinceau.Riviere: if (E_Sol != e_Typedesol.banquise && E_Sol != e_Typedesol.mer) { E_Riviere = e_Riviere.riviere; moteurgraphique_.river(i, j); } break; case e_pinceau.Eau: E_Sol = e_Typedesol.mer; E_Riviere = e_Riviere.vide; altitude = moteurgraphique_.altitudeMin(i, j); break; case e_pinceau.Banquise: E_Sol = e_Typedesol.banquise; E_Riviere = e_Riviere.vide; break; case e_pinceau.Route: E_Route = e_Typederoute.route; break; case e_pinceau.Bunker: if (E_Sol != e_Typedesol.banquise && E_Sol != e_Typedesol.mer) { E_DecorAvant = e_Decoravant.bunker; E_DecorArriere = e_Decorarriere.bunker; } else { E_DecorAvant = e_Decoravant.iceBunker; E_DecorArriere = e_Decorarriere.iceBunker; } break; case e_pinceau.Foret: if (E_Sol != e_Typedesol.banquise && E_Sol != e_Typedesol.mer) { E_DecorAvant = e_Decoravant.foret; E_DecorArriere = e_Decorarriere.foret; } break; case e_pinceau.Ruine: E_DecorAvant = e_Decoravant.vide; E_DecorArriere = e_Decorarriere.ruine; break; case e_pinceau.Cratere: E_DecorAvant = e_Decoravant.vide; E_DecorArriere = e_Decorarriere.cratere; break; case e_pinceau.Village: switch (E_Sol) { case e_Typedesol.herbe: if (E_Riviere != e_Riviere.riviere) { E_DecorAvant = e_Decoravant.vide; E_DecorArriere = e_Decorarriere.villagePanda; } break; case e_Typedesol.sable: if (E_Riviere != e_Riviere.riviere) { E_DecorAvant = e_Decoravant.vide; E_DecorArriere = e_Decorarriere.campementFenrir; } break; case e_Typedesol.neige: case e_Typedesol.banquise: E_DecorAvant = e_Decoravant.vide; E_DecorArriere = e_Decorarriere.villagePingvin; break; default: break; } break; case e_pinceau.Rien: E_Route = e_Typederoute.vide; E_Riviere = e_Riviere.vide; E_DecorArriere = e_Decorarriere.vide; E_DecorAvant = e_Decoravant.vide; break; case e_pinceau.Montagne: if (E_Sol != e_Typedesol.mer && E_Sol != e_Typedesol.banquise) { altitude += r_ % center_; if (altitude > moteurgraphique_.altitudeMax(i, j)) { altitude = moteurgraphique_.altitudeMax(i, j); } } break; case e_pinceau.Vallee: if (E_Sol != e_Typedesol.mer && E_Sol != e_Typedesol.banquise) { altitude -= r_ % center_; if (altitude < moteurgraphique_.altitudeMin(i, j)) { altitude = moteurgraphique_.altitudeMin(i, j); } } break; case e_pinceau.Lissage: if (E_Sol != e_Typedesol.mer && E_Sol != e_Typedesol.banquise) { if (altitude > r_) { altitude--; if (altitude < moteurgraphique_.altitudeMin(i, j)) { altitude = moteurgraphique_.altitudeMin(i, j); } } if (altitude < r_) { altitude++; if (altitude > moteurgraphique_.altitudeMax(i, j)) { altitude = moteurgraphique_.altitudeMax(i, j); } } } break; default: break; } if (pinceau == e_pinceau.Route || pinceau == e_pinceau.Riviere) { moteurgraphique_.AdaptAutour(i, j); } else { Adapt(moteurgraphique_, r_ % 10); } }