public void Comportement() { Monde monde = new Monde(new FlatGenerateur(new Noise())); monde.GenerateChunk(0, 0); monde.SetBlock(1, 0, new Terre_Block()); monde.SetBlock(2, 1, new Terre_Block()); monde.SetBlock(2, 2, new Terre_Block()); Zombie z = new Zombie(0, 0); Joueur j = new Joueur(10, 0); monde.Entites.Add(z); Assert.IsFalse(z.Comportement(monde)); monde.Entites.Add(j); Assert.AreEqual(z.X, 0); Assert.AreEqual(z.Y, 0); Assert.IsTrue(z.Comportement(monde)); Assert.AreEqual(z.X, 0.5f); Assert.AreEqual(z.Y, 0); Assert.IsTrue(z.Comportement(monde)); Assert.AreEqual(z.X, 1); Assert.AreEqual(z.Y, 1); Assert.IsFalse(z.Comportement(monde)); Assert.AreEqual(z.X, 1); Assert.AreEqual(z.Y, 1); }
public void GetMaxHeight() { Generateur g = new FlatGenerateur(new Noise()); Monde m = new Monde(g); m.GenerateChunk(0, -1); m.GenerateChunk(0, 0); Assert.AreEqual(m.GetMaxHeight(0, false, true), -1); Assert.AreEqual(m.GetMaxHeight(0, false, false), -1); m.SetBlock(2, 0, new Echelle_Block()); Assert.AreEqual(m.GetMaxHeight(2, false, true), 0); Assert.AreEqual(m.GetMaxHeight(2, false, false), -1); Assert.AreEqual(m.GetMaxHeight(2, true, false), 0); Assert.AreEqual(m.GetMaxHeight(2, true, true), 0); g = new FlatGenerateur(new Noise()); m = new Monde(g); m.GenerateChunk(0, 0); Assert.AreEqual(m.GetMaxHeight(0, false, true), int.MinValue); Assert.AreEqual(m.GetMaxHeight(0, false, false), int.MinValue); m.SetBlock(2, 0, new Echelle_Block()); Assert.AreEqual(m.GetMaxHeight(2, false, false), int.MinValue); Assert.AreEqual(m.GetMaxHeight(2, false, true), 0); Assert.AreEqual(m.GetMaxHeight(2, true, false), 0); Assert.AreEqual(m.GetMaxHeight(2, true, true), 0); }
public bool CreateHero(HeroDetailsDTO dto) { try { using (var context = new HugoLANDContext()) { Monde monde = context.Mondes.First(m => m.Description == dto.World); Classe classe = context.Classes.First(c => c.NomClasse == dto.Class); CompteJoueur compteJoueur = context.CompteJoueurs.First(a => a.NomJoueur == dto.UserName); var hero = new Hero { Niveau = 1, Experience = 0, x = 0, y = 0, StatStr = dto.StatStr, StatDex = dto.StatDex, StatReg = dto.StatReg, StatVitalite = dto.StatVitality, NomHero = dto.HeroName, EstConnecte = false, Classe = classe, CompteJoueur = compteJoueur, Monde = monde }; context.Entry(hero).State = EntityState.Added; context.SaveChanges(); } return(true); } catch { return(false); } }
public static Monde CreerEnsemble() { Monde test = new Monde(); test.AjouterVille("San Francisco", "Etats Unis d'Amérique", "SanFrancisco/vignette.jpg", "SanFrancisco/panorama.jpg"); test.AjouterVille("New York", "Etats Unis d'Amérique", "NewYork/vignette.jpg", "NewYork/panorama.jpg"); test.AjouterVille("Paris", "France", "Paris/vignette.jpg", "Paris/panorama.jpg"); test.AjouterVille("Londres", "Royaume Uni", "Londres/vignette.jpg", "Londres/panorama.jpg"); test.AjouterBatimentSimple("San Francisco", "Golden Gate", "Description", "GoldenGate/golden_gate.jpg", "GoldenGate/architecte.jpg", "GoldenGate/plan.jpg", "GoldenGate/interieur.jpg"); test.AjouterBatimentSimple("San Francisco", "Coit Tower", "Description", "CoitTower/coit_tower.jpg", "CoitTower/architecte.jpg", "CoitTower/plan.gif", "CoitTower/interieur.jpg"); test.AjouterBatimentSimple("San Francisco", "Transamerica Pyramid", "Description", "TransamericaPyramid/transamerica_pyramid.jpg", "TransamericaPyramid/architecte.jpg", "TransamericaPyramid/plan.png", "TransamericaPyramid/interieur.png"); test.AjouterBatimentSimple("San Francisco", "Ferry Building", "Description", "FerryBuilding/ferry_building.jpg", "no_image_available.png", "FerryBuilding/plan.jpg", "FerryBuilding/interieur.jpg"); test.AjouterBatimentSimple("New York", "Empire State Building", "Description", "EmpireStateBuilding/empire_state_building.jpg", "EmpireStateBuilding/architecte.png", "EmpireStateBuilding/plan.jpg", "EmpireStateBuilding/interieur.jpg"); test.AjouterBatimentSimple("New York", "Chrysler Building", "Description", "ChryslerBuilding/chrysler_building.jpg", "ChryslerBuilding/architecte.jpg", "ChryslerBuilding/plan.jpg", "ChryslerBuilding/interieur.jpg"); test.AjouterBatimentSimple("New York", "One World Trade Center", "Description", "OneWorldTradeCenter/one_world_trade_center.jpg", "OneWorldTradeCenter/architecte.jpg", "OneWorldTradeCenter/plan.jpg", "OneWorldTradeCenter/interieur.jpg"); test.AjouterBatimentSimple("New York", "Flatiron Building", "Description", "FlatIronBuilding/flatiron building.jpg", "FlatIronBuilding/architecte.jpg", "FlatIronBuilding/plan.jpg", "FlatIronBuilding/interieur.jpg"); test.AjouterBatimentSimple("New York", "Metropolitan Museum Of Art", "Description", "MMOA/mmoa.jpg", "MMOA/architecte.jpg", "MMOA/plan.jpg", "MMOA/interieur.jpg"); test.AjouterBatimentSimple("Paris", "Tour Eiffel", "Description", "TourEiffel/toureiffel.webp", "TourEiffel/archtoureiffel.jpg", "TourEiffel/plantoureiffel.jpg", "TourEiffel/intertoureiffel.jpg"); test.AjouterBatimentSimple("Paris", "Arc de triomphe", "Description", "ArcDeTriomphe/arcdetriomphe.jpg", "ArcDeTriomphe/archarcdetriomphe.jpg", "ArcDeTriomphe/planarcdetriomphe.jpg", "ArcDeTriomphe/interarcdetriomphe.jpg"); test.AjouterBatimentSimple("Paris", "Pyramide du Louvre", "Description", "PyramideDuLouvre/pyramidedulouvre.jpg", "PyramideDuLouvre/archpyramidedulouvre.jpg", "PyramideDuLouvre/planpyramidedulouvre.jfif", "PyramideDuLouvre/interpyramidedulouvre.jfif"); test.AjouterBatimentSimple("Paris", "Notre-Dame de Paris", "Description", "NotreDameDeParis/notredamedeparis.jpg", "NotreDameDeParis/archnotredamedeparis.jpg", "NotreDameDeParis/plannotredamedeparis.jpg", "NotreDameDeParis/internotredamedeparis.jpg"); test.AjouterBatimentSimple("Paris", "Obélisque de Louxor", "Description", "ObelisqueDeLouxor/obelisquedelouxor.jpg", "ObelisqueDeLouxor/archobelisquedelouxor.jpg", "ObelisqueDeLouxor/planobelisquedelouxor.jpg", "ObelisqueDeLouxor/interobelisquedelouxor.jpg"); test.AjouterBatimentSimple("Paris", "Grande Arche de la Défense", "Description", "GrandeArcheDeLaDefense/grandearchdeladefense.jpg", "GrandeArcheDeLaDefense/archgrandearchdeladefense.jpg", "GrandeArcheDeLaDefense/plangrandearchdeladefense.jpg", "GrandeArcheDeLaDefense/intergrandearchdeladefense.jpg"); test.AjouterBatimentSimple("Londres", "Big Ben", "Description", "BigBen/bigben.jpeg", "BigBen/archbigben.jpg", "BigBen/planbigben.jpg", "BigBen/interbigben.jpg"); test.AjouterBatimentSimple("Londres", "Palais de Westminster", "Description", "PalaisDeWestminster/palaisdewestminster.jpg", "PalaisDeWestminster/archpalaisdewestminster.jpg", "PalaisDeWestminster/planpalaisdewestminster.jpg", "PalaisDeWestminster/interpalaisdewestminster.jpg"); test.AjouterBatimentSimple("Londres", "London Eye", "Description", "LondonEye/londoneye.jpg", "LondonEye/archlondoneye.jpg", "LondonEye/planlondoneye.jpg", "LondonEye/interlondoneye.jpg"); test.AjouterBatimentSimple("Londres", "L'Ogive de Foster", "Description", "LOgiveDeFoster/logivedefoster.jpg", "LOgiveDeFoster/archlogivedefoster.jpg", "LOgiveDeFoster/planlogivedefoster.jfif", "LOgiveDeFoster/interlogivedefoster.jpg"); return(test); }
// Création d'un monstre public void CréerMonstre(Monstre monstre) { try { using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1()) { // Ajouter le monstre dans le monde demandé Monde monde = contexte.Mondes.Find(monstre.MondeId); monstre.Monde = monde; monde.Monstres.Add(monstre); if ((monstre.y > -1 && monstre.y <= monstre.Monde.LimiteY) && (monstre.x > -1 && monstre.x <= monstre.Monde.LimiteX) && (monstre.MondeId > 0 && contexte.Mondes.Any(x => x.Id == monstre.MondeId)) && monstre.Nom != "" && monstre.Niveau > 0 && monstre.StatPV > 0 && !(contexte.Monstres.Any(x => x.Id == monstre.Id))) { contexte.Monstres.Add(monstre); contexte.SaveChanges(); RetournerMonstres(); } } } catch (Exception) { //LstErreursMonstres.Add("Erreur dans la méthode \'CréerMonstre\' : " + ex.Message); } }
public void CliqueGauche() { Monde monde = new Monde(new FlatGenerateur(new Noise())); Vache j1 = new Vache(0, 0); monde.Entites.Add(j1); Assert.AreEqual(j1.Vie, 20); Joueur joueur = new Joueur(0, 0); monde.Entites.Add(joueur); Assert.AreEqual(joueur.Vie, 20); for (int i = 19; i > 0; i--) { j1.CliqueGauche(joueur, 1, monde); Assert.AreEqual(j1.Vie, i); Assert.AreEqual(joueur.Vie, 20); Assert.IsTrue(monde.Entites.Contains(j1)); Assert.IsTrue(monde.Entites.Contains(joueur)); } joueur.AjouterItem(new EpeeBois()); Assert.IsTrue(j1.CliqueGauche(joueur, 1, monde)); Assert.IsFalse(monde.Entites.Contains(j1)); Assert.IsTrue(monde.Entites.Contains(joueur)); }
public bool CreateClass(ClassDetailsDTO newClass, WorldDetailsDTO world) { try { using (HugoLANDContext context = new HugoLANDContext()) { Monde monde = context.Mondes.Find(world.ID); var classe = new Classe() { NomClasse = newClass.ClassName, Description = newClass.Description, StatBaseStr = newClass.StatBaseStr, StatBaseDex = newClass.StatBaseDex, StatBaseReg = newClass.StatBaseReg, StatBaseVitalite = newClass.StatBaseVitality, Monde = monde, }; context.Entry(classe).State = EntityState.Added; context.SaveChanges(); return(true); } } catch { return(false); } }
private void btnSelect_Click(object sender, EventArgs e) { m_currentworld = getCurrentWorld(); this.DialogResult = DialogResult.OK; this.Close(); //mondeBindingSource.Current(); }
/// <summary> /// Actualise le fond d'ecran du form (la map) /// </summary> /// <param name="joueur"></param> /// <param name="monde"></param> public static void Afficher(Joueur joueur, Monde monde) { switch (ecran) { case Ecrans.Jeu: AfficherMap(joueur, monde); break; case Ecrans.Inventaire: AfficherInventaire(); break; case Ecrans.Marchand: AfficherMarchand(); break; case Ecrans.TableCraft: AfficherCraft(); break; case Ecrans.Four: AfficherFour(); break; case Ecrans.Joueur: AfficherJoueur(); break; } }
// Création d'un item public void CréationItem(Item item) { try { using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1()) { // Ajouter le monstre dans le monde demandé Monde monde = contexte.Mondes.Find(item.MondeId); item.Monde = monde; monde.Items.Add(item); if ((item.y > -1 && item.y <= item.Monde.LimiteY) && (item.x > -1 && item.x <= item.Monde.LimiteX) && (item.MondeId > 0 && contexte.Mondes.Any(x => x.Id == item.MondeId)) && item.Nom != "" && !(contexte.Items.Any(x => x.Id == item.Id))) { contexte.Items.Add(item); contexte.SaveChanges(); RetournerItems(); } } } catch (Exception) { } }
// Création d'un héro public void CréationHero(Hero hero) { try { using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1()) { // Ajouter le héro au compte du joueur et au monde CompteJoueur compte = contexte.CompteJoueurs.Find(hero.CompteJoueurId); hero.CompteJoueur = compte; Monde monde = contexte.Mondes.Find(hero.MondeId); hero.Monde = monde; if ((hero.y > -1 && hero.y <= monde.LimiteY) && (hero.x > -1 && hero.x <= monde.LimiteX) && monde.Id == hero.MondeId && hero.NomHero != "" && hero.Niveau > 0 && hero.CompteJoueurId == compte.Id && !(contexte.Heros.Any(z => z.Id == hero.Id))) { compte.Heros.Add(hero); monde.Heros.Add(hero); // Donner une classe de novice si la classe est à null if (hero.Classe == null) { hero.ClasseId = 2056; hero.Classe = contexte.Classes.Find(hero.ClasseId); } contexte.Heros.Add(hero); contexte.SaveChanges(); RetournerHeros(); } } } catch (Exception) { } }
// Éléments étant à proximité du héro public void ÉlémentsRayon200x200(Hero hero) { try { int tileX = 0; using (EntitiesGEDEquipe1 contexte = new EntitiesGEDEquipe1()) { Monde monde = contexte.Mondes.Find(hero.MondeId); Hero heros = contexte.Heros.Find(hero.MondeId); if (contexte.Heros.Any(z => z.Id == hero.Id)) { if (monde.SizeTile != null) { tileX = 200 / (int)monde.SizeTile; } else { tileX = 200 / 16; } lstHero = contexte.Heros.Where(z => z.MondeId == hero.MondeId && (z.x <= hero.x + tileX && z.x >= hero.x - tileX) && (z.y <= hero.y + tileX && z.y >= hero.y - tileX) && hero.Id != z.Id).ToList(); lstItems = contexte.Items.Where(z => z.MondeId == hero.MondeId && (z.x <= hero.x + tileX && z.x >= hero.x - tileX) && (z.y <= hero.y + tileX && z.y >= hero.y - tileX) && hero.Id != z.Id).ToList(); lstMonstres = contexte.Monstres.Where(z => z.MondeId == hero.MondeId && (z.x <= hero.x + tileX && z.x >= hero.x - tileX) && (z.y <= hero.y + tileX && z.y >= hero.y - tileX) && hero.Id != z.Id).ToList(); lstObjmonde = contexte.ObjetMondes.Where(z => z.MondeId == hero.MondeId && (z.x <= hero.x + tileX && z.x >= hero.x - tileX) && (z.y <= hero.y + tileX && z.y >= hero.y - tileX) && hero.Id != z.Id).ToList(); //foreach (var obj in monde.Heros) // if (obj.MondeId == hero.MondeId && (obj.x <= hero.x + tileX && obj.x >= hero.x - tileX) // && (obj.y <= hero.y + tileX && obj.y >= hero.y - tileX) && hero.Id != obj.Id) // lstHero.Add(obj); //foreach (var obj in monde.Items) // if (obj.MondeId == hero.MondeId && (obj.x <= hero.x + tileX && obj.x >= hero.x - tileX) // && (obj.y <= hero.y + tileX && obj.y >= hero.y - tileX)) // lstItems.Add(obj); //foreach (var obj in monde.Monstres) // if (obj.MondeId == hero.MondeId && (obj.x <= hero.x + tileX && obj.x >= hero.x - tileX) // && (obj.y <= hero.y + tileX && obj.y >= hero.y - tileX)) // lstMonstres.Add(obj); //foreach (var obj in monde.ObjetMondes) // if (obj.MondeId == hero.MondeId && (obj.x <= hero.x + tileX && obj.x >= hero.x - tileX) // && (obj.y <= hero.y + tileX && obj.y >= hero.y - tileX)) // lstObjmonde.Add(obj); } } } catch (Exception) { } }
public void Constructeur() { Generateur g = new GenerateurParDefault(new Noise()); Monde m = new Monde(g); Assert.AreEqual(m.Chunks.Count, 0); Assert.AreEqual(m.Entites.Count, 0); Assert.AreEqual(m.Generateur, g); }
/// <summary> /// Constructeur /// </summary> /// <param name="description"></param> /// <param name="limiteX"></param> /// <param name="limiteY"></param> public cMonde(string description, int limiteX, int limiteY) { _monde = new Monde(); _monde.ObjetMonde = new List <ObjetMonde>(); _monde.Monstre = new List <Monstre>(); _monde.Description = description; _monde.LimiteX = limiteX; _monde.LimiteY = limiteY; }
/// <summary> /// Charge un monde et démarre le système. /// </summary> /// <param name="cheminCarte">Le chemin du fichier de sauvegarde du monde.</param> public static void Start(string cheminCarte) { Carte map = ChargerCarteMonde(cheminCarte); if (map != null) { S_Monde = new Monde(map); S_Monde.start(); } }
public void GetBlock() { Generateur g = new FlatGenerateur(new Noise()); Monde m = new Monde(g); Assert.IsNull(m.GetBlock(0, 0, false)); Assert.IsNull(m.GetBlock(0, 0, true)); Assert.IsNull(m.GetBlock(0, -1, false)); Assert.AreEqual(m.GetBlock(0, -1, true).Name, "Terre"); }
private void mnuFileClose_Click(object sender, EventArgs e) { picMap.Visible = false; m_CurrentWorld = null; m_CurrentWorld = new Monde(); m_DObj.Clear(); m_DMonstre.Clear(); m_DItem.Clear(); m_OBJ.Clear(); m_li.Clear(); m_Mons.Clear(); }
public void GetEntity() { Generateur g = new FlatGenerateur(new Noise()); Monde m = new Monde(g); Assert.IsNull(m.GetEntite(0, 0)); Entite ent = new Joueur(0, 0); m.Entites.Add(ent); Assert.AreEqual(m.GetEntite(0, 0), ent); }
/// <summary> /// Auteur: Marc-André Landry /// Create a new world /// </summary> /// <param name="iLimiteX">Limit of the world (x)</param> /// <param name="iLimiteY">Limit of the world (y)</param> /// <param name="sDescription">A small description of your new world!</param> public void CreateMonde(string iLimiteX, string iLimiteY, string sDescription) { Monde monde = new Monde() { LimiteX = iLimiteX, LimiteY = iLimiteY, Description = sDescription }; db.Mondes.Add(monde); db.SaveChanges(); }
public void Equals() { Monde m = new Monde(new FlatGenerateur(new Noise())); Vache j1 = new Vache(0, 0); Vache j2 = new Vache(0, 0); Assert.IsTrue(j1.Equals(j2)); Assert.IsTrue(j2.Equals(j1)); j2.Bouger(1, 0, m); Assert.IsFalse(j1.Equals(j2)); Assert.IsFalse(j2.Equals(j1)); }
/// <summary> /// Indique comment sauvegarder les données et où /// </summary> public void SauvegardeDonnées(Monde LeMonde) { var serializer = new DataContractSerializer(typeof(Monde)); if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } using (Stream s = File.Create(Path.Combine(FilePath, FileName))) { serializer.WriteObject(s, LeMonde); } }
public void Equals() { Monde m = new Monde(new FlatGenerateur(new Noise())); Marchand j1 = new Marchand(0, 0, null); Marchand j2 = new Marchand(0, 0, null); Assert.IsTrue(j1.Equals(j2)); Assert.IsTrue(j2.Equals(j1)); j2.Bouger(1, 0, m); Assert.IsFalse(j1.Equals(j2)); Assert.IsFalse(j2.Equals(j1)); }
public void Bouger() { Monde m = new Monde(new FlatGenerateur(new Noise())); m.GenerateChunk(0, 0); Zombie joueur = new Zombie(0, 0); joueur.Bouger(2, 2, m); Assert.AreEqual(joueur.X, 1); Assert.AreEqual(joueur.Y, 0); joueur.Bouger(-1, -5, m); Assert.AreEqual(joueur.X, 0); Assert.AreEqual(joueur.Y, 0); }
public void Bouger() { Monde m = new Monde(new FlatGenerateur(new Noise())); m.GenerateChunk(0, 0); Marchand joueur = new Marchand(0, 0, null); joueur.Bouger(2, 2, m); Assert.AreEqual(joueur.X, 1); Assert.AreEqual(joueur.Y, 0); joueur.Bouger(-1, -5, m); Assert.AreEqual(joueur.X, 0); Assert.AreEqual(joueur.Y, 0); }
public static Monde InitialiserMondeIlesMorcelees() { var monMonde = new Monde() { Nom = "Îles Morcelées", MesZones = new List <Zone>() { GenererZone1(), GenererZone2() } }; return(monMonde); }
/// <summary> /// Auteur : Marc-André Landry /// /// Delete an object from the world by its ID /// </summary> /// <param name="iID">The ID of the object you want to destroy</param> /// <param name="mondeid">Id du monde</param> public void DeleteObjectMonde(int objectMondeId, int mondeid) { Monde monde = db.Mondes.FirstOrNull(c => c.Id == mondeid); ObjetMonde objMonde = db.ObjetMondes.FirstOrNull(o => o.Id == objectMondeId); if (objMonde == null || monde == null) { return; } db.ObjetMondes.Remove(objMonde); monde.ObjetMondes.Remove(objMonde); db.SaveChanges(); }
public void GenerateChunk() { { Generateur g = new FlatGenerateur(new Noise()); Monde m = new Monde(g); Chunk c = g.Generer(0, 0, new Chunk(new Block[16, 16])).Item1; m.GenerateChunk(0, 0); for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { Block b1 = m.Chunks["0/0"].Blocks[x, y]; Block b2 = c.Blocks[x, y]; Assert.IsTrue((b1 == null && b2 == null) || (b1 != null && b2 != null && b1.Name == b2.Name)); } } } { Generateur g = new GenerateurParDefault(new Noise(100)); Monde m = new Monde(g); Tuple <Chunk, Tuple <int, int, Schematique>[], Entite[]> s = g.Generer(0, 0, new Chunk(new Block[16, 16])); Chunk c = s.Item1; foreach (Tuple <int, int, Schematique> shematic in s.Item2) { foreach (KeyValuePair <string, Block> b in shematic.Item3.Blocks) { string[] a = b.Key.Split('/'); int x = int.Parse(a[0]) + shematic.Item1; int y = int.Parse(a[1]) + shematic.Item1; if (x >= 0 && x < 16 && y >= 0 && y < 16) { c.SetBlock(x % 16, y % 16, b.Value); } } } m.GenerateChunk(0, 0); for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { Block b1 = m.Chunks["0/0"].Blocks[x, y]; Block b2 = c.Blocks[x, y]; Assert.IsTrue((b1 == null && b2 == null) || (b1 != null && b2 != null && b1.Name == b2.Name)); } } } }
/* -------------------------------------------------------------- *\ * m_NewMap() * * - Creates a new map of the selected size. \* -------------------------------------------------------------- */ private void NewMap() { frmNew f; DialogResult result; bool bResult; f = new frmNew(); m_DObj.Clear(); m_DMonstre.Clear(); m_DItem.Clear(); m_OBJ.Clear(); m_li.Clear(); m_Mons.Clear(); m_CurrentWorld = null; m_CurrentWorld = new Monde(); f.MapWidth = m_Map.Width; f.MapHeight = m_Map.Height; f.MapDescription = m_Map.Description; result = f.ShowDialog(this); if (result == DialogResult.OK) { m_bOpen = false; picMap.Visible = false; this.Cursor = Cursors.WaitCursor; try { bResult = m_Map.CreateNew(f.MapWidth, f.MapHeight, f.MapDescription, 32); m_CurrentWorld.LimiteX = m_Map.Width; m_CurrentWorld.LimiteY = m_Map.Height; m_CurrentWorld.Description = m_Map.Description; m_worldNew = true; if (bResult) { m_bOpen = true; m_bRefresh = true; m_bResize = true; picMap.Visible = true; } } catch { Console.WriteLine("Error Creating..."); } m_MenuLogic(); this.Cursor = Cursors.Default; } }
/// <summary> /// si le block a de l'air autoure de lui /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="monde"></param> /// <returns></returns> public static bool CanSeeBlock(int x, int y, Monde monde) { Joueur j = new Joueur(x, y); Func <Block, bool> seeme = (block) => { return(block == null || block.CanPassThrough(j, false)); }; return(seeme(monde.GetBlock(x - 1, y, false)) || seeme(monde.GetBlock(x + 1, y, false)) || seeme(monde.GetBlock(x, y - 1, false)) || seeme(monde.GetBlock(x, y + 1, false)) || seeme(monde.GetBlock(x - 1, y - 1, false)) || seeme(monde.GetBlock(x + 1, y - 1, false)) || seeme(monde.GetBlock(x - 1, y + 1, false)) || seeme(monde.GetBlock(x + 1, y + 1, false))); }
public void Chunks() { Generateur g = new FlatGenerateur(new Noise()); Monde m = new Monde(g); Chunk c = g.Generer(0, 0, new Chunk(new Block[16, 16])).Item1; m.SetBlockChunk(0, 0, c); Assert.AreEqual(m.GetBlockChunk(0, 0), c); m.RemoveBlockChunk(0, 0); Assert.IsNull(m.GetBlockChunk(0, 0)); m.AddBlockChunk(0, 0, c); Assert.AreEqual(m.GetBlockChunk(0, 0), c); m.RemoveBlockChunk(0, 0); Assert.IsNull(m.GetBlockChunk(0, 0)); }
//refresh la map public void Refresh() { List<Monde> lstmonde = Data.MondeController.GetListMonde(); currentWorld = lstmonde.FirstOrDefault(c => c.Id == currentWorld.Id); FillGrass(); List<Monstre> lstmonstre = currentWorld.Monstres.Where(c => c.MondeId == currentWorld.Id && c.x >= _x * MapSizeX && c.x < (_x * MapSizeX + MapSizeX) && c.y >= _y * MapSizeY && c.y < (_y * MapSizeY + MapSizeY)).ToList(); List<ObjetMonde> lstobj = currentWorld.ObjetMondes.Where(c => c.MondeId == currentWorld.Id && c.x >= _x * MapSizeX && c.x < (_x * MapSizeX + MapSizeX) && c.y >= _y * MapSizeY && c.y < (_y * MapSizeY + MapSizeY)).ToList(); List<Item> lstitem = currentWorld.Items.Where(c => c.MondeId == currentWorld.Id && c.x >= _x * MapSizeX && c.x < (_x * MapSizeX + MapSizeX) && c.y >= _y * MapSizeY && c.y < (_y * MapSizeY + MapSizeY)).ToList(); foreach (var m in lstmonstre) { int xm = m.x - _x * MapSizeX; int ym = m.y - _y * MapSizeY; MapTile mapTile = new MapTile(); Map[xm, ym] = mapTile; mapTile.Tile = _tiles[m.Nom]; mapTile.ObjectTile = _tiles[m.Nom]; mapTile.SetSprite(xm, ym); } foreach (var m in lstobj) { int xo = m.x - _x * MapSizeX; int yo = m.y - _y * MapSizeY; if (m.Description != "Sand" && m.Description != "Snow" && m.Description != "Grass" && m.Description != "Dirt" && m.Description != "Path4way" && m.Description != "PathH" && m.Description != "PathV" && m.Description != "PathCornerUR") { MapTile mapTile = new MapTile(); Map[xo, yo] = mapTile; mapTile.Tile = _tiles[m.Description]; mapTile.ObjectTile = _tiles[m.Description]; mapTile.SetSprite(xo, yo); } else { MapTile mapTile = new MapTile(); MapItem[xo, yo] = mapTile; mapTile.Tile = _tiles[m.Description]; mapTile.SetSprite(xo, yo); } } foreach (var m in lstitem) { if (m.x.Value == 0 && m.y.Value == 0) { Console.WriteLine("inv"); } else { int xi = m.x.Value - _x * MapSizeX; int yi = m.y.Value - _y * MapSizeY; MapTile mapTile = new MapTile(); Map[xi, yi] = mapTile; mapTile.Tile = _tiles[m.Nom]; mapTile.ObjectTile = _tiles[m.Nom]; mapTile.SetSprite(xi, yi); } } List<Hero> lstheronear = Data.HeroController.GetListHeroNearHero(Data.CurrentHeroId); if (lstheronear != null) { if (lstheronear.Count != 0) { foreach (var her in lstheronear) { if (her.Id != Data.CurrentHeroId) { MapTile mapTile = new MapTile(); Map[her.x % 8, her.y % 8] = mapTile; mapTile.Tile = _tiles[her.Classe.Description]; mapTile.ObjectTile = _tiles[her.Classe.Description]; mapTile.SetSprite(her.x % 8, her.y % 8); _names[her.x % 8, her.y % 8] = her.Name; } } } } //for (int j = 0; j < MapSizeY; j++) //{ // for (int i = 0; i < MapSizeX; i++) // { // MapTile mapTile2 = new MapTile(); // if (MapItem[i, j] == null) // { // MapItem[i, j] = mapTile2; // mapTile2.Tile = _tiles["Grass"]; // mapTile2.SetSprite(i, j); // } // MapTile mapTile = new MapTile(); // if (Map[i, j] == null) // { // Map[i, j] = MapItem[i, j]; // } // } //} }
/// <summary> /// /// </summary> /// <param name="Mondeid"></param> /// <param name="x">Position du héro X</param> /// <param name="y">Position du héro Y</param> /// <param name="tiles"></param> public Area(int Mondeid, int x, int y, Dictionary<string, Tile> tiles) { _x = x; _y = y; _tiles = tiles; FillGrass(); MondeControllerClient client = new MondeControllerClient(); List<Monde> lstmonde = client.GetListMonde(); currentWorld = lstmonde.FirstOrDefault(c => c.Id == Mondeid); Name = x.ToString() + ',' + y.ToString(); if (y == 0) NorthArea = "-"; else NorthArea = x.ToString() + ',' + (y - 1).ToString(); if (x * 8 + 8 == int.Parse(currentWorld.LimiteX)) EastArea = "-"; else EastArea = (x + 1).ToString() + ',' + (y).ToString(); if (y * 8 + 8 == int.Parse(currentWorld.LimiteY)) SouthArea = "-"; else SouthArea = x.ToString() + ',' + (y + 1).ToString(); if (x == 0) WestArea = "-"; else WestArea = (x - 1).ToString() + ',' + (y).ToString(); if (currentWorld == null) return; int Mondex = int.Parse(currentWorld.LimiteX) / 8; int Mondey = int.Parse(currentWorld.LimiteY) / 8; //Read in 8 lines of 8 characters each. Look up the tile and make the //matching sprite Refresh(); ////Read game objects until the blank line //while (!stream.EndOfStream && (line = stream.ReadLine().Trim()) != "") //{ // //Each line is an x,y coordinate and a tile shortcut // //Look up the tile and construct the sprite // string[] elements = line.Split(','); // int x = Convert.ToInt32(elements[0]); // int y = Convert.ToInt32(elements[1]); // MapTile mapTile = Map[x, y]; // mapTile.ObjectTile = tiles[elements[2]]; // mapTile.SetObjectSprite(x, y); // if (mapTile.ObjectTile.IsTransparent) // { // mapTile.ObjectSprite.ColorKey = Color.FromArgb(75, 75, 75); // } //} }
/// <summary> /// /// Ouvre un form, et load la map selectionnée /// </summary> private void LoadMap() { frmLoad frm = new frmLoad(mondeControleur, context); frm.ShowDialog(this); if (frm.DialogResult != System.Windows.Forms.DialogResult.OK) return; List<Monde> mondelist = mondeControleur.GetListMonde(); CurrentWorld = mondelist.Where(c => c.Id == frm.MondeID).First(); m_Map.ID = frm.MondeID; this.Cursor = Cursors.WaitCursor; NewMap(false); for (int i = 0; i < m_Map.Height; i++) for (int j = 0; j < m_Map.Width; j++) { var Itemlist = CurrentWorld.Items.Where(c => c.x == j && c.y == i).ToList(); var ObjList = CurrentWorld.ObjetMondes.Where(c => c.x == j && c.y == i).ToList(); var MonsterList = CurrentWorld.Monstres.Where(c => c.x == j && c.y == i).ToList(); if (ObjList.Count() != 0) { foreach (var ob in ObjList) { Tile tile = m_TileLibrary.ObjMonde[ob.Description]; m_Map.PlotTile(j,i, tile.X_Image + tile.Y_Image *32); picMap.Refresh(); } } if (Itemlist.Count() != 0) { foreach (var it in Itemlist) { Tile tile = m_TileLibrary.ObjMonde[it.Description]; m_Map.PlotTile(j, i, tile.X_Image + tile.Y_Image * 32); picMap.Refresh(); } } if (MonsterList.Count() != 0) { foreach (var Mo in MonsterList) { Tile tile = m_TileLibrary.ObjMonde[Mo.Nom]; m_Map.PlotTile(j, i, tile.X_Image + tile.Y_Image * 32); picMap.Refresh(); } } } m_bOpen = true; picMap.Visible = true; m_MenuLogic(); m_ResizeMap(); this.Cursor = Cursors.Default; }
//load la map private void CreerAreaDic(int mapid) { MondeControllerClient client = new MondeControllerClient(); List<Monde> lstmonde = client.GetListMonde(); _currentWorld = lstmonde.FirstOrDefault(c => c.Id == mapid); if (_currentWorld == null) return; int Mondex = int.Parse(_currentWorld.LimiteX) / 8; int Mondey = int.Parse(_currentWorld.LimiteY) / 8; for (int x = 0; x < Mondex; x++) { for (int y = 0; y < Mondey; y++) { Area area = new Area(mapid, x, y, _tiles); _world.Add(area.Name, area); } } }