public EntityMoveNodeAction(EntityLayer entityLayer, Entity entity, int nodeIndex, Point moveTo)
     : base(entityLayer)
 {
     this.entity = entity;
     this.nodeIndex = nodeIndex;
     this.moveTo = moveTo;
 }
 public EntityInsertNodeAction(EntityLayer entityLayer, Entity entity, Point node, int index)
     : base(entityLayer)
 {
     this.entity = entity;
     this.node = node;
     this.index = index;
 }
 public EntityResizeAction(EntityLayer entityLayer, List<Entity> entities, Size resize)
     : base(entityLayer)
 {
     this.entities = new List<Entity>(entities);
     this.resize = resize;
     was = new List<Size>();
     for (int i = 0; i < entities.Count; i++)
         was.Add(new Size());
 }
 public EntityRotateAction(EntityLayer entityLayer, List<Entity> entities, float rotateTo)
     : base(entityLayer)
 {
     this.entities = new List<Entity>(entities);
     this.rotateTo = rotateTo;
     was = new List<float>();
     for (int i = 0; i < entities.Count; i++)
         was.Add(0);
 }
Exemple #5
0
        public Entity(EntityLayer layer, XmlElement xml)
        {
            Layer = layer;
            Definition = Ogmo.Project.EntityDefinitions.Find(d => d.Name == xml.Name);

            //ID
            if (xml.Attributes["id"] != null)
                ID = Convert.ToUInt32(xml.Attributes["id"].InnerText);
            else
                ID = layer.GetNewEntityID();

            //Position
            Position = new Point(Convert.ToInt32(xml.Attributes["x"].InnerText), Convert.ToInt32(xml.Attributes["y"].InnerText));

            //Size
            if (Definition.ResizableX && xml.Attributes["width"] != null)
                Size.Width = Convert.ToInt32(xml.Attributes["width"].InnerText);
            else
                Size.Width = Definition.Size.Width;
            if (Definition.ResizableY && xml.Attributes["height"] != null)
                Size.Height = Convert.ToInt32(xml.Attributes["height"].InnerText);
            else
                Size.Height = Definition.Size.Height;

            //Rotation
            if (Definition.Rotatable && xml.Attributes["angle"] != null)
                Angle = Ogmo.Project.ImportAngle(xml.Attributes["angle"].InnerText);

            //Nodes
            if (Definition.NodesDefinition.Enabled)
            {
                Nodes = new List<Point>();
                foreach (XmlElement node in xml.GetElementsByTagName("node"))
                    Nodes.Add(new Point(Convert.ToInt32(node.Attributes["x"].InnerText), Convert.ToInt32(node.Attributes["y"].InnerText)));
            }

            //Values
            if (Definition.ValueDefinitions.Count > 0)
            {
                Values = new List<Value>(Definition.ValueDefinitions.Count);
                foreach (var d in Definition.ValueDefinitions)
                    Values.Add(new Value(d));
                OgmoParse.ImportValues(Values, xml);
            }
        }
Exemple #6
0
        public Entity(EntityLayer layer, EntityDefinition def, Point position)
        {
            Layer = layer;
            Definition = def;
            ID = layer.GetNewEntityID();

            Position = position;
            Size = def.Size;
            Angle = 0;

            //Nodes
            if (def.NodesDefinition.Enabled)
                Nodes = new List<Point>();

            //Values
            if (def.ValueDefinitions.Count > 0)
            {
                Values = new List<Value>(def.ValueDefinitions.Count);
                foreach (var d in def.ValueDefinitions)
                    Values.Add(new Value(d));
            }
        }
 public EntityLayerEditor(LevelEditor levelEditor, EntityLayer layer)
     : base(levelEditor, layer)
 {
     Layer = layer;
 }
 public EntityAddNodeAction(EntityLayer entityLayer, Entity entity, Point node)
     : base(entityLayer)
 {
     this.entity = entity;
     this.node = node;
 }
 public EntityRemoveNodeAction(EntityLayer entityLayer, Entity entity, int index)
     : base(entityLayer)
 {
     this.entity = entity;
     this.index = index;
 }
 public EntityAddAction(EntityLayer entityLayer, Entity entity)
     : base(entityLayer)
 {
     added = entity;
 }
 public EntityRemoveAction(EntityLayer entityLayer, List<Entity> entities)
     : base(entityLayer)
 {
     toRemove = entities;
 }
