/// <summary> /// /// </summary> /// <param name="hvc"></param> /// <param name="color"></param> /// <param name="hilight"></param> /// <param name="front"></param> /// <param name="side"></param> public ContributionReference(HalfVoxelContribution hvc, int color, int hilight, Direction front, PlaceSide side) { this.contrib = hvc; this.colorIdx = color; this.hilightIdx = hilight; this.placeSide = side; this.frontface = front; this.patternIdx = SpriteSet.GetIndexOf(front, side); }
/// <summary> /// /// </summary> /// <param name="e"></param> /// <param name="hle"></param> protected virtual void LoadHighSprites(XmlElement e, XmlElement hle) { Picture pic = GetPicture(hle, "HL"); if (pic == null || hle.Attributes["src"] == null) { throw new FormatException("highlight picture not found."); } string baseFileName = XmlUtil.Resolve(hle, hle.Attributes["src"].Value).LocalPath; using (Bitmap bit = new Bitmap(baseFileName)) { for (int i = 0; i < hl_patterns; i++) { hilights[i] = new SpriteSet(8); } XmlNode cn = e.FirstChild; while (cn != null) { if (cn.Name.Equals("pattern")) { SideStored ss = ParseSide(cn); Direction d = ParseDirection(cn); Point orgn = XmlUtil.ParsePoint(cn.Attributes["origin"].Value); Point offF = GetOffset(d, PlaceSide.Fore); Point offB = GetOffset(d, PlaceSide.Back); Size sz = new Size(24, 8 + height * 16); // create highlight patterns XmlNode hlp = cn.SelectSingleNode("highlight"); if (hlp != null) { HueShiftSpriteFactory factory = new HueShiftSpriteFactory(hl_patterns); if ((ss & SideStored.Fore) != 0) { ISprite[] arr = factory.CreateSprites(bit, pic, offF, orgn, sz); for (int i = 0; i < hl_patterns; i++) { hilights[i][d, PlaceSide.Fore] = arr[i]; } } if ((ss & SideStored.Back) != 0) { ISprite[] arr = factory.CreateSprites(bit, pic, offB, orgn, sz); for (int i = 0; i < hl_patterns; i++) { hilights[i][d, PlaceSide.Back] = arr[i]; } } } } //if(cn.Name.Equals("pattern")) cn = cn.NextSibling; } //while } //using }
/// <summary> /// Parses a commercial structure contribution from a DOM node. /// </summary> /// <exception cref="XmlException">If the parsing fails</exception> public HalfVoxelContribution(XmlElement e) : base(e) { _price = int.Parse(XmlUtil.SelectSingleNode(e, "price").InnerText); height = int.Parse(XmlUtil.SelectSingleNode(e, "height").InnerText); subgroup = XmlUtil.SelectSingleNode(e, "subgroup").InnerText; XmlElement spr = (XmlElement)XmlUtil.SelectSingleNode(e, "sprite"); XmlElement pic = (XmlElement)XmlUtil.SelectSingleNode(spr, "picture"); variation = spr.SelectSingleNode("map"); if (variation != null) { String idc = variation.Attributes["to"].Value; colors = PluginManager.GetContribution(idc) as ColorLibrary; sprites = new SpriteSet[colors.size]; for (int i = 0; i < colors.size; i++) { sprites[i] = new SpriteSet(8); } } else { colors = ColorLibrary.NullLibrary; sprites = new SpriteSet[1]; sprites[0] = new SpriteSet(8); } LoadSprites(spr, pic); XmlElement hle = (XmlElement)spr.SelectSingleNode("highlight"); if (hle != null) { hilights = new SpriteSet[hl_patterns]; LoadHighSprites(spr, hle); } else { hilights = null; } }
/// <summary> /// /// </summary> /// <param name="org"></param> /// <param name="variation"></param> public SpriteSet(SpriteSet org, Color variation) { }