private static void ParseRectangleItem(XmlNode rectangleItem, Vector2 scrollSpeed, String layerName) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layerName; oi.name = GetObjectName(rectangleItem); foreach (XmlNode child in rectangleItem.ChildNodes) { switch (child.Name) { case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Width": oi.width = ExtractFloat(child); break; case "Height": oi.height = ExtractFloat(child); break; } } //Adjust the position since Gleed handles textures' and primitives' positions differently. oi.position += new Vector2(oi.width / 2, oi.height / 2); objectProcessor.ProcessPrimitiveObject(oi); }
public override void ProcessPrimitiveObject(ObjectInformation oi) { if (oi.customProperties.Count == 0) //No custom properties means a regular platform { Platform tempPlatform = new Platform(oi.width, oi.height, oi.position, oi.name); return; } else { switch (oi.customProperties[0].ToUpper()) { case "SLOPE": new Platform(oi.width, oi.height, oi.position, oi.name, true); return; case "INVERSLOPE": new Platform(oi.width, oi.height, oi.position, oi.name, false); return; case "PLAYER": new Player(oi.position, "PlayerOne"); break; } } }
private static void ProcessTextureItem(string layer, Vector2 scrollSpeed, XmlNode properties, ContentManager cm) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layer; oi.name = "TEMP"; foreach (XmlNode child in properties.ChildNodes) { switch (child.Name) { case "Name": oi.name = child.InnerText; break; case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Rotation": oi.rotation = ExtractFloat(child); break; case "Scale": oi.scale = ExtractVector2(child);; break; case "FlipHorizontally": oi.flipH = ExtractBool(child); break; case "FlipVertically": oi.flipV = ExtractBool(child); break; case "TexturePathRelativeToContentRoot": String[] splitString = child.FirstChild.Value.Split('\\'); try { oi.texture = cm.Load <Texture2D>(child.FirstChild.Value); } //This causes major performance issues at the moment catch (ContentLoadException e) { } break; } } objectProcessor.ProcessTextureObject(oi); }
private void CreateCameraObject(ObjectInformation oi) { bool unlockDirection = CameraObject.UnlockWhenPlayerMovesLeft; if (oi.customProperties[0].Equals("TRUE", StringComparison.OrdinalIgnoreCase)) { unlockDirection = CameraObject.UnlockWhenPlayerMovesRight; } new CameraObject(2000, 2, oi.position, unlockDirection, oi.name); }
public override void ProcessTextureObject(ObjectInformation oi) { switch (oi.name.ToUpper()) { case "CAMERAOBJECT": CameraObject cameraObject = new CameraObject(2000, 2, oi.position, true, oi.name); return; } //If we have come this far we will create a tile with the texture Tile t = new Tile(item.getTexture(), item.Position, layer.ScrollSpeed, item.Name, layer.Name); }
public override void ProcessTextureObject(ObjectInformation oi) { //It is not a valid ObjectInformation if (oi.texture == null) { return; } switch (oi.name.ToUpper()) { case "CAMERAOBJECT": this.CreateCameraObject(oi); return; } //If we have come this far we will create a tile with the texture Tile t = new Tile(oi.texture, oi.position, oi.scale, oi.rotation,oi.flipH, oi.flipV, oi.scrollSpeed, oi.name, oi.name); }
private static void ParseTextureItem(XmlNode textureItem, Vector2 scrollSpeed, String layerName, ContentManager cm) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layerName; oi.name = "TEMP"; foreach (XmlNode child in textureItem.ChildNodes) { switch (child.Name) { case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Rotation": oi.rotation = ExtractFloat(child); break; case "Scale": oi.scale = ExtractVector2(child);; break; case "FlipHorizontally": oi.flipH = ExtractBool(child); break; case "FlipVertically": oi.flipV = ExtractBool(child); break; case "asset_name": //oi.texture = cm.Load<Texture2D>(child.FirstChild.Value); String[] splitString = child.FirstChild.Value.Split('\\'); String name = splitString[splitString.Length - 1]; oi.name = name; break; } } objectProcessor.ProcessTextureObject(oi); }
private static void ProcessRectangleItem(string layer, Vector2 scrollSpeed, XmlNode properties) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layer; oi.name = "TEMP"; foreach (XmlNode child in properties.ChildNodes) { switch (child.Name) { case "Name": oi.name = child.InnerText; break; case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Width": oi.width = ExtractFloat(child); break; case "Height": oi.height = ExtractFloat(child); break; case "Rotation": oi.rotation = ExtractFloat(child); break; } } //Adjust the position since Gleed handles textures' and primitives' positions differently. oi.position.X += oi.width / 2; oi.position.Y += oi.height / 2; objectProcessor.ProcessPrimitiveObject(oi); }
private static void ParseTextureItem(XmlNode textureItem, Vector2 scrollSpeed, String layerName, ContentManager cm) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layerName; oi.name = "TEMP"; foreach (XmlNode child in textureItem.ChildNodes) { switch (child.Name) { case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Rotation": oi.rotation = ExtractFloat(child); break; case "Scale": oi.scale = ExtractVector2(child);; break; case "FlipHorizontally": oi.flipH = ExtractBool(child); break; case "FlipVertically": oi.flipV = ExtractBool(child); break; case "Origin": oi.origin = ExtractVector2(child); break; case "asset_name": try { oi.texturePath = child.FirstChild.Value; oi.texture = cm.Load <Texture2D>(oi.texturePath); } //This causes major performance issues at the moment catch (ContentLoadException e) { bool hej = true; } String[] splitString = child.FirstChild.Value.Split('\\'); oi.textureName = splitString[splitString.Length - 1]; String name = GetObjectName(textureItem); oi.name = name; break; } } Vector2 middle = Vector2.Zero; if (oi.texture != null) { middle = new Vector2(oi.texture.Width / 2, oi.texture.Height / 2); Vector2 offset = middle - oi.origin; oi.position += offset; } //oi.origin *= oi.scale; objectProcessor.ProcessTextureObject(oi); }
public abstract void ProcessPrimitiveObject(ObjectInformation oi);
public abstract void ProcessTextureObject(ObjectInformation oi);
private static void ParseTextureItem(XmlNode textureItem, Vector2 scrollSpeed, String layerName, ContentManager cm) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layerName; oi.name = "TEMP"; foreach(XmlNode child in textureItem.ChildNodes) { switch (child.Name) { case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Rotation": oi.rotation = ExtractFloat(child); break; case "Scale": oi.scale = ExtractVector2(child);; break; case "FlipHorizontally": oi.flipH = ExtractBool(child); break; case "FlipVertically": oi.flipV = ExtractBool(child); break; case "asset_name": try { oi.texture = cm.Load<Texture2D>(child.FirstChild.Value); } //This causes major performance issues at the moment catch (ContentLoadException e) { } String[] splitString = child.FirstChild.Value.Split('\\'); String name = splitString[splitString.Length - 1]; oi.name = name; break; } } objectProcessor.ProcessTextureObject(oi); }
private static void ParseRectangleItem(XmlNode rectangleItem, Vector2 scrollSpeed, String layerName) { ObjectInformation oi = new ObjectInformation(); oi.scrollSpeed = scrollSpeed; oi.layer = layerName; oi.name = "TEMP"; foreach (XmlNode child in rectangleItem.ChildNodes) { switch (child.Name) { case "Position": oi.position = ExtractVector2(child); break; case "CustomProperties": oi.customProperties = ExtractCustomProperties(child); break; case "Width": oi.width = ExtractFloat(child); break; case "Height": oi.height = ExtractFloat(child); break; } } //Adjust the position since Gleed handles textures' and primitives' positions differently. oi.position.X += oi.width / 2; oi.position.Y += oi.height / 2; objectProcessor.ProcessPrimitiveObject(oi); }