コード例 #1
0
        public override void Excute()
        {
            if (form.TextureList.Items.Count > 0 && form.TextureList.SelectedItem != null)
            {
                LayerStateBeforeRecursion = new TileLayer(currentLayer.TileMapArray);
                foreach (Texture2D text in currentLayer.TexturesList)
                {
                    LayerStateBeforeRecursion.AddTexture(text);
                }

                fillCounter = 5000;
                FillCellIndex((int)form.TileX, (int)form.TileY, -1);
            }
        }
コード例 #2
0
        public override void Excute()
        {
            TileLayer currentLayer = this.form.currentLayer;

                if ((this.form.TileX != null) || (this.form.TileY != null))
                {
                    int TileX = (int)this.form.TileX;
                    int TileY = (int)this.form.TileY;

                    this.TileLocation = new Vector2(TileX, TileY);
                    this.layer = currentLayer;
                    this.PreviousTexture = currentLayer.GetCellIndex(TileX, TileY);

                    int IndexToSet = -1;
                    currentLayer.SetCellIndex(TileX, TileY, IndexToSet);
                }
        }
コード例 #3
0
        public override void Excute()
        {
            TileLayer currentLayer = this.form.currentLayer;
            if(form.TextureList.Items.Count>0 && form.TextureList.SelectedItem!=null){
                if ((this.form.TileX != null) || (this.form.TileY != null))
                {
                    int TileX = (int)this.form.TileX;
                    int TileY = (int)this.form.TileY;

                    this.TileLocation = new Vector2(TileX, TileY);
                    this.layer = currentLayer;
                    this.PreviousTexture = currentLayer.GetCellIndex(TileX, TileY);

                    string TextureToSet = form.TextureList.SelectedItem.ToString();

                    Texture2D text = form.dictTextures[TextureToSet];
                    int IndexToSet = currentLayer.HasTexture(text);
                    currentLayer.SetCellIndex(TileX, TileY, IndexToSet);
                }
            }
        }
コード例 #4
0
 public FillCellErase(Form1 form)
     : base(form)
 {
     this.currentLayer = form.currentLayer;
 }
コード例 #5
0
        public override void Undo()
        {
            string key = "";
            foreach (KeyValuePair<string, TileLayer> KeyVal in form.dictLayer)
            {
                if (KeyVal.Value == currentLayer)
                {
                    key = KeyVal.Key;
                    break;
                }
            }
            form.LayerList.SelectedItem = key;
            TileLayer FoundLayer = form.dictLayer[key];

            currentLayer = FoundLayer;

            FoundLayer.TileMapArray = LayerStateBeforeRecursion.TileMapArray;
        }
コード例 #6
0
        private void quickLoadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog2.InitialDirectory = WorkspacePath;
            openFileDialog2.Filter = "Layer File|*.layer|Map File|*.map|Xml File|*.xml|All Supported Files|*.layer;*.map;*.xml";
            Dictionary<int, string> texturesToLoad;
            string NameOfLayer;

            if (openFileDialog2.ShowDialog() == DialogResult.OK)
            {
                TileLayer layer = TileLayer.ReadInLayer(openFileDialog2.FileName, out texturesToLoad);
                NameOfLayer = layer.LayerName;
                string extensFound = "";

                try
                {
                    foreach (KeyValuePair<int, string> texturespaths in texturesToLoad)
                    {
                        foreach (string ext in Extensions)
                        {
                            if (File.Exists(texPathAddress.Text + "\\" + texturespaths.Value + ext))
                            {
                                extensFound = ext;
                                break;
                            }
                        }

                        FileStream stream = new FileStream(texPathAddress.Text + "\\" + texturespaths.Value + extensFound, FileMode.Open);
                        Texture2D texture = Texture2D.FromStream(GraphicsDevices, stream);
                        layer.AddTexture(texture);
                        stream.Dispose();
                        if (!dictTextures.ContainsKey(texturespaths.Value))
                        {
                            TextureList.Items.Add(texturespaths.Value);
                            dictTextures.Add(texturespaths.Value, texture);
                            Image img = Image.FromFile(texPathAddress.Text + "\\" + texturespaths.Value + extensFound);
                            dictImages.Add(texturespaths.Value, img);
                        }
                    }
                    dictLayer[NameOfLayer] = layer;
                    Map.Addlayer(layer);
                    LayerList.Items.Add(NameOfLayer);
                    currentLayer = layer;
                    LayerList.SelectedIndex = LayerList.Items.Count - 1;
                    activateControls();
                }
                catch (FileNotFoundException ex)
                {
                    MessageBox.Show("Cannot Load Layer File. the texure: " +
                        ex.FileName +
                        " Could not be found in the content folder you have chosen. Content Folder Selector button has been enabled, you have can choose another Directory that has the resource you are trying to load.", "RESOURCE FILE NOT FOUND");
                    btnAddFiles.Enabled = true;
                }
            }
        }
