private void checkDoors(MapTile mapTile, int x, int y) { //If the next tile is a closed door then check if we have the key if (mapTile.Tile.Name == "DoorClosed" && mapTile.Tile.IsBlock) { //For each key if it matches then open the door by switching the sprite & sprite to its matching open version if (_gameState.HasRedKey) { //Open the door mapTile.Tile = _tiles["DoorOpen"]; mapTile.SetSprite(x, y); } } }
//met du gazon par defaut public void FillGrass() { for (int j = 0; j < MapSizeY; j++) { for (int i = 0; i < MapSizeX; i++) { MapTile mapTile2 = new MapTile(); MapItem[i, j] = mapTile2; mapTile2.Tile = _tiles["Grass"]; mapTile2.SetSprite(i, j); _names[i, j] = null; Map[i, j] = MapItem[i, j]; } } }
//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]; // } // } //} }
//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]; // } // } //} }