Beispiel #1
0
        public void DD2DeleteMTXM(CDD2 cDD2)
        {
            DoodadPallet pallete = UseMapEditor.Global.WindowTool.MapViewer.tileSet.DoodadPallets[TILETYPE][cDD2.ID];

            int _x = cDD2.X / 32 - (pallete.dddWidth / 2);
            int _y = cDD2.Y / 32 - (pallete.dddHeight / 2);


            for (int y = 0; y < pallete.dddHeight; y++)
            {
                for (int x = 0; x < pallete.dddWidth; x++)
                {
                    ushort group = (ushort)(pallete.dddGroup + y);
                    ushort index = (ushort)x;


                    if (UseMapEditor.Global.WindowTool.MapViewer.tileSet.IsBlack(TILETYPE, group, index))
                    {
                        continue;
                    }

                    MTXM[_x + x + (_y + y) * WIDTH] = TILE[_x + x + (_y + y) * WIDTH];
                }
            }
        }
Beispiel #2
0
        public DoodadEvent(MapEditor mapEditor, CDD2 cDD2, bool IsCreate)
        {
            this.mapEditor = mapEditor;
            this.cDD2      = cDD2;

            this.IsCreate  = IsCreate;
            IsCreateAction = true;
        }
Beispiel #3
0
        private void GetCHKAll(BinaryWriter bw)
        {
            LoadString();

            DDDTHG2.Clear();
            MTXM = (ushort[])TILE.Clone();
            //Doodad풀기
            for (int i = 0; i < DD2.Count; i++)
            {
                CDD2 cDD2 = DD2[i];

                DoodadPallet pallete = UseMapEditor.Global.WindowTool.MapViewer.tileSet.DoodadPallets[TILETYPE][cDD2.ID];
                DD2ToMTXM(cDD2);

                CTHG2 cTHG2 = new CTHG2();
                cTHG2.FLAG = pallete.dddFlags;
                cTHG2.X    = cDD2.X;
                cTHG2.Y    = cDD2.Y;
                cTHG2.ID   = pallete.dddOverlayID;

                if (((cTHG2.FLAG & (0b1 << 12)) != 0) | ((cTHG2.FLAG & (0b1 << 13)) != 0))
                {
                    DDDTHG2.Add(cTHG2);
                }
            }



            TriggerSave();



            //에디터로부터 CHK데이터를 가져오는 함수
            for (int i = 0; i < cHKTokens.Count; i++)
            {
                if (cHKTokens[i].tokentype == TOKENTYPE.NULL)
                {
                    GetCHK(bw, cHKTokens[i], TOKENTYPE.NULL);
                }
            }


            foreach (TOKENTYPE cHKTYPE in Enum.GetValues(typeof(TOKENTYPE)))
            {
                if (cHKTYPE != TOKENTYPE.NULL)
                {
                    GetCHK(bw, new CHKToken(), cHKTYPE);
                }
            }
        }
Beispiel #4
0
        private bool DoodadCollsionCheck(Vector2 pos, DoodadPallet paldoodad)
        {
            if (mapeditor.mapDataBinding.DOODAD_STACKALLOW)
            {
                return(true);
            }

            int x = (ushort)pos.X / 32 * 32 - (paldoodad.dddWidth / 2) * 32;
            int y = (ushort)pos.Y / 32 * 32 - (paldoodad.dddHeight / 2) * 32;

            Rect rect = new Rect(new Point(x, y), new Point(x + paldoodad.dddWidth * 32, y + paldoodad.dddHeight * 32));

            for (int i = 0; i < mapeditor.mapdata.DD2.Count; i++)
            {
                CDD2 mcDD2 = mapeditor.mapdata.DD2[i];

                int          doodadid  = mcDD2.ID;
                var          t         = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];
                DoodadPallet mapdoodad = t[(ushort)doodadid];

                int tx = (ushort)mcDD2.X / 32 * 32 - (mapdoodad.dddWidth / 2) * 32;
                int ty = (ushort)mcDD2.Y / 32 * 32 - (mapdoodad.dddHeight / 2) * 32;


                Rect _rect = new Rect(new Point(tx, ty), new Point(tx + mapdoodad.dddWidth * 32, ty + mapdoodad.dddHeight * 32));

                Rect interRect = Rect.Intersect(rect, _rect);
                if (interRect != Rect.Empty)
                {
                    //if (tileSet.IsBlack(mapeditor.mapdata.TILETYPE, group, index))
                    //{
                    //    continue;
                    //}
                    //충돌상황
                    //하나하나 비교시작
                    for (int iy = 0; iy < (int)(interRect.Height / 32); iy++)
                    {
                        for (int ix = 0; ix < (int)(interRect.Width / 32); ix++)
                        {
                            int mx = (int)(interRect.X - tx) / 32;
                            int my = (int)(interRect.Y - ty) / 32;
                            int px = (int)(interRect.X - x) / 32;
                            int py = (int)(interRect.Y - y) / 32;


                            ushort mg = (ushort)(mapdoodad.dddGroup + my + iy);
                            ushort mi = (ushort)(mx + ix);
                            ushort pg = (ushort)(paldoodad.dddGroup + py + iy);
                            ushort pi = (ushort)(px + ix);



                            if (!tileSet.IsBlack(mapeditor.mapdata.TILETYPE, mg, mi) & !tileSet.IsBlack(mapeditor.mapdata.TILETYPE, pg, pi))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }



            return(true);
        }
Beispiel #5
0
        private void DoodadPalleteDraw()
        {
            if (mapeditor.mapDataBinding.DOODAD_SELECTMODE)
            {
                return;
            }

            if (mouse_LeftDown)
            {
                if (mapeditor.doodad_PasteMode)
                {
                    int gridsize = 32;

                    Vector2 mappos = MouseMapPos;

                    //생성모드
                    if ((LastCreatePos - mappos).Length() >= Math.Max(gridsize, 4))
                    {
                        LastCreatePos = mappos;

                        for (int i = 0; i < mapeditor.CopyedDoodad.Count; i++)
                        {
                            mappos = MouseMapPos;

                            mappos.X = (float)(Math.Round(mappos.X / 32) * 32);
                            mappos.Y = (float)(Math.Round(mappos.Y / 32) * 32);


                            int          doodadid = mapeditor.CopyedDoodad[i].ID;
                            var          t        = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];
                            DoodadPallet pallete  = t[(ushort)doodadid];


                            CDD2 _cDD2 = mapeditor.CopyedDoodad[i];

                            //if (pallete.dddHeight % 2 == 1)
                            //{
                            //    mappos.Y -= 16;
                            //}

                            mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                            mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                            mappos.X = (float)Math.Floor(mappos.X);
                            mappos.Y = (float)Math.Floor(mappos.Y);


                            mappos.X += (float)_cDD2.X;
                            mappos.Y += (float)_cDD2.Y;



                            if (DoodadCollsionCheck(mappos, pallete))
                            {
                                LastCreatePos = mappos;

                                CDD2 cDD2 = new CDD2(mapeditor.mapdata);
                                cDD2.X      = (ushort)mappos.X;
                                cDD2.Y      = (ushort)mappos.Y;
                                cDD2.ID     = (ushort)doodadid;
                                cDD2.PLAYER = (byte)_cDD2.PLAYER;

                                mapeditor.mapdata.DD2.Add(cDD2);
                                cDD2.ImageReset();

                                mapeditor.mapdata.DD2ToMTXM(cDD2);
                                mapeditor.taskManager.TaskAdd(new DoodadEvent(mapeditor, cDD2, true));
                            }
                        }
                    }
                }
                else
                {
                    int gridsize = 32;
                    int doodadid = mapeditor.doodad_index;
                    var t        = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];

                    if (!t.ContainsKey((ushort)doodadid))
                    {
                        return;
                    }

                    DoodadPallet pallete = t[(ushort)doodadid];


                    int playerid = 12;
                    if (doodadid == -1)
                    {
                        return;
                    }


                    Vector2 mappos = MouseMapPos;


                    mappos.X = (float)(Math.Round(mappos.X / 32) * 32);
                    mappos.Y = (float)(Math.Round(mappos.Y / 32) * 32);
                    if (pallete.dddHeight % 2 == 1)
                    {
                        mappos.Y -= 16;
                    }



                    mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                    mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                    mappos.X = (float)Math.Floor(mappos.X);
                    mappos.Y = (float)Math.Floor(mappos.Y);


                    //생성모드
                    if ((LastCreatePos - mappos).Length() >= Math.Max(gridsize, 4))
                    {
                        if (DoodadCollsionCheck(mappos, pallete))
                        {
                            LastCreatePos = mappos;

                            CDD2 cDD2 = new CDD2(mapeditor.mapdata);
                            cDD2.X      = (ushort)mappos.X;
                            cDD2.Y      = (ushort)mappos.Y;
                            cDD2.ID     = (ushort)doodadid;
                            cDD2.PLAYER = (byte)playerid;

                            mapeditor.mapdata.DD2.Add(cDD2);
                            cDD2.ImageReset();

                            mapeditor.mapdata.DD2ToMTXM(cDD2);
                            mapeditor.taskManager.TaskAdd(new DoodadEvent(mapeditor, cDD2, true));
                        }
                    }
                }
            }
        }
