Пример #1
0
 /// <summary>
 /// Remove a layer from the level.
 /// </summary>
 /// <param name="layer">The layer to remove.</param>
 public void RemoveLayer(Layer layer)
 {
     //Remove the layer.
     _Level.RemoveLayer(layer);
 }
Пример #2
0
 /// <summary>
 /// Select a layer.
 /// </summary>
 /// <param name="layer">The layer to select.</param>
 public void Selectlayer(Layer layer)
 {
     //Select the specified layer.
     _SelectedLayer = layer;
 }
Пример #3
0
        /// <summary>
        /// Move a layer and its items upwards in the list.
        /// </summary>
        /// <param name="layer">The layer to move.</param>
        public void MoveLayerUp(Layer layer)
        {
            //Get the layer's index.
            int index = GetLayerIndex(layer);

            //If the item isn't already at the top of the list, move it upwards one step.
            if (index > 0) { _Level.Layers[index] = _Level.Layers[index - 1]; _Level.Layers[index - 1] = layer; }
        }
Пример #4
0
 /// <summary>
 /// Remove an item from a layer.
 /// </summary>
 /// <param name="layer">The source layer.</param>
 /// <param name="item">The item to remove.</param>
 public void RemoveItem(Layer layer, Item item)
 {
     //Remove the item from the specified layer.
     layer.RemoveItem(item);
 }
Пример #5
0
 /// <summary>
 /// Add a box to the game.
 /// </summary>
 /// <param name="layer">The layer that this box will belong to.</param>
 /// <param name="name">The name of the box.</param>
 /// <param name="position">The position of the box.</param>
 /// <param name="rotation">The rotation of the box.</param>
 /// <param name="scale">The scale of the box.</param>
 /// <param name="width">The width of the box.</param>
 /// <param name="height">The height of the box.</param>
 /// <returns>The recently added part.</returns>
 public Box AddBox(Layer layer, string name, Vector2 position, float rotation, Vector2 scale, float width, float height)
 {
     //Add the part to the specified entity and return it.
     return (AddItem(layer, new Box(layer.Level, name, position, rotation, scale, width, height)) as Box);
 }
Пример #6
0
        /// <summary>
        /// Move a layer and all its item downwards in the list.
        /// </summary>
        /// <param name="layer">The layer to move.</param>
        public void MoveLayerDown(Layer layer)
        {
            //Get the layer's index.
            int index = GetLayerIndex(layer);

            //If the item isn't already at the bottom of the list, move it downwards one step.
            if (index < (_Level.Layers.Count - 1)) { _Level.Layers[index] = _Level.Layers[index + 1]; _Level.Layers[index + 1] = layer; }
        }
Пример #7
0
 /// <summary>
 /// Add a layer to the level.
 /// </summary>
 /// <param name="layer">The level to add.</param>
 public Layer AddLayer(Layer layer)
 {
     //Add the layer and return it.
     return Factory.Instance.AddLayer(_Level, layer);
 }
Пример #8
0
 /// <summary>
 /// Get the index of a layer.
 /// </summary>
 /// <param name="layer">The layer in question.</param>
 /// <returns>The index of the layer.</returns>
 public int GetLayerIndex(Layer layer)
 {
     //Return the index of the layer.
     return (_Layers.IndexOf(layer));
 }
Пример #9
0
        /// <summary>
        /// Add a texture item to a layer.
        /// </summary>
        /// <param name="layer">The layer to add the item to.</param>
        /// <param name="spritePath">The name of the item's sprite.</param>
        /// <param name="name">The name of the item.</param>
        /// <param name="position">The position of the item.</param>
        /// <param name="rotation">The rotation of the item.</param>
        /// <param name="scale">The scale of the item.</param>
        public TextureItem AddTextureItem(Layer layer, string spritePath, string name, Vector2 position, float rotation, Vector2 scale)
        {
            //The item.
            TextureItem item = new TextureItem(layer.Level, name, position, rotation, scale);
            item.AddSprite(spritePath);

            //Add the item and return it.
            return (layer.AddItem(item) as TextureItem);
        }
Пример #10
0
 /// <summary>
 /// Get the index of a layer.
 /// </summary>
 /// <param name="layer">The layer in question.</param>
 /// <returns>The index of the layer.</returns>
 private int GetLayerIndex(Layer layer)
 {
     return _Level.GetLayerIndex(layer);
 }
Пример #11
0
 /// <summary>
 /// Add a layer to a level.
 /// </summary>
 /// <param name="level">The level to add the layer to.</param>
 /// <param name="layer">The level to add.</param>
 public Layer AddLayer(Level level, Layer layer)
 {
     //Add the layer and return it.
     return level.AddLayer(layer);
 }
Пример #12
0
 /// <summary>
 /// Add an item to a layer.
 /// </summary>
 /// <param name="layer">The destination layer.</param>
 /// <param name="item">The item to add.</param>
 public Item AddItem(Layer layer, Item item)
 {
     return layer.AddItem(item);
 }
