Ejemplo n.º 1
0
 /*
  * 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()
        {
            RectangleItem result = (RectangleItem)this.MemberwiseClone();

            result.CustomProperties = new SerializableDictionary(CustomProperties);
            result.hovering         = false;
            return(result);
        }
Ejemplo n.º 3
0
    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));
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
        public override Item clone()
        {
            RectangleItem result = (RectangleItem)this.MemberwiseClone();

            result.CustomProperties               = new SerializableDictionary(CustomProperties);
            result.Scale                          = new CustomNode("string");
            result.BodyScale                      = new CustomNode("string");
            result.ManualBodyScale.value          = this.ManualBodyScale.value;
            result.Rotation                       = new CustomNode("string");
            result.Position                       = new CustomNode("string");
            result.ResetOnLoad                    = new CustomNode("string");
            result.SecondaryObjectId              = new CustomNode("string");
            result.ActivatesObjectWithSecondaryId = new CustomNode("string");
            result.ActivatedBySecondaryObjectIds  = new CustomNode("string");
            ArchetypeId     = new CustomNode("string");
            result.hovering = false;
            result.OnTransformed();
            return(result);
        }
Ejemplo n.º 5
0
 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();
 }