Esempio n. 1
0
		public bool LoadData()
		{
			//Load the XML file:
			XmlDocument Doc = new XmlDocument();
			Doc.Load(msTileSetFile);
			
			XmlElement DocRoot = (XmlElement)Doc.FirstChild;
			
			msDirectory = Path.GetFullPath(DocRoot.GetAttribute("dir")).Trim();
			mlTileSize = Convert.ToInt32(DocRoot.GetAttribute("size"));
			
			if(msDirectory.EndsWith("\\")==false && msDirectory.EndsWith("/")==false)
			{
				msDirectory+="/";
			}
			
			//Iterate trough all tiles:
			for(int i=0;i< DocRoot.ChildNodes.Count;i++)
			{
				XmlElement TNode = (XmlElement)DocRoot.ChildNodes[i];
				
				cTileData TData = new cTileData(TNode.GetAttribute("name"),
												msDirectory + TNode.GetAttribute("name"),
												TNode.GetAttribute("material"),
												TNode.GetAttribute("mesh"));
				TData.LoadData();

				mlstTileData.Add(TData);
			}
			return true;
		}
Esempio n. 2
0
        public bool LoadData()
        {
            //Load the XML file:
            XmlDocument Doc = new XmlDocument();

            Doc.Load(msTileSetFile);

            XmlElement DocRoot = (XmlElement)Doc.FirstChild;

            msDirectory = Path.GetFullPath(DocRoot.GetAttribute("dir")).Trim();
            mlTileSize  = Convert.ToInt32(DocRoot.GetAttribute("size"));

            if (msDirectory.EndsWith("\\") == false && msDirectory.EndsWith("/") == false)
            {
                msDirectory += "/";
            }

            //Iterate trough all tiles:
            for (int i = 0; i < DocRoot.ChildNodes.Count; i++)
            {
                XmlElement TNode = (XmlElement)DocRoot.ChildNodes[i];

                cTileData TData = new cTileData(TNode.GetAttribute("name"),
                                                msDirectory + TNode.GetAttribute("name"),
                                                TNode.GetAttribute("material"),
                                                TNode.GetAttribute("mesh"));
                TData.LoadData();

                mlstTileData.Add(TData);
            }
            return(true);
        }
        public void DrawMini(Graphics aGfx, int alX, int alY, int alW, int alH)
        {
            if (mTileSetForm.objSetList.Items.Count < 1)
            {
                return;
            }

            for (int x = alX; x < alW; x++)
            {
                for (int y = alY; y < alH; y++)
                {
                    if (x < 0 || x >= mlWidth || y < 0 || y >= mlHeight)
                    {
                        continue;
                    }

                    cTile T    = mvTiles[x + y * mlWidth];
                    int   lSet = T.mlSet;
                    int   lNum = T.mlNum;

                    if (lSet < 0 || lNum < 0)
                    {
                        continue;
                    }

                    if (lSet >= mTileSetForm.mlstTileSets.Count)
                    {
                        continue;
                    }
                    cTileSet TSetData = (cTileSet)mTileSetForm.mlstTileSets[lSet];

                    if (lNum >= TSetData.mlstTileData.Count)
                    {
                        continue;
                    }
                    cTileData TData = (cTileData)TSetData.mlstTileData[lNum];

                    TData.DrawMini(aGfx, (x - alX) * 2, (y - alY) * 2, T.mlRotation);
                }
            }
        }
        private void UpdateTileInfo()
        {
            objBigTilePanel.Refresh();

            if (objSetList.Items.Count < 0 || mlSelectedTileSet < 0 || mlSelectedTile < 0)
            {
                objLabelName.Text     = "Name: ";
                objLabelMaterial.Text = "Material: ";
                objLabelMesh.Text     = "Mesh: ";
                objLabelSize.Text     = "Size: ";
            }
            else
            {
                int       lIndex   = mlSelectedTileSet;
                cTileSet  TSetData = (cTileSet)mlstTileSets[lIndex];
                cTileData TData    = (cTileData)TSetData.mlstTileData[mlSelectedTile];
                objLabelName.Text     = "Name: " + TData.msName;
                objLabelMaterial.Text = "Material: " + TData.msMaterialType;
                objLabelMesh.Text     = "Mesh: " + TData.msMeshType;
                objLabelSize.Text     = "Size: " + TData.mTileImage.Width + "x" + TData.mTileImage.Height;
            }
        }
        private void objBigTilePanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            if (objSetList.Items.Count < 1)
            {
                return;
            }
            int lIndex = mlSelectedTileSet;

            if (lIndex < 0)
            {
                return;
            }
            if (mlSelectedTile < 0)
            {
                return;
            }

            cTileSet  TSetData = (cTileSet)mlstTileSets[lIndex];
            cTileData TData    = (cTileData)TSetData.mlstTileData[mlSelectedTile];

            e.Graphics.DrawImage(TData.mTileImage,
                                 0, 0,
                                 objBigTilePanel.Width, objBigTilePanel.Height);
        }
        public void Draw(Graphics aGfx, int alX, int alY, int alW, int alH, bool abGrid)
        {
            if (mTileSetForm.objSetList.Items.Count < 1)
            {
                return;
            }


            alW = alW / mlTileSize + 2;
            alH = alH / mlTileSize + 2;

            int lTileX = alX / mlTileSize;
            int lTileY = alY / mlTileSize;

            if (lTileX + alW > mlWidth)
            {
                alW = mlWidth - lTileX;
            }
            if (lTileY + alH > mlHeight)
            {
                alH = mlHeight - lTileY;
            }

            for (int x = 0; x < alW; x++)
            {
                for (int y = 0; y < alH; y++)
                {
                    cTile T    = mvTiles[(lTileY + y) * mlWidth + (lTileX + x)];
                    int   lSet = T.mlSet;
                    int   lNum = T.mlNum;

                    if (lSet < 0 || lNum < 0)
                    {
                        continue;
                    }

                    if (lSet >= mTileSetForm.mlstTileSets.Count)
                    {
                        continue;
                    }
                    cTileSet TSetData = (cTileSet)mTileSetForm.mlstTileSets[lSet];

                    if (lNum >= TSetData.mlstTileData.Count)
                    {
                        continue;
                    }
                    cTileData TData = (cTileData)TSetData.mlstTileData[lNum];

                    TData.Draw(aGfx, (lTileX + x) * mlTileSize - alX, (lTileY + y) * mlTileSize - alY,
                               abGrid, false, T.mlRotation);

                    if (T.mbBreakable)
                    {
                        Font       BreakFont = new Font("Arial", 10);
                        SolidBrush BreakPen  = new SolidBrush(Color.White);

                        aGfx.DrawString("B", BreakFont, BreakPen, (mlTileSize / 2 - 5) + (lTileX + x) * mlTileSize - alX,
                                        (mlTileSize / 2 - 5) + (lTileY + y) * mlTileSize - alY);

                        BreakFont.Dispose();
                        BreakPen.Dispose();
                    }

                    /*aGfx.DrawRectangle(new Pen(Color.White),x*mlTileSize,y*mlTileSize,
                     *                                      mlTileSize, mlTileSize);*/
                }
            }
        }