Пример #13
0
        /// <summary>
        /// Add a character to the game.
        /// </summary>
        /// <param name="layer">The layer that this character will belong to.</param>
        /// <param name="name">The name of the character.</param>
        /// <param name="position">The position of the character.</param>
        /// <param name="width">The width of the character.</param>
        /// <param name="height">The height of the character.</param>
        /// <returns>The character.</returns>
        public Character AddCharacter(Layer layer, string name, Vector2 position, float width, float height)
        {
            //Add the character to a layer.
            Character character = new Character(layer.Level, name, position, 0, Vector2.One, width, height);
            layer.AddItem(character);

            //Return the character.
            return character;
        }
Пример #14
0
 /// <summary>
 /// Add an item to a layer.
 /// </summary>
 /// <param name="layer">The destination layer.</param>
 /// <param name="item">The item to add.</param>
 public Item AddItem(Layer layer, Item item)
 {
     return Factory.Instance.AddItem(layer, item);
 }
Пример #15
0
 /// <summary>
 /// Add a texture item to the layer.
 /// </summary>
 /// <param name="layer">The layer to add the item to.</param>
 /// <param name="spriteName">The name of the item's sprite.</param>
 /// <param name="name">The name of the item.</param>
 /// <param name="position">The position of the item.</param>
 /// <param name="rotation">The rotation of the item.</param>
 /// <param name="scale">The scale of the item.</param>
 public TextureItem AddTextureItem(Layer layer, string spriteName, string name, Vector2 position, float rotation, Vector2 scale)
 {
     //Add the item and return it.
     return Factory.Instance.AddTextureItem(layer, spriteName, name, position, rotation, scale);
 }
Пример #16
0
        /// <summary>
        /// Add a layer to the level.
        /// </summary>
        /// <param name="layer">The layer to add.</param>
        public Layer AddLayer(Layer layer)
        {
            //Add the layer and load its content..
            _Layers.Add(layer);
            if (_ContentManager != null) { layer.LoadContent(_ContentManager); }
            LayerChangedInvoke();

            //Hook up to some events.
            GetLastLayer().ItemChanged += OnItemChanged;

            //Return the layer.
            return GetLastLayer();
        }
