Пример #1
0
        public static List <LevelEditorObject> Load_From_XML(string filename)
        {
            List <LevelEditorObject> Res = new List <LevelEditorObject>();
            root MainObject = null;

            MainObject = new root();

            StreamReader  SR   = new StreamReader(filename);
            XmlSerializer xSer = new XmlSerializer(typeof(root));

            MainObject = (root)xSer.Deserialize(SR);
            SR.Close();

            foreach (rootObject obj in MainObject.Object)
            {
                LevelEditorObject le = ObjectGenerator.GetEditorObject(obj.OName);
                if (le != null)
                {
                    le.name         = obj.OName;
                    le.x            = obj.X;
                    le.y            = obj.Y;
                    le.ParamInt[0]  = obj.Int1;
                    le.ParamInt[1]  = obj.Int2;
                    le.ParamInt[2]  = obj.Int3;
                    le.Parambool[0] = obj.Bool1;
                    le.Parambool[1] = obj.Bool2;
                    le.Parambool[2] = obj.Bool3;

                    Res.Add(le);
                }
            }

            return(Res);
        }
Пример #2
0
        public LevelEditorObject(LevelEditorObject tmp)
        {
            this.width      = tmp.width;
            this.height     = tmp.height;
            this.ImageIndex = tmp.ImageIndex;
            this.ImageCount = tmp.ImageCount;
            this.OT         = tmp.OT;
            this.x          = tmp.x;
            this.y          = tmp.y;
            this.name       = tmp.name;
            this.ListIndex  = tmp.ListIndex;
            this.ParamTypes = tmp.ParamTypes;

            ParamInt  = new int[3];
            Parambool = new bool[3];
        }
Пример #3
0
        public FormParams(LevelEditorObject le)
        {
            InitializeComponent();

            MainObject = le;
        }
Пример #4
0
        public LevelEditorObject(LevelEditorObject tmp)
        {
            this.width = tmp.width;
            this.height = tmp.height;
            this.ImageIndex = tmp.ImageIndex;
            this.ImageCount = tmp.ImageCount;
            this.OT = tmp.OT;
            this.x = tmp.x;
            this.y = tmp.y;
            this.name = tmp.name;
            this.ListIndex = tmp.ListIndex;
            this.ParamTypes = tmp.ParamTypes;

            ParamInt = new int[3];
            Parambool = new bool[3];
        }
Пример #5
0
 public Bitmap ObjectTypeToImage(LevelEditorObject obj)
 {
     Bitmap tmp = new Bitmap(obj.width, obj.height);
     Graphics xGraph = Graphics.FromImage(tmp);
     Rectangle Src, Dest;
     Dest = new Rectangle(0, 0, obj.width, obj.height);
     Src = new Rectangle(obj.width * obj.ImageIndex, 0, obj.width, obj.height);
     xGraph.DrawImage(ImageGenerator.GetImage(obj.OT), Dest,Src,GraphicsUnit.Pixel);
     xGraph.Dispose();
     return tmp;
 }
Пример #6
0
        private void pictureLevel_MouseDown(object sender, MouseEventArgs e)
        {
            int Divx, Divy, Divyi;

            Divx = (e.X / 16);
            Divy = (e.Y / 16);

            LX = Divx * 16;
            LY = Divy * 16;
            //PutBox(LX, LY, CurrentImageIndex);

            Divyi = (MainImage.Height / 16) - (Divy + 1);

            if (e.Button == MouseButtons.Left)
            {
                LevelEditorObject le = CheckPosition(Divx, Divyi);
                if (le == null)
                {
                    le = new LevelEditorObject((LevelEditorObject)list.Items[CurrentImageIndex].Tag);
                    le.x = Divx;
                    le.y = Divyi;
                    Objects.Add(le);
                }
                else
                {
                    if (le.ParamTypes != null)
                    {
                        FormParams PR = new FormParams(le);
                        PR.ShowDialog();
                        if (PR.Update)
                            le = PR.MainObject;
                        PR.Dispose();
                    }

                }
            }
            if (e.Button == MouseButtons.Right)
            {
                LevelEditorObject le = CheckPosition(Divx, Divyi);
                if (le != null)
                {
                    Objects.Remove(le);
                    pictureLevel.Invalidate();
                }

            }
        }