Beispiel #6
0
        private bool Applychk(BinaryReader br)
        {
            CHKToken cHKToken = GetNextCHK(br);

            br.BaseStream.Position = cHKToken.start;



            //Byte로부터 에디터로 넣는 함수
            switch (cHKToken.tokentype)
            {
            case TOKENTYPE.ENCD:
                SetEncoding(br.ReadInt32());

                break;

            case TOKENTYPE.IOWN:
                IOWN = br.ReadBytes(12);

                break;

            case TOKENTYPE.OWNR:
                //넘기기
                OWNR = br.ReadBytes(12);

                break;

            case TOKENTYPE.SIDE:
                SIDE = br.ReadBytes(12);

                break;

            case TOKENTYPE.ERA:
                ushort tile = br.ReadUInt16();
                if (tile > 7)
                {
                    throw new Exception("");
                }
                TILETYPE = (TileType)tile;


                break;

            case TOKENTYPE.COLR:
                COLR = br.ReadBytes(8);
                for (int i = 0; i < 8; i++)
                {
                    if (COLR[i] >= ColorName.Count())
                    {
                        COLR[i] = 0;
                    }


                    CRGB[i] = new Microsoft.Xna.Framework.Color(0, 0, COLR[i]);
                }


                break;

            case TOKENTYPE.CRGB:
                for (int i = 0; i < 8; i++)
                {
                    byte[] colors = br.ReadBytes(3);
                    CRGB[i] = new Microsoft.Xna.Framework.Color(colors[0], colors[1], colors[2]);
                }
                CRGBIND = br.ReadBytes(8);

                break;

            case TOKENTYPE.UNIT:
                UNIT.Clear();
                for (int i = 0; i < cHKToken.size / 36; i++)
                {
                    CUNIT cUNIT = new CUNIT(br);
                    cUNIT.SetMapEditor(mapEditor);
                    UNIT.Add(cUNIT);
                }

                break;

            case TOKENTYPE.DIM:
                WIDTH  = br.ReadUInt16();
                HEIGHT = br.ReadUInt16();
                break;

            case TOKENTYPE.TILE:
                TILE = new ushort[cHKToken.size / 2];
                for (int i = 0; i < cHKToken.size / 2; i++)
                {
                    TILE[i] = br.ReadUInt16();
                }

                break;

            case TOKENTYPE.MTXM:
                MTXM = new ushort[cHKToken.size / 2];
                for (int i = 0; i < cHKToken.size / 2; i++)
                {
                    MTXM[i] = br.ReadUInt16();
                }

                break;

            case TOKENTYPE.DD2:
                for (int i = 0; i < cHKToken.size / 8; i++)
                {
                    CDD2 cDD2 = new CDD2(br, this);

                    DD2.Add(cDD2);
                }
                break;

            case TOKENTYPE.THG2:
                for (int i = 0; i < cHKToken.size / 10; i++)
                {
                    CTHG2 cTHG2 = new CTHG2(br);

                    THG2.Add(cTHG2);
                }

                break;

            case TOKENTYPE.MASK:
                MASK = br.ReadBytes((int)cHKToken.size);

                break;

            case TOKENTYPE.STR:
            {
                long startpoint = br.BaseStream.Position;

                LOADSTR = new string[br.ReadUInt16()];
                BYTESTR = new List <byte[]>();

                ushort[] ptrs = new ushort[LOADSTR.Length];
                for (int i = 0; i < ptrs.Length; i++)
                {
                    ptrs[i] = br.ReadUInt16();
                }


                for (int i = 0; i < ptrs.Length; i++)
                {
                    br.BaseStream.Position = startpoint + ptrs[i];

                    List <byte> strs     = new List <byte>();
                    byte        readbyte = br.ReadByte();


                    if (readbyte != 0)
                    {
                        strs.Add(readbyte);
                        while (true)
                        {
                            readbyte = br.ReadByte();
                            if (readbyte == 0)
                            {
                                break;
                            }
                            strs.Add(readbyte);
                        }
                    }


                    BYTESTR.Add(strs.ToArray());

                    //LOADSTR[i] = System.Text.Encoding.GetEncoding(949).GetString(strs.ToArray());
                }
            }
            break;

            case TOKENTYPE.STRx:
            {
                long startpoint = br.BaseStream.Position;

                LOADSTRx = new string[br.ReadUInt32()];
                BYTESTRx = new List <byte[]>();

                uint[] ptrs = new uint[LOADSTRx.Length];
                for (int i = 0; i < ptrs.Length; i++)
                {
                    ptrs[i] = br.ReadUInt32();
                }


                for (int i = 0; i < ptrs.Length; i++)
                {
                    br.BaseStream.Position = startpoint + ptrs[i];

                    List <byte> strs     = new List <byte>();
                    byte        readbyte = br.ReadByte();

                    if (readbyte != 0)
                    {
                        strs.Add(readbyte);
                        while (true)
                        {
                            readbyte = br.ReadByte();
                            if (readbyte == 0)
                            {
                                break;
                            }
                            strs.Add(readbyte);
                        }
                    }


                    BYTESTRx.Add(strs.ToArray());

                    //LOADSTRx[i] = System.Text.Encoding.UTF8.GetString(strs.ToArray());
                }
            }
            break;

            case TOKENTYPE.SPRP:
                SCEARIONAME = new StringData(this, br.ReadUInt16());
                SCEARIODES  = new StringData(this, br.ReadUInt16());


                break;

            case TOKENTYPE.FORC:
                FORCE = br.ReadBytes(8);

                FORCENAME    = new StringData[4];
                FORCENAME[0] = new StringData(this, br.ReadUInt16());
                FORCENAME[1] = new StringData(this, br.ReadUInt16());
                FORCENAME[2] = new StringData(this, br.ReadUInt16());
                FORCENAME[3] = new StringData(this, br.ReadUInt16());

                FORCEFLAG = br.ReadBytes(4);
                break;

            case TOKENTYPE.MRGN:
                LocationDatas.Clear();
                LocationDatas.Add(new LocationData(mapEditor));
                for (int i = 0; i < 255; i++)
                {
                    LocationData locationData = new LocationData(mapEditor);

                    locationData.INDEX = i + 1;

                    locationData.L      = br.ReadUInt32();
                    locationData.T      = br.ReadUInt32();
                    locationData.R      = br.ReadUInt32();
                    locationData.B      = br.ReadUInt32();
                    locationData.STRING = new StringData(this, br.ReadUInt16());
                    locationData.FLAG   = br.ReadUInt16();

                    if (locationData.L == 0 & locationData.T == 0 & locationData.L == 0 & locationData.T == 0 &
                        locationData.STRING.LoadedIndex == -1 & locationData.FLAG == 0)
                    {
                        continue;
                    }


                    LocationDatas.Add(locationData);
                }
                //u32: Left(X1) coordinate of location, in pixels(usually 32 pt grid aligned)
                //u32: Top(Y1) coordinate of location, in pixels
                //u32: Right(X2) coordinate of location, in pixels
                //u32: Bottom(Y2) coordinate of location, in pixels
                //u16: String number of the name of this location
                //u16: Location elevation flags.If an elevation is disabled in the location, it's bit will be on (1)
                //Bit 0 - Low elevation
                //Bit 1 - Medium elevation
                //Bit 2 - High elevation
                //Bit 3 - Low air
                //Bit 4 - Medium air
                //Bit 5 - High air
                //Bit 6 - 15 - Unused


                break;

            case TOKENTYPE.UPRP:
                UPRP = new CUPRP[64];
                for (int i = 0; i < 64; i++)
                {
                    CUPRP cUPRP = new CUPRP();
                    cUPRP.STATUSVALID = br.ReadUInt16();
                    cUPRP.POINTVALID  = br.ReadUInt16();

                    cUPRP.PLAYER      = br.ReadByte();
                    cUPRP.HITPOINT    = br.ReadByte();
                    cUPRP.SHIELDPOINT = br.ReadByte();
                    cUPRP.ENERGYPOINT = br.ReadByte();


                    cUPRP.RESOURCE   = br.ReadUInt32();
                    cUPRP.HANGAR     = br.ReadUInt16();
                    cUPRP.STATUSFLAG = br.ReadUInt16();
                    cUPRP.UNUSED     = br.ReadUInt32();

                    UPRP[i] = cUPRP;
                }
                break;

            case TOKENTYPE.UPUS:
                UPUS = br.ReadBytes(64);
                break;

            case TOKENTYPE.WAV:
                WAV = new StringData[512];
                for (int i = 0; i < 512; i++)
                {
                    WAV[i] = new StringData(this, br.ReadInt32());
                }
                break;

            case TOKENTYPE.SWNM:
                SWNM = new StringData[256];
                for (int i = 0; i < 256; i++)
                {
                    SWNM[i] = new StringData(this, br.ReadInt32());
                }
                break;

            case TOKENTYPE.PUNI:
                PUNI = new CPUNI();
                for (int i = 0; i < 12; i++)
                {
                    PUNI.UNITENABLED[i] = br.ReadBytes(228);
                }
                PUNI.DEFAULT = br.ReadBytes(228);
                for (int i = 0; i < 12; i++)
                {
                    PUNI.USEDEFAULT[i] = br.ReadBytes(228);
                }

                break;

            case TOKENTYPE.PUPx:
                PUPx = new CPUPx();
                for (int i = 0; i < 12; i++)
                {
                    PUPx.MAXLEVEL[i] = br.ReadBytes(61);
                }
                for (int i = 0; i < 12; i++)
                {
                    PUPx.STARTLEVEL[i] = br.ReadBytes(61);
                }
                PUPx.DEFAULTMAXLEVEL   = br.ReadBytes(61);
                PUPx.DEFAULTSTARTLEVEL = br.ReadBytes(61);
                for (int i = 0; i < 12; i++)
                {
                    PUPx.USEDEFAULT[i] = br.ReadBytes(61);
                }

                break;

            case TOKENTYPE.PTEx:
                PTEx = new CPTEx();
                for (int i = 0; i < 12; i++)
                {
                    PTEx.MAXLEVEL[i] = br.ReadBytes(44);
                }
                for (int i = 0; i < 12; i++)
                {
                    PTEx.STARTLEVEL[i] = br.ReadBytes(44);
                }
                PTEx.DEFAULTMAXLEVEL   = br.ReadBytes(44);
                PTEx.DEFAULTSTARTLEVEL = br.ReadBytes(44);
                for (int i = 0; i < 12; i++)
                {
                    PTEx.USEDEFAULT[i] = br.ReadBytes(44);
                }

                break;

            case TOKENTYPE.UNIx:
                UNIx = new CUNIx();
                for (int i = 0; i < 228; i++)
                {
                    UNIx.USEDEFAULT[i] = br.ReadByte();
                }

                for (int i = 0; i < 228; i++)
                {
                    UNIx.HIT[i] = br.ReadUInt32();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.SHIELD[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.ARMOR[i] = br.ReadByte();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.BUILDTIME[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.MIN[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.GAS[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 228; i++)
                {
                    UNIx.STRING[i] = new StringData(this, br.ReadUInt16());
                }
                for (int i = 0; i < 130; i++)
                {
                    UNIx.DMG[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 130; i++)
                {
                    UNIx.BONUSDMG[i] = br.ReadUInt16();
                }

                break;

            case TOKENTYPE.UPGx:
                UPGx = new CUPGx();
                for (int i = 0; i < 61; i++)
                {
                    UPGx.USEDEFAULT[i] = br.ReadByte();
                }
                br.ReadByte();
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BASEMIN[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BONUSMIN[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BASEGAS[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BONUSGAS[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BASETIME[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 61; i++)
                {
                    UPGx.BONUSTIME[i] = br.ReadUInt16();
                }

                break;

            case TOKENTYPE.TECx:
                TECx = new CTECx();
                for (int i = 0; i < 44; i++)
                {
                    TECx.USEDEFAULT[i] = br.ReadByte();
                }
                for (int i = 0; i < 44; i++)
                {
                    TECx.MIN[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 44; i++)
                {
                    TECx.GAS[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 44; i++)
                {
                    TECx.BASETIME[i] = br.ReadUInt16();
                }
                for (int i = 0; i < 44; i++)
                {
                    TECx.ENERGY[i] = br.ReadUInt16();
                }

                break;

            case TOKENTYPE.TRIG:
                TRIG.Clear();

                for (int i = 0; i < cHKToken.size / 2400; i++)
                {
                    RAWTRIGMBRF trig = new RAWTRIGMBRF(br);

                    TRIG.Add(trig);
                }


                break;

            case TOKENTYPE.MBRF:
                MBRF.Clear();

                for (int i = 0; i < cHKToken.size / 2400; i++)
                {
                    RAWTRIGMBRF mbrf = new RAWTRIGMBRF(br);

                    MBRF.Add(mbrf);
                }


                break;
            }



            for (int i = 0; i < cHKTokens.Count; i++)
            {
                if (cHKTokens[i].code == cHKToken.code)
                {
                    cHKTokens.RemoveAt(i);
                    break;
                }
            }
            cHKTokens.Add(cHKToken);
            br.BaseStream.Position = cHKToken.end;
            return(true);
        }
        private void DrawPalleteCursor()
        {
            //우클릭하면 선택모드로 변경됨

            bool IsDrawSelectRect = false;
            bool IsRetrun         = false;

            switch (mapeditor.PalleteLayer)
            {
            case Control.MapEditor.Layer.Sprite:
                if (mapeditor.mapDataBinding.SPRITE_SELECTMODE)
                {
                    if (mouse_IsDrag)
                    {
                        IsDrawSelectRect = true;
                    }
                    IsRetrun = true;
                }
                break;

            case Control.MapEditor.Layer.Unit:
                if (mapeditor.mapDataBinding.UNIT_SELECTMODE)
                {
                    if (mouse_IsDrag)
                    {
                        IsDrawSelectRect = true;
                    }
                    IsRetrun = true;
                }
                break;

            case Control.MapEditor.Layer.Doodad:
                if (mapeditor.mapDataBinding.DOODAD_SELECTMODE)
                {
                    if (mouse_IsDrag)
                    {
                        IsDrawSelectRect = true;
                    }
                    IsRetrun = true;
                }
                break;
            }
            if (IsDrawSelectRect)
            {
                _spriteBatch.Begin(blendState: BlendState.NonPremultiplied);
                //Q하면 유닛 선택

                Vector2 dragpos = mapeditor.PosMapToScreen(mouse_DragMapStart);

                Vector2 min  = new Vector2(Math.Min(dragpos.X, MousePos.X), Math.Min(dragpos.Y, MousePos.Y));
                Vector2 max  = new Vector2(Math.Max(dragpos.X, MousePos.X), Math.Max(dragpos.Y, MousePos.Y));
                Vector2 size = max - min;

                DrawRect(_spriteBatch, dragpos, MousePos, Color.LimeGreen, 2);
                _spriteBatch.Draw(gridtexture, new Rectangle((int)min.X, (int)min.Y, (int)size.X, (int)size.Y), null, new Color(128, 255, 128, 64), 0, new Vector2(), SpriteEffects.None, 0);
                _spriteBatch.End();
            }
            if (IsRetrun)
            {
                return;
            }



            List <CImage> templist = new List <CImage>();
            int           gridsize = mapeditor.opt_grid;

            switch (mapeditor.PalleteLayer)
            {
            case Control.MapEditor.Layer.Unit:
            {
                if (mapeditor.unit_PasteMode)
                {
                    for (int i = 0; i < mapeditor.CopyedUnit.Count; i++)
                    {
                        CUNIT cUNIT = mapeditor.CopyedUnit[i];
                        if (cUNIT.Images.Count == 0)
                        {
                            cUNIT.ImageReset();
                        }
                        Vector2 mappos  = MouseMapPos;
                        byte    sflag   = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Special Ability Flags", cUNIT.unitID).Data;
                        ushort  bwidth  = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "StarEdit Placement Box Width", cUNIT.unitID).Data;
                        ushort  bheight = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "StarEdit Placement Box Height", cUNIT.unitID).Data;

                        ushort uleft  = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Left", cUNIT.unitID).Data;
                        ushort uup    = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Up", cUNIT.unitID).Data;
                        ushort uright = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Right", cUNIT.unitID).Data + 1);
                        ushort udown  = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Down", cUNIT.unitID).Data + 1);

                        bool IsBuilding = false;
                        if ((sflag & 0x1) > 0)
                        {
                            //건물
                            IsBuilding = true;
                        }
                        if (mapeditor.UnitPalleteGridFix)
                        {
                            //그리드 픽스
                            if (gridsize != 0)
                            {
                                mappos.X = (float)(Math.Round(mappos.X / gridsize) * gridsize);
                                mappos.Y = (float)(Math.Round(mappos.Y / gridsize) * gridsize);
                            }
                        }


                        mappos += new Vector2((short)cUNIT.X, (short)cUNIT.Y);

                        mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                        mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                        mappos.X = (float)Math.Floor(mappos.X);
                        mappos.Y = (float)Math.Floor(mappos.Y);

                        Vector2 mousepos = mapeditor.PosMapToScreen(mappos);

                        DrawUnit(cUNIT, templist, (int)mappos.X, (int)mappos.Y);
                        DrawImageList(templist);
                        if (IsBuilding)
                        {
                            double _w = bwidth * mapeditor.opt_scalepercent;
                            double _h = bheight * mapeditor.opt_scalepercent;
                            _spriteBatch.Begin(blendState: BlendState.NonPremultiplied);
                            _spriteBatch.Draw(gridtexture, new Rectangle((int)(mousepos.X - _w / 2), (int)(mousepos.Y - _h / 2), (int)_w, (int)_h), null, new Color(128, 255, 128, 64), 0, new Vector2(), SpriteEffects.None, 0);
                            _spriteBatch.End();
                        }



                        double _l = uleft * mapeditor.opt_scalepercent;
                        double _u = uup * mapeditor.opt_scalepercent;
                        double _r = uright * mapeditor.opt_scalepercent;
                        double _d = udown * mapeditor.opt_scalepercent;

                        _spriteBatch.Begin();
                        if (UnitCollsionCheck(mappos, cUNIT.unitID, IsBuilding, true))
                        {
                            //유닛 배치 가능
                            DrawRect(_spriteBatch, new Vector2(mousepos.X - (float)_l, mousepos.Y - (float)_u), new Vector2(mousepos.X + (float)_r, mousepos.Y + (float)_d), Color.Lime, 1);
                        }
                        else
                        {
                            DrawRect(_spriteBatch, new Vector2(mousepos.X - (float)_l, mousepos.Y - (float)_u), new Vector2(mousepos.X + (float)_r, mousepos.Y + (float)_d), Color.Red, 1);
                        }
                        _spriteBatch.End();
                        templist.Clear();
                    }
                }
                else
                {
                    int unitid   = (ushort)mapeditor.UnitPallete.SelectIndex;
                    int playerid = (ushort)mapeditor.unit_player;
                    if (unitid == -1)
                    {
                        return;
                    }
                    if (UnitPalleteCursor == null)
                    {
                        UnitPalleteCursor = new CUNIT();
                        //UnitPalleteCursor.stateFlag = 0b1;
                        UnitPalleteCursor.unitID = (ushort)unitid;
                    }

                    if (UnitPalleteCursor.unitID != unitid)
                    {
                        UnitPalleteCursor.unitID = (ushort)unitid;
                        UnitPalleteCursor.ImageReset();
                    }

                    if (UnitPalleteCursor.player != playerid)
                    {
                        UnitPalleteCursor.player = (byte)playerid;
                        UnitPalleteCursor.ImageReset();
                    }

                    if (UnitPalleteCursor.Images.Count == 0)
                    {
                        UnitPalleteCursor.ImageReset();
                    }

                    Vector2 mappos  = MouseMapPos;
                    byte    sflag   = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Special Ability Flags", unitid).Data;
                    ushort  bwidth  = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "StarEdit Placement Box Width", unitid).Data;
                    ushort  bheight = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "StarEdit Placement Box Height", unitid).Data;

                    ushort uleft  = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Left", unitid).Data;
                    ushort uup    = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Up", unitid).Data;
                    ushort uright = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Right", unitid).Data + 1);
                    ushort udown  = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Down", unitid).Data + 1);

                    bool IsBuilding = false;
                    if ((sflag & 0x1) > 0)
                    {
                        //건물
                        IsBuilding = true;
                    }

                    if (mapeditor.UnitPalleteBuildingFix & IsBuilding)
                    {
                        //빌딩 그리드 픽스
                        mappos.X = (float)(Math.Round(mappos.X / 32) * 32);
                        mappos.Y = (float)(Math.Round(mappos.Y / 32) * 32);

                        mappos.X += (bwidth / 2) % 32;
                        mappos.Y += (bheight / 2) % 32;
                    }
                    else if (mapeditor.UnitPalleteGridFix)
                    {
                        //그리드 픽스
                        if (gridsize != 0)
                        {
                            mappos.X = (float)(Math.Round(mappos.X / gridsize) * gridsize);
                            mappos.Y = (float)(Math.Round(mappos.Y / gridsize) * gridsize);
                        }
                    }

                    mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                    mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                    mappos.X = (float)Math.Floor(mappos.X);
                    mappos.Y = (float)Math.Floor(mappos.Y);

                    UnitPalleteCursor.X = (ushort)mappos.X;
                    UnitPalleteCursor.Y = (ushort)mappos.Y;

                    Vector2 mousepos = mapeditor.PosMapToScreen(mappos);

                    DrawUnit(UnitPalleteCursor, templist, AlwaysDraw: true);
                    DrawImageList(templist);
                    if (MousePos.X > screenwidth)
                    {
                        //밖으로 나갔을 경우 미리보기 그리기
                        DrawImageListPreview(templist, new Vector2(screenwidth - 128, 256));
                    }
                    if (IsBuilding)
                    {
                        double _w = bwidth * mapeditor.opt_scalepercent;
                        double _h = bheight * mapeditor.opt_scalepercent;
                        _spriteBatch.Begin(blendState: BlendState.NonPremultiplied);
                        _spriteBatch.Draw(gridtexture, new Rectangle((int)(mousepos.X - _w / 2), (int)(mousepos.Y - _h / 2), (int)_w, (int)_h), null, new Color(128, 255, 128, 64), 0, new Vector2(), SpriteEffects.None, 0);
                        _spriteBatch.End();
                    }



                    double _l = uleft * mapeditor.opt_scalepercent;
                    double _u = uup * mapeditor.opt_scalepercent;
                    double _r = uright * mapeditor.opt_scalepercent;
                    double _d = udown * mapeditor.opt_scalepercent;

                    _spriteBatch.Begin();
                    if (UnitCollsionCheck(mappos, unitid, IsBuilding, true))
                    {
                        //유닛 배치 가능
                        DrawRect(_spriteBatch, new Vector2(mousepos.X - (float)_l, mousepos.Y - (float)_u), new Vector2(mousepos.X + (float)_r, mousepos.Y + (float)_d), Color.Lime, 1);
                    }
                    else
                    {
                        DrawRect(_spriteBatch, new Vector2(mousepos.X - (float)_l, mousepos.Y - (float)_u), new Vector2(mousepos.X + (float)_r, mousepos.Y + (float)_d), Color.Red, 1);
                    }
                    _spriteBatch.End();
                }
            }

            break;

            case Control.MapEditor.Layer.Sprite:
            {
                if (mapeditor.sprite_PasteMode)
                {
                    //복사모드
                    for (int i = 0; i < mapeditor.CopyedSprite.Count; i++)
                    {
                        CTHG2   cTHG2  = mapeditor.CopyedSprite[i];
                        Vector2 mappos = MouseMapPos;
                        if (mapeditor.SpritePalleteGridFix)
                        {
                            //그리드 픽스
                            if (gridsize != 0)
                            {
                                mappos.X = (float)(Math.Round(mappos.X / gridsize) * gridsize);
                                mappos.Y = (float)(Math.Round(mappos.Y / gridsize) * gridsize);
                            }
                        }


                        mappos += new Vector2((short)cTHG2.X, (short)cTHG2.Y);

                        mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                        mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));



                        if (cTHG2.Images.Count == 0)
                        {
                            cTHG2.ImageReset();
                        }

                        for (int c = 0; c < cTHG2.Images.Count; c++)
                        {
                            Vector2 mp = mapeditor.PosMapToScreen(mappos);


                            cTHG2.Images[c].IsHover = true;
                            cTHG2.Images[c].screen  = mp;
                            templist.Add(cTHG2.Images[c]);
                            cTHG2.Images[c].PlayScript();
                        }
                    }

                    DrawImageList(templist);
                }
                else
                {
                    int spriteid;

                    if (mapeditor.sprite_SpritBrush)
                    {
                        spriteid = mapeditor.SpritePallete.SelectIndex;
                    }
                    else
                    {
                        int unitID  = mapeditor.SpritePallete_Unit.SelectIndex;
                        int fligyID = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Graphics", unitID).Data;
                        spriteid = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.flingy, "Sprite", fligyID).Data;
                    }


                    Vector2 mappos = MouseMapPos;
                    mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                    mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                    if (mapeditor.SpritePalleteGridFix)
                    {
                        //그리드 픽스
                        if (gridsize != 0)
                        {
                            mappos.X = (float)(Math.Round(mappos.X / gridsize) * gridsize);
                            mappos.Y = (float)(Math.Round(mappos.Y / gridsize) * gridsize);
                        }
                    }


                    if (SpritePalleteCursor == null)
                    {
                        SpritePalleteCursor = new List <CImage>();
                        SpritePalleteCursor.Add(new CImage(int.MaxValue, SpritePalleteCursor, 0, 0, 0));
                    }

                    if (SpritePalleteCursor.Count != 0)
                    {
                        if (spriteid != -1)
                        {
                            int imageid = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.sprites, "Image File", spriteid).Data;
                            if (SpritePalleteCursor[0].imageID != imageid)
                            {
                                SpritePalleteCursor.Clear();
                                SpritePalleteCursor.Add(new CImage(0, SpritePalleteCursor, imageid, 0, 0, level: 30));
                            }
                        }
                        else
                        {
                            SpritePalleteCursor.Clear();
                        }
                    }
                    else
                    {
                        if (spriteid != -1)
                        {
                            int imageid = (int)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.sprites, "Image File", spriteid).Data;
                            SpritePalleteCursor.Add(new CImage(0, SpritePalleteCursor, imageid, 0, 0, level: 30));
                        }
                        else
                        {
                            SpritePalleteCursor.Clear();
                        }
                    }

                    if (spriteid == -1)
                    {
                        return;
                    }



                    for (int i = 0; i < SpritePalleteCursor.Count; i++)
                    {
                        SpritePalleteCursor[i].color = mapeditor.sprite_player;


                        Vector2 mp = mapeditor.PosMapToScreen(mappos);

                        SpritePalleteCursor[i].screen = mp;
                        templist.Add(SpritePalleteCursor[i]);
                        SpritePalleteCursor[i].PlayScript();
                    }
                    DrawImageList(templist);
                    if (MousePos.X > screenwidth)
                    {
                        //밖으로 나갔을 경우 미리보기 그리기
                        DrawImageListPreview(templist, new Vector2(screenwidth - 128, 256));
                    }
                }
            }
            break;

            case Control.MapEditor.Layer.Doodad:
            {
                if (mapeditor.doodad_PasteMode)
                {
                    for (int i = 0; i < mapeditor.CopyedDoodad.Count; i++)
                    {
                        Vector2 mappos = MouseMapPos;


                        mappos.X = (float)(Math.Round(mappos.X / 32) * 32);
                        mappos.Y = (float)(Math.Round(mappos.Y / 32) * 32);


                        int doodadid = mapeditor.CopyedDoodad[i].ID;
                        var t        = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];


                        CDD2 cDD2 = mapeditor.CopyedDoodad[i];
                        if (cDD2.Images.Count == 0)
                        {
                            cDD2.ImageReset();
                        }


                        Vector2 DoodadPos = mappos + new Vector2(cDD2.X, cDD2.Y);


                        //if (pallete.dddHeight % 2 == 1)
                        //{
                        //    mappos.Y -= 16;
                        //}

                        mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                        mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                        mappos.X = (float)Math.Floor(mappos.X);
                        mappos.Y = (float)Math.Floor(mappos.Y);


                        mappos.X += (float)cDD2.X;
                        mappos.Y += (float)cDD2.Y;


                        cDD2.PalleteX = (ushort)mappos.X;
                        cDD2.PalleteY = (ushort)mappos.Y;



                        //Vector2 mousepos = mapeditor.PosMapToScreen(mappos);

                        _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
                        DrawDooDad(cDD2, templist, IsPallete: true);
                        //_spriteBatch.DrawString(_font, doodadid.ToString(), mousepos, Color.Red);
                        _spriteBatch.End();
                        DrawImageList(templist);
                    }
                }
                else
                {
                    int doodadid = mapeditor.doodad_index;
                    var t        = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];

                    if (!t.ContainsKey((ushort)doodadid))
                    {
                        return;
                    }

                    DoodadPallet pallete = t[(ushort)doodadid];


                    int playerid = 12;
                    if (doodadid == -1)
                    {
                        return;
                    }
                    if (DoodadPalleteCursor == null)
                    {
                        DoodadPalleteCursor        = new CDD2(mapeditor.mapdata);
                        DoodadPalleteCursor.ID     = (ushort)doodadid;
                        DoodadPalleteCursor.PLAYER = (byte)playerid;
                    }

                    if (DoodadPalleteCursor.ID != doodadid)
                    {
                        DoodadPalleteCursor.ID = (ushort)doodadid;
                        DoodadPalleteCursor.ImageReset();
                    }



                    if (DoodadPalleteCursor.Images.Count == 0)
                    {
                        DoodadPalleteCursor.ImageReset();
                    }

                    Vector2 mappos = MouseMapPos;


                    mappos.X = (float)(Math.Round(mappos.X / 32) * 32);
                    mappos.Y = (float)(Math.Round(mappos.Y / 32) * 32);
                    if (pallete.dddHeight % 2 == 1)
                    {
                        mappos.Y -= 16;
                    }



                    mappos = Tools.VectorTool.Max(mappos, new Vector2(0));
                    mappos = Tools.VectorTool.Min(mappos, new Vector2(mapeditor.mapdata.WIDTH * 32, mapeditor.mapdata.HEIGHT * 32));

                    mappos.X = (float)Math.Floor(mappos.X);
                    mappos.Y = (float)Math.Floor(mappos.Y);

                    DoodadPalleteCursor.PalleteX = (ushort)mappos.X;
                    DoodadPalleteCursor.PalleteY = (ushort)mappos.Y;

                    //Vector2 mousepos = mapeditor.PosMapToScreen(mappos);

                    _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
                    DrawDooDad(DoodadPalleteCursor, templist, IsPallete: true);
                    //_spriteBatch.DrawString(_font, doodadid.ToString(), mousepos, Color.Red);
                    _spriteBatch.End();
                    DrawImageList(templist);
                }
            }
            break;
            }
        }