コード例 #7
0
 private void LayerList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (LayerList.SelectedItem != null)
     {
         string CurrentList = LayerList.SelectedItem.ToString();
         currentLayer = dictLayer[CurrentList];
         barAlpha.Value = (int)currentLayer.Alpha * 100;
     }
 }
コード例 #8
0
        private void btnRemoveLayer_Click(object sender, EventArgs e)
        {
            if (LayerList.SelectedItem != null)
            {

                //currentLayer = null;

                Map.RemoveLayer(dictLayer[LayerList.SelectedItem as string]);
                dictLayer.Remove(LayerList.SelectedItem as string);
                LayerList.Items.Remove(LayerList.SelectedItem);

                if (LayerList.Items.Count > 0)
                {
                    currentLayer = dictLayer[LayerList.Items[0].ToString()];
                    LayerList.SetSelected(0, true);
                }
            }
        }
コード例 #9
0
        private void btnAddLayer_Click(object sender, EventArgs e)
        {
            string layerName;
            int layerWidth;
            int layerHeight;
            TileLayer layer;

            LayerForm Form = new LayerForm(LayerList.Items.Count);
            Form.ShowDialog();

            if (Form.OkPressed)
            {
                layerName = Form.txtLayerName.Text;
                layerWidth = int.Parse(Form.txtLayrWidth.Text);
                layerHeight = int.Parse(Form.txtLayHeight.Text);
                layer = new TileLayer(layerWidth, layerHeight);
                dictLayer.Add(layerName, layer);
                LayerList.Items.Add(layerName);
                Map.Addlayer(layer);
                currentLayer = layer;
                foreach (string s in TextureList.Items)
                {
                    currentLayer.AddTexture(dictTextures[s]);
                }
                LayerList.SetSelected(LayerList.Items.Count - 1, true);
            }
        }
コード例 #10
0
 public void RemoveLayer(TileLayer Layer)
 {
     layers.Remove(Layer);
     modifyCollisionMap();
 }
コード例 #11
0
 public void RemoveLayer(TileLayer Layer)
 {
     layers.Remove(Layer);
     modifyCollisionMap();
 }
コード例 #12
0
 /// <summary>
 /// Add Layers
 /// </summary>
 /// <param name="layer"></param>
 public void Addlayer(TileLayer layer)
 {
     layers.Add(layer);
     Camera.MapHeight = MapHeight() * TileLayer.GetTileHeight;
     Camera.MapWidth = MapWidth() * TileLayer.GetTileWidth;
     modifyCollisionMap();
 }
コード例 #13
0
        public static TileLayer ReadInLayer(XmlNode doc, out Dictionary<int, string> textureNames)
        {
            TileLayer layerToReturn = null;
            Dictionary<int, string> dicToReturn = new Dictionary<int,string>();
            float layerAlpha=1.0f;

            XmlNode BaseNode = doc;

            foreach (XmlNode node in BaseNode.ChildNodes)
            {
                if (node.Name == "Textures")
                {
                    foreach (XmlNode textureNode in node.ChildNodes)
                    {
                        dicToReturn.Add(int.Parse(textureNode.Attributes["ID"].Value) , textureNode.Attributes["Name"].Value);
                    }

                }
                else if (node.Name == "Properties")
                {
                    foreach (XmlNode propertyNode in node.ChildNodes)
                    {
                        if (propertyNode.Name == "Alpha")
                        {
                            layerAlpha = float.Parse(propertyNode.Attributes["Value"].Value);
                        }
                    }
                }
                else if (node.Name == "Layer")
                {
                    int width, height;
                    width = int.Parse(node.Attributes["Width"].Value);
                    height = int.Parse(node.Attributes["Height"].Value);

                    layerToReturn = new TileLayer(width, height);
                    int  y = 0;

                    foreach (XmlNode RowNode in node.ChildNodes)
                    {
                        string row = RowNode.InnerText;
                        row.Trim();
                        row.TrimStart(' ');
                        string[] CellsInRow = row.Split(' ');

                        for (int x = 1; x < CellsInRow.Length; x++)
                        {
                            layerToReturn.SetCellIndex(x-1, y, int.Parse(CellsInRow[x]));
                        }
                        y++;
                    }
                }
            } //ForEach Loop Ends Having Read in Everything.
            layerToReturn.Alpha = layerAlpha;
            layerToReturn.LayerName = BaseNode.Attributes["Name"].Value;
            textureNames = dicToReturn;
            return layerToReturn;
        }