/* * public void setCollisionBoxesForStaticObjects * (string propertyName, List<TextureItem> textureItems, List<StaticObject> staticObjects) * { * foreach (TextureItem items in textureItems) * { * CollisionBox collisionBox = null; * * if (items.CustomProperties.ContainsKey(propertyName)) * { * if (items.CustomProperties[propertyName].type == typeof(Item)) * { * Console.WriteLine("StaticObject CollisionBox"); * RectangleItem rectangleItem = (RectangleItem)items.CustomProperties[propertyName].value; * collisionBox = new CollisionBox(rectangleItem.Position, rectangleItem.Width, rectangleItem.Height); * * } * } * staticObjects.Add(new StaticObject(items.texture, items.asset_name, items.Name, items.Visible, items.Position, new Vector2(8, 8), * items.Rotation, items.Scale, items.Origin, collisionBox)); * } * } */ public void copyFromItemList() { foreach (Layer layer in Layers) { foreach (Item item in layer.Items) { if (item is TextureItem) { TextureItem textureItem = (TextureItem)item; layer.textureItems.Add(textureItem); } else if (item is RectangleItem) { RectangleItem rectangleItem = (RectangleItem)item; layer.rectangleItems.Add(rectangleItem); } else if (item is PathItem) { PathItem pathItem = (PathItem)item; layer.pathItems.Add(pathItem); } else if (item is CircleItem) { CircleItem circleItem = (CircleItem)item; layer.circleItems.Add(circleItem); } } } }
public override Item clone() { CircleItem result = (CircleItem)this.MemberwiseClone(); result.CustomProperties = new SerializableDictionary(CustomProperties); result.hovering = false; return(result); }
void SuperHackyLevelParsing() { foreach (GLEED2D.Layer layer in testLevel.Layers) { if (layer.Name.ToLower() == "collision") { //For now only process this layer //All items on this layer should be either a path, circle, or AABB foreach (GLEED2D.Item item in layer.Items) { //I don't like this, it's fine for when they were serialized out but not for loading them. //One size does not fit all if (item.GetType() == typeof(GLEED2D.PathItem)) { CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionPath((GLEED2D.PathItem)item)); } else if (item.GetType() == typeof(GLEED2D.RectangleItem)) { GLEED2D.RectangleItem gleeRect = (GLEED2D.RectangleItem)item; Rectangle zeRect = new Rectangle((int)gleeRect.Position.X, (int)gleeRect.Position.Y, (int)gleeRect.Width, (int)gleeRect.Height); CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionAABB(zeRect)); } else if (item.GetType() == typeof(GLEED2D.CircleItem)) { GLEED2D.CircleItem gleeCircle = (GLEED2D.CircleItem)item; CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionCircle(gleeCircle.Position, gleeCircle.Radius)); } } } } }
public void paintPrimitiveBrush() { switch (currentprimitive) { case PrimitiveType.Rectangle: Item ri = new RectangleItem(Extensions.RectangleFromVectors(clickedPoints[0], clickedPoints[1])); ri.Name = ri.getNamePrefix() + level.getNextItemNumber(); ri.layer = SelectedLayer; beginCommand("Add Item \"" + ri.Name + "\""); addItem(ri); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Rectangle_Entered; break; case PrimitiveType.Circle: Item ci = new CircleItem(clickedPoints[0], (mouseworldpos - clickedPoints[0]).Length()); ci.Name = ci.getNamePrefix() + level.getNextItemNumber(); ci.layer = SelectedLayer; beginCommand("Add Item \"" + ci.Name + "\""); addItem(ci); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Circle_Entered; break; case PrimitiveType.Path: Item pi = new PathItem(clickedPoints.ToArray()); pi.Name = pi.getNamePrefix() + level.getNextItemNumber(); pi.layer = SelectedLayer; beginCommand("Add Item \"" + pi.Name + "\""); addItem(pi); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Entered; AdesExtensions.onAddPoly(pi); break; } updatetreeview(); }
public void paintPrimitiveBrush() { int nextnum = level.getNextItemNumber(); switch (currentprimitive) { case PrimitiveType.CollisionRectangle: MapObject ri; if (customEntity) { ri = (MapObject)Activator.CreateInstance(customEntityType, Extensions.RectangleFromVectors(clickedPoints[0], clickedPoints[1])); } else { ri = new CollisionRectangle(Extensions.RectangleFromVectors(clickedPoints[0], clickedPoints[1])); } ri.Id = generateID(nextnum); ri.Name = ri.getNamePrefix() + nextnum; ri.layer = SelectedLayer; beginCommand("Add MapObject \"" + ri.Name + "\""); addItem(ri); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Rectangle_Entered; break; case PrimitiveType.Circle: MapObject ci; if (customEntity) { ci = (MapObject)Activator.CreateInstance(customEntityType, clickedPoints[0], (mouseworldpos - clickedPoints[0]).Length()); } else { ci = new CircleItem(clickedPoints[0], (mouseworldpos - clickedPoints[0]).Length()); } ci.Id = generateID(nextnum); ci.Name = ci.getNamePrefix() + nextnum;// level.getNextItemNumber(); ci.layer = SelectedLayer; beginCommand("Add MapObject \"" + ci.Name + "\""); addItem(ci); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Circle_Entered; break; case PrimitiveType.Path: MapObject pi; if (customEntity) { pi = (MapObject)Activator.CreateInstance(customEntityType, clickedPoints.ToArray()); } else { pi = new PathItem(clickedPoints.ToArray()); } pi.Id = generateID(nextnum); pi.Name = pi.getNamePrefix()+nextnum;// pi.layer = SelectedLayer; beginCommand("Add MapObject \"" + pi.Name + "\""); addItem(pi); endCommand(); MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Entered; break; } updatetreeview(); }