Пример #17
0
        /// <summary>
        /// Initialize the level editor.
        /// </summary>
        /// <param name="viewport">The window's viewport.</param>
        public void Initialize(Rectangle viewport)
        {
            //Initialize some variables.
            _State = EditorState.Idle;
            _GUI = new GraphicalUserInterface();
            _SelectedItem = null;
            _SelectedLayer = null;
            _Camera = new Camera2D(viewport, new Rectangle(0, 0, 10000, 5000));
            _Level = new Level("Level 1", _Camera);
            _DebugSystem = new DebugSystem(_Level.World);

            //Enable the debug view from start.
            _DebugSystem.Debug(true);

            //Hook up to some of the level's events.
            _Level.LayerChanged += OnLayerChanged;

            //Create the GUI items.
            _TreeView = new TreeView(_GUI, new Vector2(0, 50), 275, 450);
            _PropertyList = new List(_GUI, new Vector2(0, 505), 275, 200);
            _ItemModifier = new ItemModifier(_GUI, new Vector2(viewport.Width - 300, 50), 300, 500);
            _Menu = new Menu(_GUI, new Vector2(0, 0), 500, 30);

            //Add items to the GUI.
            _GUI.AddItem(_TreeView);
            _GUI.AddItem(_PropertyList);
            _GUI.AddItem(_ItemModifier);
            _GUI.AddItem(_Menu);

            //Brushes.
            _SelectionBrush = new LineBrush(1, Color.Gainsboro);

            #region Menu
            //Play with the menu.
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[0].IsScrollable = false;
            _Menu.MenuItems[1].IsScrollable = false;
            _Menu.MenuItems[2].IsScrollable = false;
            _Menu.MenuItems[3].IsScrollable = false;
            _Menu.MenuItems[0].IsFixed = false;
            _Menu.MenuItems[1].IsFixed = false;
            _Menu.MenuItems[2].IsFixed = false;
            _Menu.MenuItems[3].IsFixed = false;
            _Menu.MenuItems[0].Text = "File";
            _Menu.MenuItems[1].Text = "Edit";
            _Menu.MenuItems[2].Text = "View";
            _Menu.MenuItems[3].Text = "Physics";
            _Menu.MenuItems[0][0].Label.Text = "New Level";
            _Menu.MenuItems[0][1].Label.Text = "Open Level";
            _Menu.MenuItems[0][2].Label.Text = "Save Level";
            _Menu.MenuItems[1][0].Label.Text = "Add Item";
            _Menu.MenuItems[1][1].Label.Text = "Add Layer";
            _Menu.MenuItems[1][2].Label.Text = "Delete Layer";
            _Menu.MenuItems[2][0].Label.Text = "Zoom";
            _Menu.MenuItems[2][1].Label.Text = "Scroll";
            _Menu.MenuItems[2][2].Label.Text = "Windows";
            _Menu.MenuItems[3][0].Label.Text = "Play";
            _Menu.MenuItems[3][1].Label.Text = "Pause";
            _Menu.MenuItems[3][2].Label.Text = "Stop";
            #endregion

            //Hook up some events.
            _GUI.ItemClicked += OnGUIClicked;
            _TreeView.Ticked += OnTreeViewNodeTicked;
            _Menu.MenuOptionSelect += OnMenuOptionSelected;

            #region Test
            //Add layers.
            Layer layer1 = AddLayer("Layer 1", new Vector2(.6f, .6f));
            Layer layer2 = AddLayer("Layer 2", new Vector2(.5f, .5f));
            Layer layer3 = AddLayer("Layer 3", new Vector2(.7f, .7f));
            Layer layer4 = AddLayer("Layer 4", new Vector2(.63f, .63f));
            Layer layer5 = AddLayer("Layer 5", Vector2.One);
            Layer layer6 = AddLayer("Layer 6", new Vector2(.99f, 0.99f));
            Layer layer7 = AddLayer("Layer 7", new Vector2(1.5f, 1));

            //Add items.
            AddTextureItem(layer1, @"General/Textures/Hazy_Field[1]", "Background Hazy", new Vector2(0, 50), 0, Vector2.One);
            AddTextureItem(layer1, @"General/Textures/Hazy_Field[2]", "Background Hazy", new Vector2(0, 1000), 0, Vector2.One);
            AddTextureItem(layer1, @"General/Textures/Ruins[1]", "Background Ruins", new Vector2(2000, 50), 0, Vector2.One);
            AddTextureItem(layer2, @"General/Textures/FrozenMetalGroundV1[1]", "Ground", new Vector2(0, 700), 0, Vector2.One);
            AddTextureItem(layer2, @"General/Textures/Backdrop_Guy[1]", "Backdrop Guy", new Vector2(1900, 200), 0, Vector2.One);
            AddTextureItem(layer3, @"General/Textures/Hazy_Field_Tree[1]", "Hazy Field Tree", new Vector2(0, 1200), 0, Vector2.One);
            AddTextureItem(layer4, @"General/Textures/Hazy_Field_Pillar[1]", "Hazy Field Pillar", new Vector2(1200, 1500), 0, Vector2.One);
            AddTextureItem(layer5, @"General/Textures/Fern", "Fern 1", new Vector2(500, 500), 0, Vector2.One);
            AddTextureItem(layer5, @"General/Textures/Rock[1]", "Rock 1", new Vector2(400, 500), 0, Vector2.One);
            AddTextureItem(layer6, @"General/Textures/Fern", "Fern 2", new Vector2(515, 515), 0, Vector2.One);
            AddTextureItem(layer7, @"General/Textures/Pine_Tree", "Pine Tree", new Vector2(600, 0), 0, Vector2.One);
            AddTextureItem(layer7, @"General/Textures/Rock[2]", "Rock 2", new Vector2(300, 550), 0, Vector2.One);

            Box box1 = Factory.Instance.AddBox(layer5, "Ground", @"General/Textures/FrozenMetalGroundV1[1]", new Vector2(800, 700), 937, 32);
            box1.Limbs[0].Body.BodyType = FarseerPhysics.Dynamics.BodyType.Static;

            for (int i = 0; i <= 5; i++)
            {
                Box box2 = Factory.Instance.AddBox(layer5, "Box", @"General/Textures/BlueBoxV1[1]", new Vector2(500 + 50 * i, 50), 26, 27);
                box2.Limbs[0].Body.Restitution = .1f * i;
                //box2.Parts[0].Body.Mass = 1 + 1 * i;
            }
            #endregion
        }
Пример #18
0
 /// <summary>
 /// Remove a layer from the level.
 /// </summary>
 /// <param name="layer">The layer to remove.</param>
 public void RemoveLayer(Layer layer)
 {
     _Layers.Remove(layer);
     LayerChangedInvoke();
 }
Пример #19
0
        /// <summary>
        /// Add a box to the game.
        /// </summary>
        /// <param name="layer">The layer that this box will belong to.</param>
        /// <param name="name">The name of the box.</param>
        /// <param name="spritePath">The name of the sprite to attach to it.</param>
        /// <param name="position">The position of the box.</param>
        /// <param name="width">The width of the box.</param>
        /// <param name="height">The height of the box.</param>
        /// <returns>The recently added part.</returns>
        public Box AddBox(Layer layer, string name, string spritePath, Vector2 position, float width, float height)
        {
            //Add the part to the specified entity and return it.
            Box box = AddBox(layer, name, position, 0, Vector2.One, width, height);
            box.SetSprite(AddSprite(box.Sprites, name, spritePath, new Vector2(width / 2, height / 2)));

            //Return the box.
            return box;
        }