Exemple #12
0
        public Entity(EntityLayer layer, XmlElement xml)
        {
            Layer      = layer;
            Definition = Ogmo.Project.EntityDefinitions.Find(d => d.Name == xml.Name);

            //ID
            if (xml.Attributes["id"] != null)
            {
                ID = Convert.ToUInt32(xml.Attributes["id"].InnerText);
            }
            else
            {
                ID = layer.GetNewEntityID();
            }

            //Position
            Position = new Point(Convert.ToInt32(xml.Attributes["x"].InnerText), Convert.ToInt32(xml.Attributes["y"].InnerText));

            //Size
            if (Definition.ResizableX && xml.Attributes["width"] != null)
            {
                Size.Width = Convert.ToInt32(xml.Attributes["width"].InnerText);
            }
            else
            {
                Size.Width = Definition.Size.Width;
            }
            if (Definition.ResizableY && xml.Attributes["height"] != null)
            {
                Size.Height = Convert.ToInt32(xml.Attributes["height"].InnerText);
            }
            else
            {
                Size.Height = Definition.Size.Height;
            }

            //Rotation
            if (Definition.Rotatable && xml.Attributes["angle"] != null)
            {
                Angle = Ogmo.Project.ImportAngle(xml.Attributes["angle"].InnerText);
            }

            //Nodes
            if (Definition.NodesDefinition.Enabled)
            {
                Nodes = new List <Point>();
                foreach (XmlElement node in xml.GetElementsByTagName("node"))
                {
                    Nodes.Add(new Point(Convert.ToInt32(node.Attributes["x"].InnerText), Convert.ToInt32(node.Attributes["y"].InnerText)));
                }
            }

            //Values
            if (Definition.ValueDefinitions.Count > 0)
            {
                Values = new List <Value>(Definition.ValueDefinitions.Count);
                foreach (var d in Definition.ValueDefinitions)
                {
                    Values.Add(new Value(d));
                }
                OgmoParse.ImportValues(Values, xml);
            }
        }
Exemple #13
0
        public Entity(EntityLayer layer, JObject json)
        {
            Layer      = layer;
            Definition = Ogmo.Project.EntityDefinitions.Find(d => d.Name == (string)json.GetValue("name"));

            //ID
            if (json.Property("id") != null)
            {
                ID = Convert.ToUInt32(json.GetValue("id"));
            }
            else
            {
                ID = layer.GetNewEntityID();
            }

            //Position
            Position = new Point(Convert.ToInt32(json.GetValue("x")), Convert.ToInt32(json.GetValue("y")));

            //Size
            if (Definition.ResizableX && json.Property("width") != null)
            {
                Size.Width = Convert.ToInt32(json.GetValue("width"));
            }
            else
            {
                Size.Width = Definition.Size.Width;
            }

            if (Definition.ResizableY && json.Property("height") != null)
            {
                Size.Height = Convert.ToInt32(json.GetValue("height"));
            }
            else
            {
                Size.Height = Definition.Size.Height;
            }

            //Rotation
            if (Definition.Rotatable && json.Property("angle") != null)
            {
                Angle = Ogmo.Project.ImportAngle((string)json.GetValue("angle"));
            }

            //Nodes
            if (Definition.NodesDefinition.Enabled)
            {
                Nodes = new List <Point>();
                if (json.Property("nodes") != null)
                {
                    foreach (JObject node in json.GetValue("nodes"))
                    {
                        Nodes.Add(new Point(Convert.ToInt32(node.GetValue("x")), Convert.ToInt32(node.GetValue("y"))));
                    }
                }
            }

            //Values
            if (Definition.ValueDefinitions.Count > 0)
            {
                Values = new List <Value>(Definition.ValueDefinitions.Count);
                foreach (var d in Definition.ValueDefinitions)
                {
                    Values.Add(new Value(d));
                }
                OgmoParse.ImportValues(Values, json);
            }
        }
Exemple #14
0
        public Entity(EntityLayer layer, Entity e)
        {
            Layer = layer;
            Definition = e.Definition;
            ID = layer.GetNewEntityID();

            Position = e.Position;
            Size = e.Size;
            Angle = e.Angle;

            //Nodes
            if (Definition.NodesDefinition.Enabled)
            {
                Nodes = new List<Point>();
                foreach (var p in e.Nodes)
                    Nodes.Add(p);
            }

            //Values
            if (Definition.ValueDefinitions.Count > 0)
            {
                Values = new List<Value>(e.Values.Count);
                foreach (var v in e.Values)
                    Values.Add(new Value(v));
            }
        }
