Exemplo n.º 1
0
        private void drawItem(String path, int ID)
        {
            Bitmap bm = new Bitmap(Path.Combine(Application.StartupPath, path));

            if (ID == (int)EnumID.Brick_ID || ID == (int)EnumID.StairUpLeft_ID || ID == (int)EnumID.StairUpRight_ID || ID == (int)EnumID.Door_ID)
            {
                currentMouse = new Point((currentMouse.X / 32) * 32, (currentMouse.Y / 32) * 32);
            }
            DrawImage(pictureBox1.Image, bm, currentMouse, new Rectangle(0, 0, bm.Width, bm.Height));
            pictureBox1.Refresh();
            ObjectGame obj = new ObjectGame(bm, ID);

            obj.SetLocation(currentMouse.X, currentMouse.Y);
            addObject(obj);
        }
Exemplo n.º 2
0
        private void decodeObj(string readObj)
        {
            int currentIndex = 0;
            int numOfObj     = int.Parse(readObj.Substring(currentIndex, readObj.IndexOf("\r\n\r\n", currentIndex) - currentIndex));

            currentIndex = readObj.IndexOf("\r\n\r\n", currentIndex) + 4;
            for (int i = 0; i < numOfObj; i++)
            {
                int id = int.Parse(readObj.Substring(currentIndex, readObj.IndexOf("\r\n", currentIndex) - currentIndex));
                currentIndex = readObj.IndexOf("\r\n", currentIndex) + 2;
                int x = int.Parse(readObj.Substring(currentIndex, readObj.IndexOf("\r\n", currentIndex) - currentIndex));
                currentIndex = readObj.IndexOf("\r\n", currentIndex) + 2;
                int        y   = int.Parse(readObj.Substring(currentIndex, readObj.IndexOf("\r\n", currentIndex) - currentIndex));
                ObjectGame obj = new ObjectGame(getImage(id), id);
                obj.SetLocation(x, y);
                listobjmap.Add(obj);
                currentIndex = readObj.IndexOf("\r\n\r\n", currentIndex) + 4;
            }
        }