public UnitData(CUNIT cUNIT) { _X = cUNIT.X; _Y = cUNIT.Y; _unitID = cUNIT.unitID; _player = cUNIT.player; _hpvalid = cUNIT.hpvalid; _hitPoints = cUNIT.hitPoints; _shvalid = cUNIT.shvalid; _shieldPoints = cUNIT.shieldPoints; _envalid = cUNIT.envalid; _energyPoints = cUNIT.energyPoints; _resvalid = cUNIT.resvalid; _resoruceAmount = cUNIT.resoruceAmount; _hangarvalid = cUNIT.hangarvalid; _hangar = cUNIT.hangar; _cloakvalid = cUNIT.cloakvalid; _cloakstate = cUNIT.cloakstate; _burrowvalid = cUNIT.burrowvalid; _burrowstate = cUNIT.burrowstate; _tranvalid = cUNIT.tranvalid; _buildstate = cUNIT.buildstate; _hallvalid = cUNIT.hallvalid; _hallstate = cUNIT.hallstate; _invinvalid = cUNIT.invinvalid; _invincstate = cUNIT.invincstate; }
public void SetData(CUNIT cUNIT) { cUNIT.X = _X; cUNIT.Y = _Y; cUNIT.unitID = _unitID; cUNIT.player = _player; cUNIT.hpvalid = _hpvalid; cUNIT.hitPoints = _hitPoints; cUNIT.shvalid = _shvalid; cUNIT.shieldPoints = _shieldPoints; cUNIT.envalid = _envalid; cUNIT.energyPoints = _energyPoints; cUNIT.resvalid = _resvalid; cUNIT.resoruceAmount = _resoruceAmount; cUNIT.hangarvalid = _hangarvalid; cUNIT.hangar = _hangar; cUNIT.cloakvalid = _cloakvalid; cUNIT.cloakstate = _cloakstate; cUNIT.burrowvalid = _burrowvalid; cUNIT.burrowstate = _burrowstate; cUNIT.tranvalid = _tranvalid; cUNIT.buildstate = _buildstate; cUNIT.hallvalid = _hallvalid; cUNIT.hallstate = _hallstate; cUNIT.invinvalid = _invinvalid; cUNIT.invincstate = _invincstate; }
public UnitEvent(MapEditor mapEditor, CUNIT cUNIT, bool IsCreate) { this.mapEditor = mapEditor; this.cUNIT = cUNIT; this.IsCreate = IsCreate; IsCreateAction = true; }
public UnitPropertyEvent(MapEditor mapEditor, CUNIT cUNIT, UnitData NewCUNIT, UnitData OldCUNIT) { this.mapEditor = mapEditor; this.cUNIT = cUNIT; this.NewCUNIT = NewCUNIT; this.OldCUNIT = OldCUNIT; }
public void UNITListRemove(CUNIT cUNIT) { switch (cUNIT.unitID) { case 106: //커맨드 센터 case 113: //팩토리 case 114: //스타포트 case 116: //사이언스 case 107: //컴셋 case 108: //사일로 case 115: //컨트롤타워 case 117: //커벌트옵스 case 118: //피직스랩 case 120: //머신샵 case 134: //나이더스 카날 uint linkedunit = cUNIT.linkedUnit; CUNIT _cUNIT = UNIT.SingleOrDefault((x) => x.unitclass == linkedunit); if (_cUNIT != null) { _cUNIT.linkFlag = 0; _cUNIT.linkedUnit = 0; _cUNIT.ImageReset(); } break; } UNIT.Remove(cUNIT); mapEditor.MinimapUnitRefresh(); mapEditor.IndexedUnitCancel(); }
private void UnitPlaceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (UnitPlaceList.SelectedIndex == -1) { return; } CUNIT spdata = (CUNIT)UnitPlaceList.SelectedItem; int width = (int)MapViewer.ActualWidth; int height = (int)MapViewer.ActualHeight; int x = (int)spdata.X; int y = (int)spdata.Y; opt_xpos = (int)(x - width / opt_scalepercent / 2); opt_ypos = (int)(y - height / opt_scalepercent / 2); }
public CUNIT(CUNIT cUNIT) { //unitclass = cUNIT.unitclass; X = cUNIT.X; Y = cUNIT.Y; unitID = cUNIT.unitID; //linkFlag = cUNIT.linkFlag; linkFlag = 0; validstatusFlag = cUNIT.validstatusFlag; validunitFlag = cUNIT.validunitFlag; player = cUNIT.player; hitPoints = cUNIT.hitPoints; shieldPoints = cUNIT.shieldPoints; energyPoints = cUNIT.energyPoints; resoruceAmount = cUNIT.resoruceAmount; hangar = cUNIT.hangar; stateFlag = cUNIT.stateFlag; unused = cUNIT.unused; //linkedUnit = cUNIT.linkedUnit; linkedUnit = 0; ImageReset(); }
public void miniUnitUpdate(CUNIT cUNIT) { int w = cUNIT.BoxWidth; int h = cUNIT.BoxHeight; for (int x = -w / 2; x < w / 2; x++) { for (int y = -h / 2; y < h / 2; y++) { int mx = ((cUNIT.X + x) / 32); int my = ((cUNIT.Y + y) / 32); mx = Math.Max(0, mx); my = Math.Max(0, my); mx = Math.Min(255, mx); my = Math.Min(255, my); mapeditor.miniampUnit[mx + my * 256] = mapeditor.mapdata.UnitColor(cUNIT.player); } } }
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); }
public void UNITListAdd(CUNIT cUNIT) { uint c = 1; if (UNIT.Count != 0) { c = UNIT.Last().unitclass + 1; CUNIT _cUNIT = UNIT.SingleOrDefault((x) => x.unitclass == c); while (_cUNIT != null) { _cUNIT = UNIT.SingleOrDefault((x) => x.unitclass == ++c); } } cUNIT.unitclass = c; //링크 유닛 관리. switch (cUNIT.unitID) { case 106: //커맨드 센터 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X + 96) & (x.Y == cUNIT.Y + 16) & ((x.unitID == 107) | (x.unitID == 108))); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; addon.ImageReset(); } } break; case 113: //팩토리 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X + 96) & (x.Y == cUNIT.Y + 16) & (x.unitID == 120)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; addon.ImageReset(); } } break; case 114: //스타포트 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X + 96) & (x.Y == cUNIT.Y + 16) & (x.unitID == 115)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; addon.ImageReset(); } } break; case 116: //사이언스 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X + 96) & (x.Y == cUNIT.Y + 16) & ((x.unitID == 117) | (x.unitID == 118))); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; addon.ImageReset(); } } break; case 107: //컴셋 case 108: //사일로 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X - 96) & (x.Y == cUNIT.Y - 16) & (x.unitID == 106)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; cUNIT.ImageReset(); } } break; case 115: //컨트롤타워 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X - 96) & (x.Y == cUNIT.Y - 16) & (x.unitID == 114)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; cUNIT.ImageReset(); } } break; case 117: //커벌트옵스 case 118: //피직스랩 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X - 96) & (x.Y == cUNIT.Y - 16) & (x.unitID == 116)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; cUNIT.ImageReset(); } } break; case 120: //머신샵 { CUNIT addon = UNIT.SingleOrDefault((x) => (x.X == cUNIT.X - 96) & (x.Y == cUNIT.Y - 16) & (x.unitID == 113)); if (addon != null) { addon.linkFlag = 0b1 << 10; cUNIT.linkFlag = 0b1 << 10; addon.linkedUnit = c; cUNIT.linkedUnit = addon.unitclass; cUNIT.ImageReset(); } } break; case 134: //나이더스 카날 if (UNIT.Count != 0) { CUNIT lastunit = UNIT.SingleOrDefault((x) => (x.linkedUnit == 0) & (x.unitID == 134)); if (lastunit != null) { lastunit.linkFlag = 0b1 << 9; cUNIT.linkFlag = 0b1 << 9; lastunit.linkedUnit = c; cUNIT.linkedUnit = lastunit.unitclass; } } break; } UNIT.Add(cUNIT); mapEditor.MinimapUnitRefresh(); mapEditor.IndexedUnitCancel(); }
private void DrawUnit(CUNIT cUNIT, List <CImage> templist = null, int x = -1, int y = -1, bool AlwaysDraw = false) { int _x = cUNIT.X; int _y = cUNIT.Y; if (x != -1) { _x = x; } if (y != -1) { _y = y; } Vector2 screen = mapeditor.PosMapToScreen(new Vector2(_x, _y)); if (cUNIT.linkFlag != 0 & cUNIT.linkedUnit != 0) { CUNIT c = mapeditor.mapdata.UNIT.SingleOrDefault((tx) => tx.unitclass == cUNIT.linkedUnit); if (c != null) { Vector2 _ = mapeditor.PosMapToScreen(new Vector2(c.X, c.Y)); Lines.Add(new Vector4(screen.X, screen.Y, _.X, _.Y)); } } bool HoverDisenable = false; if (cUNIT.unitID == 214 & !mapeditor.view_Unit_StartLoc) { //스타트로케이션 HoverDisenable = true; } else if (cUNIT.unitID == 101 & !mapeditor.view_Unit_Maprevealer) { //맵리빌러 HoverDisenable = true; } bool IsSelect = false; bool IsHover = false; if (!HoverDisenable) { if (mapeditor.PalleteLayer == Control.MapEditor.Layer.Unit) { if (mapeditor.mapDataBinding.UNIT_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))) { hoverUnit.Add(cUNIT); } } if (mapeditor.SelectUnit.Contains(cUNIT)) { IsSelect = true; } else if (hoverUnit.Contains(cUNIT)) { IsHover = true; } } } } int grpwidth = (int)(cUNIT.BoxWidth * mapeditor.opt_scalepercent); int grpheight = (int)(cUNIT.BoxHeight * mapeditor.opt_scalepercent); float minX = 0 - grpwidth; float minY = 0 - grpheight; float maxX = screenwidth + grpwidth; float maxY = screenheight + grpheight; if (((minX < screen.X) & (screen.X < maxX) & (minY < screen.Y) & (screen.Y < maxY)) | AlwaysDraw) { if (cUNIT.Images.Count == 0) { cUNIT.ImageReset(); } for (int i = 0; i < cUNIT.Images.Count; i++) { cUNIT.Images[i].sortvalue = (int)cUNIT.unitclass; cUNIT.Images[i].IsSelect = false; cUNIT.Images[i].IsHover = false; cUNIT.Images[i].IsUnitRect = false; if (i == 0) { if (IsSelect) { cUNIT.Images[i].IsUnitRect = true; cUNIT.Images[i].IsSelect = true; } else if (IsHover) { cUNIT.Images[i].IsUnitRect = true; cUNIT.Images[i].IsHover = true; } } cUNIT.Images[i].Left = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Left", cUNIT.unitID).Data; cUNIT.Images[i].Up = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Up", cUNIT.unitID).Data; cUNIT.Images[i].Right = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Right", cUNIT.unitID).Data + 1); cUNIT.Images[i].Down = (byte)(Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Down", cUNIT.unitID).Data + 1); cUNIT.Images[i].color = cUNIT.player; cUNIT.Images[i].screen = screen; if (templist != null) { templist.Add(cUNIT.Images[i]); } else { ImageList.Add(cUNIT.Images[i]); } cUNIT.Images[i].PlayScript(); } ////UnitZPos //_spriteBatch.Begin(); //DrawLine(_spriteBatch, new Vector2(screen.X - 20, screen.Y), new Vector2(screen.X + 20, screen.Y), Color.Red); //DrawLine(_spriteBatch, new Vector2(screen.X, screen.Y - 20), new Vector2(screen.X, screen.Y + 20), Color.Red); //_spriteBatch.End(); } }
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; } }
private void UnitEditList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (UnitEditList.SelectedIndex == -1) { return; } unitEditIsLoad = true; CUNIT fspdata = (CUNIT)((ListBoxItem)UnitEditList.SelectedItems[0]).Tag; string selectheaders = "[" + UnitEditList.SelectedItems.Count + "개] " + mapdata.GetCodeName(Codetype.Unit, fspdata.unitID) + " "; ushort _X = fspdata.X; ushort _Y = fspdata.Y; ushort _unitID = fspdata.unitID; byte _player = fspdata.player; bool _hpvalid = fspdata.hpvalid; byte _hitPoints = fspdata.hitPoints; bool _shvalid = fspdata.shvalid; byte _shieldPoints = fspdata.shieldPoints; bool _envalid = fspdata.envalid; byte _energyPoints = fspdata.energyPoints; bool _resvalid = fspdata.resvalid; uint _resoruceAmount = fspdata.resoruceAmount; bool _hangarvalid = fspdata.hangarvalid; ushort _hangar = fspdata.hangar; bool _cloakvalid = fspdata.cloakvalid; bool _cloakstate = fspdata.cloakstate; bool _burrowvalid = fspdata.burrowvalid; bool _burrowstate = fspdata.burrowstate; bool _tranvalid = fspdata.tranvalid; bool _buildstate = fspdata.buildstate; bool _hallvalid = fspdata.hallvalid; bool _hallstate = fspdata.hallstate; bool _invinvalid = fspdata.invinvalid; bool _invincstate = fspdata.invincstate; uEdit_X.Text = _X.ToString(); uEdit_Y.Text = _Y.ToString(); uEdit_unitID.Text = _unitID.ToString(); uEdit_player.SelectedIndex = _player; uEdit_hpvalid.IsChecked = _hpvalid; uEdit_hitPoints.Text = _hitPoints.ToString(); uEdit_shvalid.IsChecked = _shvalid; uEdit_shieldPoints.Text = _shieldPoints.ToString(); uEdit_envalid.IsChecked = _envalid; uEdit_energyPoints.Text = _energyPoints.ToString(); uEdit_resvalid.IsChecked = _resvalid; uEdit_resoruceAmount.Text = _resoruceAmount.ToString(); uEdit_hangarvalid.IsChecked = _hangarvalid; uEdit_hangar.Text = _hangar.ToString(); uEdit_cloakvalid.IsChecked = _cloakvalid; uEdit_cloakstate.IsChecked = _cloakstate; uEdit_burrowvalid.IsChecked = _burrowvalid; uEdit_burrowstate.IsChecked = _burrowstate; uEdit_tranvalid.IsChecked = _tranvalid; uEdit_buildstate.IsChecked = _buildstate; uEdit_hallvalid.IsChecked = _hallvalid; uEdit_hallstate.IsChecked = _hallstate; uEdit_invinvalid.IsChecked = _invinvalid; uEdit_invincstate.IsChecked = _invincstate; for (int i = 1; i < UnitEditList.SelectedItems.Count; i++) { CUNIT spdata = (CUNIT)((ListBoxItem)UnitEditList.SelectedItems[i]).Tag; selectheaders += mapdata.GetCodeName(Codetype.Unit, spdata.unitID) + " "; if (_X != spdata.X) { uEdit_X.Text = ""; } if (_Y != spdata.Y) { uEdit_Y.Text = ""; } if (_unitID != spdata.unitID) { uEdit_unitID.Text = ""; } if (_player != spdata.player) { uEdit_player.SelectedIndex = -1; } if (_hpvalid != spdata.hpvalid) { uEdit_hpvalid.IsChecked = null; } if (_hitPoints != spdata.hitPoints) { uEdit_hitPoints.Text = ""; } if (_shvalid != spdata.shvalid) { uEdit_shvalid.IsChecked = null; } if (_shieldPoints != spdata.shieldPoints) { uEdit_shieldPoints.Text = ""; } if (_envalid != spdata.envalid) { uEdit_envalid.IsChecked = null; } if (_energyPoints != spdata.energyPoints) { uEdit_energyPoints.Text = ""; } if (_resvalid != spdata.resvalid) { uEdit_resvalid.IsChecked = null; } if (_resoruceAmount != spdata.resoruceAmount) { uEdit_resoruceAmount.Text = ""; } if (_hangarvalid != spdata.hangarvalid) { uEdit_hangarvalid.IsChecked = null; } if (_hangar != spdata.hangar) { uEdit_hangar.Text = ""; } if (_cloakvalid != spdata.cloakvalid) { uEdit_cloakvalid.IsChecked = null; } if (_cloakstate != spdata.cloakstate) { uEdit_cloakstate.IsChecked = null; } if (_burrowvalid != spdata.burrowvalid) { uEdit_burrowvalid.IsChecked = null; } if (_burrowstate != spdata.burrowstate) { uEdit_burrowstate.IsChecked = null; } if (_tranvalid != spdata.tranvalid) { uEdit_tranvalid.IsChecked = null; } if (_buildstate != spdata.buildstate) { uEdit_buildstate.IsChecked = null; } if (_hallvalid != spdata.hallvalid) { uEdit_hallvalid.IsChecked = null; } if (_hallstate != spdata.hallstate) { uEdit_hallstate.IsChecked = null; } if (_invinvalid != spdata.invinvalid) { uEdit_invinvalid.IsChecked = null; } if (_invincstate != spdata.invincstate) { uEdit_invincstate.IsChecked = null; } } //ListBoxItem listBoxItem = (ListBoxItem)UnitEditList.SelectedItem; //CUNIT spdata = (CUNIT)listBoxItem.Tag; //UnitName.Text = mapdata.GetCodeName(Codetype.Unit, spdata.unitID); selectheaders = selectheaders.Replace("\n", ""); selectheaders = selectheaders.Replace("\r", ""); //UnitEditPanel.DataContext = spdata; if (selectheaders.Length > 35) { selectheaders = selectheaders.Substring(0, 33) + " ..."; } UnitName.Text = selectheaders; unitEditIsLoad = false; }
private void uEdit_Changed(object sender, RoutedEventArgs e) { if (unitEditIsLoad) { return; } uint tuint; ushort tushort; byte tbyte; uint?_resoruceAmount = null; ushort?_X = null; ushort?_Y = null; ushort?_unitID = null; ushort?_hangar = null; byte?_player = null; byte?_hitPoints = null; byte?_shieldPoints = null; byte?_energyPoints = null; bool?_hpvalid = null; bool?_shvalid = null; bool?_envalid = null; bool?_resvalid = null; bool?_hangarvalid = null; bool?_cloakvalid = null; bool?_cloakstate = null; bool?_burrowvalid = null; bool?_burrowstate = null; bool?_tranvalid = null; bool?_buildstate = null; bool?_hallvalid = null; bool?_hallstate = null; bool?_invinvalid = null; bool?_invincstate = null; if (uint.TryParse(uEdit_resoruceAmount.Text, out tuint)) { _resoruceAmount = tuint; } if (ushort.TryParse(uEdit_X.Text, out tushort)) { _X = tushort; } if (ushort.TryParse(uEdit_Y.Text, out tushort)) { _Y = tushort; } if (ushort.TryParse(uEdit_unitID.Text, out tushort)) { _unitID = tushort; } if (ushort.TryParse(uEdit_hangar.Text, out tushort)) { _hangar = tushort; } if (uEdit_player.SelectedIndex != -1) { _player = (byte)uEdit_player.SelectedIndex; } if (byte.TryParse(uEdit_hitPoints.Text, out tbyte)) { _hitPoints = tbyte; } if (byte.TryParse(uEdit_shieldPoints.Text, out tbyte)) { _shieldPoints = tbyte; } if (byte.TryParse(uEdit_energyPoints.Text, out tbyte)) { _energyPoints = tbyte; } if (uEdit_hpvalid.IsChecked != null) { _hpvalid = uEdit_hpvalid.IsChecked; } if (uEdit_shvalid.IsChecked != null) { _shvalid = uEdit_shvalid.IsChecked; } if (uEdit_envalid.IsChecked != null) { _envalid = uEdit_envalid.IsChecked; } if (uEdit_resvalid.IsChecked != null) { _resvalid = uEdit_resvalid.IsChecked; } if (uEdit_hangarvalid.IsChecked != null) { _hangarvalid = uEdit_hangarvalid.IsChecked; } if (uEdit_cloakvalid.IsChecked != null) { _cloakvalid = uEdit_cloakvalid.IsChecked; } if (uEdit_cloakstate.IsChecked != null) { _cloakstate = uEdit_cloakstate.IsChecked; } if (uEdit_burrowvalid.IsChecked != null) { _burrowvalid = uEdit_burrowvalid.IsChecked; } if (uEdit_burrowstate.IsChecked != null) { _burrowstate = uEdit_burrowstate.IsChecked; } if (uEdit_tranvalid.IsChecked != null) { _tranvalid = uEdit_tranvalid.IsChecked; } if (uEdit_buildstate.IsChecked != null) { _buildstate = uEdit_buildstate.IsChecked; } if (uEdit_hallvalid.IsChecked != null) { _hallvalid = uEdit_hallvalid.IsChecked; } if (uEdit_hallstate.IsChecked != null) { _hallstate = uEdit_hallstate.IsChecked; } if (uEdit_invinvalid.IsChecked != null) { _invinvalid = uEdit_invinvalid.IsChecked; } if (uEdit_invincstate.IsChecked != null) { _invincstate = uEdit_invincstate.IsChecked; } //_hpvalid //_shvalid //_envalid //_resvalid //_hangarvalid //_cloakvalid //_cloakstate //_burrowvalid //_burrowstate //_tranvalid //_buildstate //_hallvalid //_hallstate //_invinvalid //_invincstate foreach (ListBoxItem item in UnitEditList.SelectedItems) { CUNIT spdata = (CUNIT)item.Tag; UnitPropertyEvent.UnitData OLDunitData = new UnitPropertyEvent.UnitData(spdata); if (_X != null) { spdata.X = (ushort)_X; } if (_Y != null) { spdata.Y = (ushort)_Y; } if (_unitID != null) { spdata.unitID = (ushort)_unitID; } if (_hangar != null) { spdata.hangar = (ushort)_hangar; } if (_resoruceAmount != null) { spdata.resoruceAmount = (uint)_resoruceAmount; } if (_player != null) { spdata.player = (byte)_player; } if (_hitPoints != null) { spdata.hitPoints = (byte)_hitPoints; } if (_shieldPoints != null) { spdata.shieldPoints = (byte)_shieldPoints; } if (_energyPoints != null) { spdata.energyPoints = (byte)_energyPoints; } if (_hpvalid != null) { spdata.hpvalid = (bool)_hpvalid; } if (_shvalid != null) { spdata.shvalid = (bool)_shvalid; } if (_envalid != null) { spdata.envalid = (bool)_envalid; } if (_resvalid != null) { spdata.resvalid = (bool)_resvalid; } if (_hangarvalid != null) { spdata.hangarvalid = (bool)_hangarvalid; } if (_cloakvalid != null) { spdata.cloakvalid = (bool)_cloakvalid; } if (_cloakstate != null) { spdata.cloakstate = (bool)_cloakstate; } if (_burrowvalid != null) { spdata.burrowvalid = (bool)_burrowvalid; } if (_burrowstate != null) { spdata.burrowstate = (bool)_burrowstate; } if (_tranvalid != null) { spdata.tranvalid = (bool)_tranvalid; } if (_buildstate != null) { spdata.buildstate = (bool)_buildstate; } if (_hallvalid != null) { spdata.hallvalid = (bool)_hallvalid; } if (_hallstate != null) { spdata.hallstate = (bool)_hallstate; } if (_invinvalid != null) { spdata.invinvalid = (bool)_invinvalid; } if (_invincstate != null) { spdata.invincstate = (bool)_invincstate; } UnitPropertyEvent.UnitData NEWunitData = new UnitPropertyEvent.UnitData(spdata); taskManager.TaskAdd(new UnitPropertyEvent(this, spdata, NEWunitData, OLDunitData)); } if (_player != null) { MinimapUnitRefresh(); } }
private void UnitPalleteDraw() { int gridsize = mapeditor.opt_grid; if (mapeditor.mapDataBinding.UNIT_SELECTMODE) { return; } if (mouse_LeftDown) { if (mapeditor.unit_PasteMode) { Vector2 mappos = MouseMapPos; if ((LastCreatePos - mappos).Length() >= Math.Max(gridsize, 4)) { LastCreatePos = mappos; for (int i = 0; i < mapeditor.CopyedUnit.Count; i++) { mappos = MouseMapPos; CUNIT cUNIT = mapeditor.CopyedUnit[i]; if (cUNIT.Images.Count == 0) { cUNIT.ImageReset(); } byte sflag = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Special Ability Flags", cUNIT.unitID).Data; 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)); //생성모드 if (UnitCollsionCheck(mappos, cUNIT.unitID, IsBuilding, false)) { CUNIT _cUNIT = new CUNIT(cUNIT); _cUNIT.SetMapEditor(mapeditor); _cUNIT.X = (ushort)mappos.X; _cUNIT.Y = (ushort)mappos.Y; mapeditor.mapdata.UNITListAdd(_cUNIT); //mapeditor.mapdata.UNIT.Add(_cUNIT); mapeditor.taskManager.TaskAdd(new UnitEvent(mapeditor, _cUNIT, true)); } } } } else { int unitid = (ushort)mapeditor.UnitPallete.SelectIndex; int playerid = (ushort)mapeditor.unit_player; Vector2 mappos = mapeditor.PosScreenToMap(MousePos); 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; if (mapeditor.UnitPalleteGridFix) { //그리드 픽스 if (gridsize != 0) { mappos.X = (float)(Math.Round(mappos.X / gridsize) * gridsize); mappos.Y = (float)(Math.Round(mappos.Y / gridsize) * gridsize); } } 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); //생성모드 if ((LastCreatePos - mappos).Length() >= Math.Max(gridsize, 4)) { if (UnitCollsionCheck(mappos, unitid, IsBuilding, false)) { LastCreatePos = mappos; CUNIT cUNIT = new CUNIT(); cUNIT.SetMapEditor(mapeditor); cUNIT.unitID = (ushort)unitid; cUNIT.X = (ushort)mappos.X; cUNIT.Y = (ushort)mappos.Y; cUNIT.player = (byte)playerid; mapeditor.mapdata.UNITListAdd(cUNIT); //mapeditor.mapdata.UNIT.Add(cUNIT); cUNIT.ImageReset(); mapeditor.taskManager.TaskAdd(new UnitEvent(mapeditor, cUNIT, true)); } } } } }
private bool UnitCollsionCheck(Vector2 pos, int unitid, bool IsBuilding, bool IsDrawRedLine) { if (mapeditor.UnitPalleteStackAllow) { return(true); } byte height = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Elevation Level", unitid).Data; bool IsAir = false; if (height >= 12) { IsAir = true; } 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); Vector2 min = pos - new Vector2(uleft, uup); Vector2 max = pos + new Vector2(uright, udown); Rect rect = new Rect(new Point(min.X, min.Y), new Point(max.X, max.Y)); //====지형==== if (!IsAir) { if (IsBuilding) { 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; min = pos - new Vector2(bwidth, bheight) / 2; max = pos + new Vector2(bwidth, bheight) / 2; } Vector2 mapmin = new Vector2((float)Math.Floor(min.X / 32), (float)Math.Floor(min.Y / 32)); Vector2 mapmax = new Vector2((float)Math.Floor((max.X - 1) / 32), (float)Math.Floor((max.Y - 1) / 32)); Vector2 minimin = new Vector2((float)Math.Floor(min.X / 8), (float)Math.Floor(min.Y / 8)); Vector2 minimax = new Vector2((float)Math.Floor((max.X - 1) / 8), (float)Math.Floor((max.Y - 1) / 8)); Vector2 gab = mapmax - mapmin; for (int Y = 0; Y <= gab.Y; Y++) { for (int X = 0; X <= gab.X; X++) { int cxti = (int)(mapmin.X + X); int cyti = (int)(mapmin.Y + Y); if (cxti < 0 || cyti < 0) { continue; } if (cxti >= mapeditor.mapdata.WIDTH || cyti >= mapeditor.mapdata.HEIGHT) { continue; } int tileindex = (int)((mapmin.X + X) + (mapmin.Y + Y) * mapeditor.mapdata.WIDTH); ushort MTXM = mapeditor.mapdata.MTXM[tileindex]; ushort megaindex = tileSet.GetMegaTileIndex(mapeditor.opt_drawType, mapeditor.mapdata.TILETYPE, MTXM); vf4 vf4 = tileSet.GetVf4(mapeditor.opt_drawType, mapeditor.mapdata.TILETYPE, megaindex); cv5 cv5 = tileSet.GetCV5(mapeditor.opt_drawType, mapeditor.mapdata.TILETYPE, MTXM); if (mapeditor.UnitPalleteBuildingFix & IsBuilding) { //빌딩 if (((cv5.Flags & 0x0040) > 0) | ((cv5.Flags & 0x0080) > 0)) { return(false); } } else { //일반 판정 if (vf4.IsWall) { return(false); } if (X == 0 | X == gab.X | Y == 0 | Y == gab.Y) { //가장자리 for (int my = 0; my < 4; my++) { for (int mx = 0; mx < 4; mx++) { Vector2 minitilepos = new Vector2((mapmin.X + X) * 4 + mx, (mapmin.Y + Y) * 4 + my); if ((minimin.X <= minitilepos.X) & (minitilepos.X <= minimax.X) & (minimin.Y <= minitilepos.Y) & (minitilepos.Y <= minimax.Y)) { int index = mx + my * 4; if ((vf4.flags[index] & 0b1) == 0) { return(false); } } } } } else { //안쪽 if (!vf4.IsGround) { return(false); } } } } } } //====유닛==== for (int i = 0; i < mapeditor.mapdata.UNIT.Count; i++) { CUNIT cUNIT = mapeditor.mapdata.UNIT[i]; int _unitid = cUNIT.unitID; byte _height = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Elevation Level", _unitid).Data; bool _IsAir = false; if (_height >= 12) { _IsAir = true; } if (_IsAir != IsAir) { continue; } 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; ushort _udown = (byte)Global.WindowTool.scdata.datFile.Values(DatFile.DatFiles.units, "Unit Size Down", _unitid).Data; _uleft -= 1; _uup -= 1; Vector2 _pos = new Vector2(cUNIT.X, cUNIT.Y); Vector2 _min = _pos - new Vector2(_uleft, _uup); Vector2 _max = _pos + new Vector2(_uright, _udown); Rect _rect = new Rect(new Point(_min.X, _min.Y), new Point(_max.X, _max.Y)); if (Rect.Intersect(rect, _rect) != Rect.Empty) { //충돌상황 if (IsDrawRedLine) { Vector2 mousepos = mapeditor.PosMapToScreen(_pos); double _l = (_uleft + 1) * mapeditor.opt_scalepercent; double _u = (_uup + 1) * mapeditor.opt_scalepercent; double _r = (_uright + 1) * mapeditor.opt_scalepercent; double _d = (_udown + 1) * mapeditor.opt_scalepercent; 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); } return(false); } } return(true); }