Exemple #15
0
        /// <summary>
        /// Edit to give the ability to generate random levels.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void generateRandomLevel_Click(object sender, EventArgs e)
        {
            // Launch an entity (Ladder)


            for (int i = 0; i < 5; i++)
            {
                //Ogmo.MainWindow.LevelEditors[Ogmo.CurrentLevelIndex].Perform(
                //new OgmoEditor.LevelEditors.Actions.EntityActions.EntityAddAction(
                //    (OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2],
                //    new OgmoEditor.LevelData.Layers.Entity(
                //        (OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2],
                //        Ogmo.EntitiesWindow.CurrentEntity,
                //        new Point(
                //            (int)OgmoEditor.LevelEditors.Tools.FlxCaveGeneratorExt.random(0, sizeX),
                //            (int)OgmoEditor.LevelEditors.Tools.FlxCaveGeneratorExt.random(0, sizeY)
                //            )
                //        )
                //    )
                //);

                LevelEditor LE = Ogmo.MainWindow.LevelEditors[Ogmo.CurrentLevelIndex];
                LevelData.Layers.EntityLayer Lyr = (OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2];

                int sizeX = LevelEditors[Ogmo.CurrentLevelIndex].LayerEditors[2].Layer.Level.Size.Width;
                int sizeY = LevelEditors[Ogmo.CurrentLevelIndex].LayerEditors[2].Layer.Level.Size.Height;


                LE.Perform(
                    new OgmoEditor.LevelEditors.Actions.EntityActions.EntityAddAction(Lyr, new OgmoEditor.LevelData.Layers.Entity(
                                                                                          Lyr,
                                                                                          Ogmo.EntitiesWindow.CurrentEntity,
                                                                                          new Point(
                                                                                              (int)FlxCaveGeneratorExt.random(0, sizeX),
                                                                                              (int)FlxCaveGeneratorExt.random(0, sizeY)
                                                                                              )
                                                                                          )
                                                                                      )
                    );
            }

            Ogmo.MainWindow.LevelEditors[Ogmo.CurrentLevelIndex].Perform(
                new OgmoEditor.LevelEditors.Actions.EntityActions.EntityAddAction(
                    (OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2],
                    new OgmoEditor.LevelData.Layers.Entity((OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2],
                                                           Ogmo.EntitiesWindow.CurrentEntity, new Point(32, 32))));

            LevelEditors[Ogmo.CurrentLevelIndex].generateRandomLevel();

            Console.WriteLine("This level is: {0}", LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[0].ToString());
            Console.WriteLine("This level is: {0}", LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[1].ToString());
            Console.WriteLine("This level is: {0}", LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2].ToString());



//            OgmoEditor.LevelEditors.Tools.EntityTools.EntityPlacementTool.



            //OgmoEditor.LevelData.Layers.Entity e2 = Ogmo.EntitySelectionWindow.Selected[0];

            //foreach (var item in  ((OgmoEditor.LevelData.Layers.EntityLayer)Ogmo.EntitiesWindow.CurrentEntity.Name)
            //{
            //    Console.WriteLine(item.ToString() );
            //}

            //OgmoEditor.LevelData.Layers.Entity e3 = Ogmo.EntitiesWindow.CurrentEntity;

            //((OgmoEditor.LevelData.Layers.EntityLayer)Ogmo.CurrentLevel.Layers[Ogmo.LayersWindow.CurrentLayerIndex]).Entities.FindAll(en => en.Definition == entity.Definition)

            //Console.WriteLine(((OgmoEditor.LevelData.Layers.EntityLayer)Ogmo.CurrentLevel.Layers[2]).Entities);

            //foreach (var e4 in Ogmo.EntitySelectionWindow.Selected)
            //{
            //    Console.WriteLine(e4.ToString());
            //}



            //Ogmo.MainWindow.LevelEditors[Ogmo.CurrentLevelIndex].Perform(
            //    new OgmoEditor.LevelEditors.Actions.EntityActions.EntityInsertNodeAction(
            //        (OgmoEditor.LevelData.Layers.EntityLayer)LevelEditors[Ogmo.CurrentLevelIndex].Level.Layers[2],
            //        Ogmo.EntitySelectionWindow.Selected[0], new Point(32, 32), 0
            //        ));

            LevelEditors[Ogmo.CurrentLevelIndex].LayerEditors[Ogmo.LayersWindow.CurrentLayerIndex].SelectAll();

            //LevelEditors[Ogmo.CurrentLevelIndex].Perform(

            //LevelEditors[Ogmo.CurrentLevelIndex].Perform(new EntityAddAction(LayerEditor.Layer, new Entity(LayerEditor.Layer, Ogmo.EntitiesWindow.CurrentEntity, Util.Ctrl ? LevelEditor.MousePosition : LayerEditor.MouseSnapPosition)));

            //LevelEditor.Perform(new EntityAddAction(LayerEditor.Layer,
            //new Entity(LayerEditor.Layer, Ogmo.EntitiesWindow.CurrentEntity, Util.Ctrl ? LevelEditor.MousePosition : LayerEditor.MouseSnapPosition)));
        }
 public EntityMoveAction(EntityLayer entityLayer, List<Entity> entities, Point move)
     : base(entityLayer)
 {
     this.entities = new List<Entity>(entities);
     this.move = move;
 }
 public EntitySetValueAction(EntityLayer entityLayer, Value value, string setTo)
     : base(entityLayer)
 {
     this.value = value;
     this.setTo = setTo;
 }
Exemple #18
0
 public EntityAction(EntityLayer entityLayer)
 {
     EntityLayer = entityLayer;
 }