Beispiel #8
0
        private void DrawDooDad(CDD2 cDD2, List <CImage> templist = null, bool IsPallete = false)
        {
            var t = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE];

            if (!t.ContainsKey(cDD2.ID))
            {
                return;
            }

            DoodadPallet pallete = t[cDD2.ID];

            ushort X;
            ushort Y;

            if (IsPallete)
            {
                X = cDD2.PalleteX;
                Y = cDD2.PalleteY;
            }
            else
            {
                X = cDD2.X;
                Y = cDD2.Y;
            }



            bool IsSelect = false;
            bool IsHover  = false;

            if (mapeditor.PalleteLayer == Control.MapEditor.Layer.Doodad)
            {
                if (mapeditor.mapDataBinding.DOODAD_SELECTMODE)
                {
                    if (mouse_IsDrag)
                    {
                        //선택모드
                        Vector2 min = new Vector2(Math.Min(mouse_DragMapStart.X, MouseMapPos.X), Math.Min(mouse_DragMapStart.Y, MouseMapPos.Y));
                        Vector2 max = new Vector2(Math.Max(mouse_DragMapStart.X, MouseMapPos.X), Math.Max(mouse_DragMapStart.Y, MouseMapPos.Y));



                        if (((min.X - 8 < X & X < max.X + 8) & (min.Y - 8 < Y & Y < max.Y + 8)))
                        {
                            hoverDoodad.Add(cDD2);
                        }
                    }
                    if (mapeditor.SelectDoodad.Contains(cDD2))
                    {
                        IsSelect = true;
                    }
                    else if (hoverDoodad.Contains(cDD2))
                    {
                        IsHover = true;
                    }
                }
            }


            int _x = X / 32 * 32 - (pallete.dddWidth / 2) * 32;
            int _y = Y / 32 * 32 - (pallete.dddHeight / 2) * 32;


            Vector2 screen       = mapeditor.PosMapToScreen(new Vector2(_x, _y));
            Vector2 spritescreen = mapeditor.PosMapToScreen(new Vector2(X, Y));



            int grpwidth  = (int)(pallete.dddWidth * 32 * mapeditor.opt_scalepercent);
            int grpheight = (int)(pallete.dddHeight * 32 * mapeditor.opt_scalepercent);


            float mag = (float)(32 * mapeditor.opt_scalepercent);


            float minX = 0 - grpwidth;
            float minY = 0 - grpheight;
            float maxX = screenwidth + grpwidth * 2;
            float maxY = screenheight + grpheight * 2;

            if ((minX < screen.X) & (screen.X < maxX))
            {
                if ((minY < screen.Y) & (screen.Y < maxY))
                {
                    if (cDD2.Images.Count == 0)
                    {
                        cDD2.ImageReset();
                    }
                    for (int i = 0; i < cDD2.Images.Count; i++)
                    {
                        cDD2.Images[i].screen = spritescreen;

                        if (templist != null)
                        {
                            templist.Add(cDD2.Images[i]);
                        }
                        else
                        {
                            ImageList.Add(cDD2.Images[i]);
                        }
                        cDD2.Images[i].PlayScript();
                    }
                    for (int y = 0; y < pallete.dddHeight; y++)
                    {
                        for (int x = 0; x < pallete.dddWidth; x++)
                        {
                            ushort group = (ushort)(pallete.dddGroup + y);
                            ushort index = (ushort)x;


                            if (tileSet.IsBlack(mapeditor.mapdata.TILETYPE, group, index))
                            {
                                continue;
                            }
                            Color color = Color.White;
                            if (mapeditor.view_DoodadColor)
                            {
                                color = mapeditor.DoodadOverlay;
                            }
                            Vector2 StartPoint = screen + new Vector2(x, y) * mag;

                            switch (mapeditor.opt_drawType)
                            {
                            case Control.MapEditor.DrawType.SD:
                            {
                                Texture2D texture2D = tileSet.GetTile(mapeditor.opt_drawType, mapeditor.mapdata.TILETYPE, group, index);
                                _spriteBatch.Draw(texture2D, StartPoint, null, color, 0, Vector2.Zero, (float)mapeditor.opt_scalepercent, SpriteEffects.None, 0);
                            }
                            break;

                            case Control.MapEditor.DrawType.HD:
                            case Control.MapEditor.DrawType.CB:
                            {
                                Texture2D texture2D = tileSet.GetTile(mapeditor.opt_drawType, mapeditor.mapdata.TILETYPE, group, index);
                                _spriteBatch.Draw(texture2D, StartPoint, null, color, 0, Vector2.Zero, (float)mapeditor.opt_scalepercent / 2, SpriteEffects.None, 0);
                            }
                            break;
                            }

                            if (IsSelect)
                            {
                                _spriteBatch.Draw(gridtexture, StartPoint, null, new Color(128, 255, 128, 128), 0, Vector2.Zero, (float)mapeditor.opt_scalepercent * 32, SpriteEffects.None, 0);
                                DrawRect(_spriteBatch, StartPoint, StartPoint + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Yellow, 3);
                            }
                            if (IsHover)
                            {
                                _spriteBatch.Draw(gridtexture, StartPoint, null, new Color(128, 128, 255, 128), 0, Vector2.Zero, (float)mapeditor.opt_scalepercent * 32, SpriteEffects.None, 0);
                                DrawRect(_spriteBatch, StartPoint, StartPoint + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Yellow, 3);
                            }


                            if (IsPallete)
                            {
                                DrawRect(_spriteBatch, StartPoint, StartPoint + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Lime, 3);
                            }
                        }
                    }


                    if (IsPallete)
                    {
                        Vector2      pos = new Vector2(cDD2.PalleteX, cDD2.PalleteY);
                        DoodadPallet paldoodad;

                        paldoodad = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE][cDD2.ID];



                        int x = (ushort)pos.X / 32 * 32 - (paldoodad.dddWidth / 2) * 32;
                        int y = (ushort)pos.Y / 32 * 32 - (paldoodad.dddHeight / 2) * 32;

                        Rect rect = new Rect(new Point(x, y), new Point(x + paldoodad.dddWidth * 32, y + paldoodad.dddHeight * 32));

                        for (int i = 0; i < mapeditor.mapdata.DD2.Count; i++)
                        {
                            CDD2 mcDD2 = mapeditor.mapdata.DD2[i];

                            DoodadPallet mapdoodad = tileSet.DoodadPallets[mapeditor.mapdata.TILETYPE][mcDD2.ID];

                            int tx = (ushort)mcDD2.X / 32 * 32 - (mapdoodad.dddWidth / 2) * 32;
                            int ty = (ushort)mcDD2.Y / 32 * 32 - (mapdoodad.dddHeight / 2) * 32;


                            Rect _rect = new Rect(new Point(tx, ty), new Point(tx + mapdoodad.dddWidth * 32, ty + mapdoodad.dddHeight * 32));

                            Rect interRect = Rect.Intersect(rect, _rect);
                            if (interRect != Rect.Empty)
                            {
                                //if (tileSet.IsBlack(mapeditor.mapdata.TILETYPE, group, index))
                                //{
                                //    continue;
                                //}
                                //충돌상황
                                //하나하나 비교시작
                                for (int iy = 0; iy < (int)(interRect.Height / 32); iy++)
                                {
                                    for (int ix = 0; ix < (int)(interRect.Width / 32); ix++)
                                    {
                                        int mx = (int)(interRect.X - tx) / 32;
                                        int my = (int)(interRect.Y - ty) / 32;
                                        int px = (int)(interRect.X - x) / 32;
                                        int py = (int)(interRect.Y - y) / 32;


                                        ushort mg = (ushort)(mapdoodad.dddGroup + my + iy);
                                        ushort mi = (ushort)(mx + ix);
                                        ushort pg = (ushort)(paldoodad.dddGroup + py + iy);
                                        ushort pi = (ushort)(px + ix);



                                        if (!tileSet.IsBlack(mapeditor.mapdata.TILETYPE, mg, mi) & !tileSet.IsBlack(mapeditor.mapdata.TILETYPE, pg, pi))
                                        {
                                            Vector2 _spos = mapeditor.PosMapToScreen(new Vector2((float)interRect.X + ix * 32, (float)interRect.Y + iy * 32));
                                            DrawRect(_spriteBatch, _spos, _spos + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Red, 3);
                                        }
                                    }
                                }
                            }
                        }



                        //if (DoodadCollsionCheckTile(new Vector2(_mapx + x, _mapy + y)))
                        //{
                        //    DrawRect(_spriteBatch, StartPoint, StartPoint + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Lime, 3);
                        //}
                        //else
                        //{
                        //    DrawRect(_spriteBatch, StartPoint, StartPoint + new Vector2((float)(mapeditor.opt_scalepercent * 32)), Color.Red, 3);
                        //}
                    }
                }
            }
        }