/*public static Rectangle[] getrectTorcheTab(Vector2[] posTorcheTab, Texture2D _torche) { List<Rectangle> nouvList = new List<Rectangle>(); foreach (Vector2 vect in posTorcheTab) nouvList.Add(new Rectangle((int)vect.X, (int)vect.Y, _torche.Width, _torche.Height)); return nouvList.ToArray(); } /*public static Rectangle[] getrectGargouilleTab(Vector2[] posGargouilleTab, Texture2D _gargouille) { List<Rectangle> nouvList = new List<Rectangle>(); foreach (Vector2 vect in posGargouilleTab) nouvList.Add(new Rectangle((int)vect.X, (int)vect.Y, _gargouille.Width, _gargouille.Height)); return nouvList.ToArray(); }*/ public static Element createElement(Element.ElementType type, Texture2D[] listOfTextures, Vector2 loc, Texture2D _waterExample, Rectangle[] waterRectTab, Texture2D _bridge, Background background) { Element nouvEl = new Element(); nouvEl.Type = type; if (type == Element.ElementType.Null) nouvEl.Texture = listOfTextures[0]; else if (type == Element.ElementType.Tree) nouvEl.Texture = listOfTextures[1]; else if (type == Element.ElementType.Water) nouvEl.Texture = _waterExample; else if (type == Element.ElementType.Bridge) nouvEl.Texture = listOfTextures[3]; /*else if (type == Element.ElementType.Gargouille) nouvEl.Texture = listOfTextures[5];*/ else if (type == Element.ElementType.Torche) nouvEl.Texture = listOfTextures[6]; else //if (type == Game1.ElementType.Stone) nouvEl.Texture = listOfTextures[4]; if (nouvEl.Type == Element.ElementType.Tree) nouvEl.BeginningLocation = new Vector2(loc.X * Game1.caseWidth, + loc.Y * Game1.caseHeight - Game1.caseHeight); else if (nouvEl.Type == Element.ElementType.Stone) nouvEl.BeginningLocation = new Vector2(loc.X * Game1.caseWidth + Game1.caseWidth / 2 - nouvEl.Texture.Height / 2, loc.Y * Game1.caseHeight + Game1.caseHeight / 2 - nouvEl.Texture.Width / 2); else nouvEl.BeginningLocation = new Vector2(loc.X * Game1.caseWidth, loc.Y * Game1.caseHeight); return nouvEl; }
//ONLY draws every Water element. public static void drawWaterBridge(Element[,] elementTab, SpriteBatch spBatch, Texture2D waterTile, Texture2D _bridge) { foreach (Element elem in elementTab) { if (elem.Type == Element.ElementType.Water) spBatch.Draw(waterTile, new Rectangle((int)elem.UpdatedLocation.X, (int)elem.UpdatedLocation.Y, elem.Texture.Width, elem.Texture.Height), elem.SourceRectangle, Color.White); else if (elem.Type == Element.ElementType.Bridge) spBatch.Draw(_bridge, elem.UpdatedLocation, Color.White); } }
public static Vector2[] getposGateTab(Element[,] elementTab) { List<Vector2> nouvlist = new List<Vector2>(); nouvlist.Clear(); foreach (Element elem in elementTab) { if (elem.Type == Element.ElementType.Gate) nouvlist.Add(elem.UpdatedLocation); } return nouvlist.ToArray(); }
public static Element[,] charMapToElementMap(char[,] charTab, Texture2D[] listOfTextures, Rectangle[] waterRectTab, Texture2D _bridge, Background background, Texture2D _waterExample) { Element[,] elementTab = new Element[charTab.GetLength(0), charTab.GetLength(1)]; for (int x = 0; x < charTab.GetLength(0); x++) //lignes { for (int y = 0; y < charTab.GetLength(1); y++) //colonnes { if (charTab[x, y] == '_') elementTab[x, y] = Element_Manager.createElement(Element.ElementType.Null, listOfTextures, new Vector2(y, x), _waterExample, waterRectTab, _bridge, background); else if (charTab[x, y] == 't') elementTab[x, y] = Element_Manager.createElement(Element.ElementType.Tree, listOfTextures, new Vector2(y, x), _waterExample, waterRectTab, _bridge, background); else if (charTab[x, y] == 's') elementTab[x, y] = Element_Manager.createElement(Element.ElementType.Stone, listOfTextures, new Vector2(y, x), _waterExample, waterRectTab, _bridge, background); else if (charTab[x, y] == 'w') elementTab[x, y] = Element_Manager.createElement(Element.ElementType.Water, listOfTextures, new Vector2(y, x), _waterExample, waterRectTab, _bridge, background); else if (charTab[x, y] == 'b') elementTab[x, y] = Element_Manager.createElement(Element.ElementType.Bridge, listOfTextures, new Vector2(y, x), _waterExample, waterRectTab, _bridge, background); else throw new Exception(); } } return elementTab; }
public static Element[,] updateElementTab(Element[,] elementTab, Background backG) { foreach (Element elem in elementTab) { elem.UpdatedLocation = new Vector2(backG.Location.X + elem.BeginningLocation.X, backG.Location.Y + elem.BeginningLocation.Y); } return elementTab; }