public virtual List <GridLocation> GetBotSlots(Vector4 a_boundingBox) { List <GridLocation> botSlots = new List <GridLocation>(); // Slots below bounding box for (float i = a_boundingBox.X; i <= a_boundingBox.Y; i += SlotDimensions.X) { botSlots.Add(GetSlotFromPixel(new Vector2(i, a_boundingBox.W + SlotDimensions.Y), Vector2.Zero)); } GridLocation lastSlot = GetSlotFromPixel(new Vector2(a_boundingBox.Y - 1, a_boundingBox.W + SlotDimensions.Y), Vector2.Zero); if (botSlots.Last() != lastSlot) { botSlots.Add(lastSlot); } return(botSlots); }
public virtual void AddGridItem(XElement a_tile, Vector2 a_location, string a_layer) { XElement image = a_tile.Element("image"); Vector2 tmpDims = new Vector2(Convert.ToInt32(image.Attribute("width").Value) * 2, Convert.ToInt32(image.Attribute("height").Value) * 2); Vector2 offsetDims = new Vector2(tmpDims.X / 2, SlotDimensions.Y - tmpDims.Y / 2); _gridItems.Add(new GridItem(/* Path */ image.Attribute("source").Value, /* Position */ GetPositionFromLocation(a_location) + offsetDims, /* Dimensions */ tmpDims, /* Frames */ new Vector2(1, 1), /* Layer */ a_layer)); GridLocation slot = GetSlotFromLocation(a_location); bool isImpassible = Convert.ToBoolean(a_tile.Element("properties").Descendants().Where(elem => (string)elem.Attribute("name") == "impassible").FirstOrDefault().Attribute("value").Value); bool isDeadly = Convert.ToBoolean(a_tile.Element("properties").Descendants().Where(elem => (string)elem.Attribute("name") == "deadly").FirstOrDefault().Attribute("value").Value); slot.SetToFilled(isImpassible); slot.Deadly = isDeadly; }