public PanneauRuine(Jeu _jeu, Creature heros, Ruines.RuineDescription _ruine) : base(_jeu, Overlay.Position.CENTRE, 400, 440, 0, 0, heros.vraiNom + " fouille la Ruine de " + _ruine.nom + "...") { _modalOverlay = ModalOverlay.FOUILLE_RUINE; // Bouton Fermer Bouton fermer = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48, "Fermer", null, _jeu.isoFont); fermer.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _jeu.popOverlay(); } }; _controles.Add(fermer); string nomEnnemi = null; string nomRecompense = null; bool herosGagne = _jeu.ruines.fouilleRuine(heros, _ruine, ref nomEnnemi, ref nomRecompense); // Affichage drawCallBack = delegate(SpriteBatch spriteBatch, GraphicsDevice GraphicsDevice, GameTime gameTime) { spriteBatch.Draw(_jeu.texRuine, new Rectangle(_xoverlay + (_width - 256) / 2, _yoverlay + 32, 256, 256), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.7f); spriteBatch.DrawString(_jeu.font, heros.vraiNom + " rencontre " + nomEnnemi + "...", new Vector2(_xoverlay + 16, _yoverlay + 256 + 48), Color.White); spriteBatch.DrawString(_jeu.font, "... et " + (herosGagne?" en sort vainqueur !" : " a été massacré(e) !"), new Vector2(_xoverlay + 16, _yoverlay + 256 + 48 + 20), Color.White); if (herosGagne) { spriteBatch.DrawString(_jeu.font, heros.vraiNom + " trouve " + nomRecompense, new Vector2(_xoverlay + 16, _yoverlay + 256 + 48 + 20 * 2), Color.White); } }; }
public MenuSauvegarde(Jeu _jeu, string nomFichier, suiteTraitement suite) : base(_jeu, Overlay.Position.CENTRE, 120, 200, 0, 0, "Menu") { _modalOverlay = ModalOverlay.MENU_SAUVE; Bouton sauver = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48 - 40 * 2, "Sauver ", null, _jeu.isoFont); sauver.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { sauverJeu(nomFichier); } }; _controles.Add(sauver); Bouton charger = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48 - 40 * 3, "Charger", null, _jeu.isoFont); charger.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { chargerJeu(nomFichier); } }; _controles.Add(charger); Bouton quitter = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48 - 40 * 1, "Quitter", null, _jeu.isoFont); quitter.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { suite(); } }; _controles.Add(quitter); Bouton annuler = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48 - 40 * 0, "Annuler", null, _jeu.isoFont); annuler.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _jeu.popOverlay(); } }; _controles.Add(annuler); }
public FactionOverlay(Jeu _jeu, suiteTraitement suite) : base(_jeu, Overlay.Position.CENTRE, 400, 680 + 80, 0, 0, "Seigneurs de Guerre - Choisissez les factions") { _modalOverlay = ModalOverlay.FACTIONS; // Bouton Démarrer Bouton demarrer = new Bouton(_jeu, _xoverlay + 16, _yoverlay + _height - 48, "Démarrer", null, _jeu.isoFont); demarrer.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _jeu.popOverlay(); // Suite du traitement - début du jeu suite(); } }; _controles.Add(demarrer); // Boutons des factions, 2 colonnes Bouton[] factions = new Bouton[_jeu.factions.nbFactions]; int xbouton = _xoverlay + 16; int ybouton = _yoverlay + 48; for (int i = 1; i <= factions.Length; i++) { Factions.Faction f = _jeu.factions.getFaction(i); string nom = (" " + f.nom + " ").Substring(0, 32); factions[i - 1] = new Bouton(_jeu, xbouton, ybouton, nom, f.humanPlayer ? _jeu.texHumain : _jeu.texCPU, _jeu.isoFont); factions[i - 1].userData = i; factions[i - 1].click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { Factions.Faction fac = _jeu.factions.getFaction(clicked.userData); fac.humanPlayer ^= true; ((Bouton)clicked).picture = fac.humanPlayer ? _jeu.texHumain : _jeu.texCPU; } }; _controles.Add(factions[i - 1]); ybouton += 80; } }
public ChoixHeros(Jeu _jeu) : base(_jeu, Overlay.Position.CENTRE, 360+16+16, 550, 0, 0, "Une nouvelle héroïne souhaite rejoindre votre cause") { _keys = new Keys[] {}; _modalOverlay = ModalOverlay.CHOIX_HEROS; _femme = (_jeu.rnd.Next(2) == 1); if (!_femme) { _titre = _titre.Replace("nouvelle héroïne", "nouvel héros"); } _nomHeros = nomAuHasard(_jeu.rnd, _femme); // Boutons de choix du sexe Bouton homme = new Bouton(_jeu, _xoverlay + 16, _yoverlay + 450, "Homme", null, _jeu.isoFont); Bouton femme = new Bouton(_jeu, _xoverlay + 16, _yoverlay + 495, "Femme", null, _jeu.isoFont); homme.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _femme = false; _titre = _titre.Replace("nouvelle héroïne", "nouvel héros"); } }; femme.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _femme = true; _titre = _titre.Replace("nouvel héros","nouvelle héroïne"); } }; _controles.Add(homme); _controles.Add(femme); // Bouton de validation Bouton ok = new Bouton(_jeu, _xoverlay + 16 + 270, _yoverlay + 495, "Valider", null, _jeu.isoFont); ok.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { // Création du héros et des troupes associées _jeu.creatures.createHeros(_editNom.texte, _femme, _jeu.noTour != 1); _jeu.popOverlay(); } }; _controles.Add(ok); // Zone de saisie _editNom = new BoiteLabel(_jeu, _xoverlay + 100, _yoverlay + 450, 275, _nomHeros, _jeu.font); _controles.Add(_editNom); // Bouton de nom au hasard Bouton nomHasard = new Bouton(_jeu, _xoverlay + 100, _yoverlay + 495, "Hasard", null, _jeu.isoFont); nomHasard.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _nomHeros = nomAuHasard(_jeu.rnd,_femme); _editNom.texte = _nomHeros; } }; _controles.Add(nomHasard); drawCallBack = delegate(SpriteBatch spriteBatch, GraphicsDevice GraphicsDevice, GameTime gameTime) { // Image de héros à gauche spriteBatch.Draw(_femme ? _jeu.texHeroine : _jeu.texHeros, new Rectangle(xoverlay + 16, yoverlay + 64, 360, 360), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.8f); }; }
public PanneauVille(Jeu _jeu, VilleDescription ville) : base(_jeu, Overlay.Position.CENTRE, 360 + 16 + 16, 550, 0, 0, "Gestion de ") { _ville = ville; _titre += ville.nom; _modalOverlay = ModalOverlay.INFO_VILLE; // Textures des créatures produites dans la ville texProd = new Texture2D[ville.typeCreatures.Length]; Bouton[] productions = new Bouton[ville.typeCreatures.Length]; for (int i = 0; i < texProd.Length; i++) { texProd[i] = new Texture2D(_jeu.graphicsDevice, Creatures.CREATURE_SIZE, Creatures.CREATURE_SIZE); // Copie la créature concernée dedans texProd[i].SetData(_jeu.creatures.getTextureData(ville.typeCreatures[i])); productions[i] = new Bouton(_jeu, _xoverlay + 16, _yoverlay + 64 + (12 + Creatures.CREATURE_SIZE) * i, "", texProd[i], _jeu.isoFont); productions[i].userData = i; productions[i].click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { ville.productionCourante = ((Bouton)clicked).userData; } }; _controles.Add(productions[i]); } Bouton stopProd = new Bouton(_jeu, _xoverlay + 116, _yoverlay + 64 + (12 + Creatures.CREATURE_SIZE) * texProd.Length + 20 + 40 + 28 , "Ne rien produire", null, _jeu.font); stopProd.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { ville.productionCourante = -1; } }; _controles.Add(stopProd); Bouton plusDef = new Bouton(_jeu, _xoverlay + 16, _yoverlay + 50 + (12 + Creatures.CREATURE_SIZE) * texProd.Length + 20 + 40 + 28 + 20 + Creatures.CREATURE_SIZE + 15 , "Augmenter la défense et la productivité", null, _jeu.font); plusDef.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { // Augmente le niveau de défense if ((_ville.niveauDefense < 40) && (_jeu.factions.getFaction(_ville.faction).or >= _ville.orPourNiveauSuivant)) { _jeu.factions.getFaction(_ville.faction).or -= _ville.orPourNiveauSuivant; _ville.niveauDefense = _ville.niveauDefense + 10; _ville.niveauProductivite = ville.niveauProductivite + 1; } } }; _controles.Add(plusDef); Bouton OK = new Bouton(_jeu, _xoverlay + 16 + 116, _yoverlay + 72 + (12 + Creatures.CREATURE_SIZE) * texProd.Length + 20 + 40 + 28 + 20 + Creatures.CREATURE_SIZE + 28 + 10 + 40 , " Valider ", null, _jeu.isoFont); OK.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released) { _jeu.popOverlay(); } }; _controles.Add(OK); _height = 25 + 64 + (12 + Creatures.CREATURE_SIZE) * texProd.Length + 20 + 40 + 28 + 20 + Creatures.CREATURE_SIZE + 28 + 10 + 60; drawCallBack = delegate(SpriteBatch spriteBatch, GraphicsDevice GraphicsDevice, GameTime gameTime) { // Texte drawOutlinedString(spriteBatch, _jeu.font, "~ Productions disponibles ~", new Vector2(_xoverlay + 8, _yoverlay + 30), Color.White, Color.DarkBlue); for (int i = 0; i < texProd.Length; i++) { // texte et profil de l'armée en production drawOutlinedString(spriteBatch, _jeu.font, _jeu.creatures.description[_ville.typeCreatures[i]].nom, new Vector2(_xoverlay + 16 + Creatures.CREATURE_SIZE + 8, _yoverlay + 58 + (12 + Creatures.CREATURE_SIZE) * i), Color.White, Color.Crimson); spriteBatch.DrawString(_jeu.font, _jeu.creatures.description[_ville.typeCreatures[i]].profilAsStr(), new Vector2(_xoverlay + 16 + Creatures.CREATURE_SIZE + 8, _yoverlay + 58 + (12 + Creatures.CREATURE_SIZE) * i + 20), Color.White); int nbTours = _ville.geNbToursPourCreatures(_jeu.creatures.description[_ville.typeCreatures[i]].cout); spriteBatch.DrawString(_jeu.font, "Coût : " + _jeu.creatures.description[_ville.typeCreatures[i]].cout + " - " + nbTours + " tour" + (nbTours > 1 ? "s" : ""), new Vector2(_xoverlay + 16 + Creatures.CREATURE_SIZE + 8, _yoverlay + 64 + (12 + Creatures.CREATURE_SIZE) * i + 40), Color.White); } int ynext = _yoverlay + 64 + (12 + Creatures.CREATURE_SIZE) * texProd.Length + 20; drawOutlinedString(spriteBatch, _jeu.font, "~ Production courante ~", new Vector2(_xoverlay + 8, ynext), Color.White, Color.DarkBlue); ynext += 15; int revenusVille = _ville.getRevenus(); spriteBatch.DrawString(_jeu.font, "Revenus de la ville : " + revenusVille, new Vector2(_xoverlay + 16 + 100, ynext), Color.White); ynext += 20; if (_ville.productionCourante != -1) { spriteBatch.Draw(texProd[_ville.productionCourante], new Rectangle(_xoverlay + 16, ynext, Creatures.CREATURE_SIZE, Creatures.CREATURE_SIZE), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.9f); int nbToursPourCrea = _ville.geNbToursPourCreatures(_jeu.creatures.description[_ville.typeCreatures[_ville.productionCourante]].cout); int toursRestants = (nbToursPourCrea - _ville.productionPoints); if (toursRestants < 1) { toursRestants = 1; } spriteBatch.DrawString(_jeu.font, "Tours restants : " + toursRestants, new Vector2(_xoverlay + 16 + 100, ynext), Color.White); } else { drawOutlinedString(spriteBatch, _jeu.font, "Aucune", new Vector2(_xoverlay + 16, ynext), Color.White, Color.DarkCyan); } ynext += Creatures.CREATURE_SIZE + 28; drawOutlinedString(spriteBatch, _jeu.font, "~ Niveau de défense actuel : " + _ville.niveauDefense + " ~", new Vector2(_xoverlay + 8, ynext), Color.White, Color.DarkBlue); ynext += 65; spriteBatch.DrawString(_jeu.font, "Coût : " + _ville.orPourNiveauSuivant, new Vector2(_xoverlay + 16 + 110, ynext), Color.White); ynext += 20; spriteBatch.DrawString(_jeu.font, "Or disponible : " + _jeu.factions.getFaction(_ville.faction).or, new Vector2(_xoverlay + 16 + 110, ynext), Color.White); }; _jeu.curseur.forme = Cursor.FormeCurseur.FLECHE; }
public PanneauControle(Jeu _jeu) : base(_jeu, Position.BAS_GAUCHE, LARGBTN * 6 + 16, 160, null, null) { // Ajout de boutons ---- Bouton boutonArmeeSuivante = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 0, yoverlay + 16, " Suivant ", _texSuivant, _jeu.isoFont); boutonArmeeSuivante.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonArmeeSuivanteClick(); } }; _controles.Add(boutonArmeeSuivante); Bouton boutonSuiteMouvement = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 1, yoverlay + 16, " Continue", _texContinuer, _jeu.isoFont); boutonSuiteMouvement.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonSuiteMouvementClick(); } }; _controles.Add(boutonSuiteMouvement); Bouton boutonDeselection = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 2, yoverlay + 16, " Déselect", _texDeselection, _jeu.isoFont); boutonDeselection.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonDeselectionClick(); } }; _controles.Add(boutonDeselection); Bouton boutonOublieArmee = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 3, yoverlay + 16, " Passer ", _texPasser, _jeu.isoFont); boutonOublieArmee.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonOublieArmeeClick(); } }; _controles.Add(boutonOublieArmee); Bouton boutonFouillerRuine = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 4, yoverlay + 16, " Fouille ", _texFouiller, _jeu.isoFont); boutonFouillerRuine.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonFouillerRuineClick(); } }; _controles.Add(boutonFouillerRuine); Bouton boutonFinTour = new Bouton(_jeu, xoverlay + 16 + LARGBTN * 5, yoverlay + 16, " Fin Tour", _texFintour, _jeu.isoFont); boutonFinTour.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonFinTourClick(); } }; _controles.Add(boutonFinTour); Bouton scinder = new Bouton(_jeu, xoverlay + 16 + Creatures.CREATURE_SIZE * 9, yoverlay + height - 64 - 16, "", _texScinder, _jeu.isoFont); scinder.click = delegate(Controle clicked, int x, int y, bool leftClick, bool rightClick, bool released) { if (released && _jeu.getTopOverlay().modalOverlay == ModalOverlay.AUCUN) { boutonScinderClick(); } }; _controles.Add(scinder); _focusCreature = null; _group = new HashSet <Creature>(); _groupOwner = null; }