private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Chọn ảnh map"; ofd.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; ofd.InitialDirectory = @"C:\Users\dell\Desktop\"; if (ofd.ShowDialog() == DialogResult.OK) { MyLogger.getInstance().logDebug("Open map ------------------------------------------"); String fileName = ofd.FileName.Split('.')[0]; Bitmap background = context.open(fileName); background.MakeTransparent(Color.FromArgb(255, 0, 255)); this.width_map = background.Width; this.height_map = background.Height; this.bmp_map = new Bitmap(background); int count_horizontal = this.width_map / 16; int count_vertical = this.height_map / 16; this.bmp_map = new Bitmap(background); Bitmap _bmp = CreateMapSquare(background); using (Graphics g = Graphics.FromImage(_bmp)) { for (int row = 0; row < count_vertical; row++) { for (int col = 0; col < count_horizontal; col++) { g.DrawLine(Pens.Red, new Point(col * 16, 0), new Point(col * 16, this.height_map)); } g.DrawLine(Pens.Red, new Point(0, row * 16), new Point(this.width_map, row * 16)); } } picMap.SizeMode = PictureBoxSizeMode.AutoSize; picMap.Image = _bmp; background = _bmp; RecObject recobj = new RecObject(); recobj.parse(fileName + "recs.txt"); this.recs.AddRange(recobj.Recs); EnemyObj enemyObj = new EnemyObj(); enemyObj.parse(fileName + "enemy.txt"); this.enemies.AddRange(enemyObj.Enemies); foreach (ObjGame obj in enemyObj.Enemies) { ObjDTO objDTO = new ObjDTO(obj, folderDefault + "enemy/" + obj.Name + ".png"); pushObjGame(obj.X, obj.Y, objDTO); } } }
public void readDLC( DataInputStream dis, int packId, int index, int stringPooldId, string resPrefix) { this.m_packId = (short)packId; this.m_index = (short)index; this.m_parent = dis.readByte(); this.m_category = dis.readByte(); this.m_stringId = (int)dis.readShort(); this.m_actionIcon = (short)((int)dis.readShort() + 11); this.m_flags = dis.readInt(); this.m_need = dis.readShort(); this.m_buyPrice = dis.readShort(); this.m_sellPrice = dis.readShort(); this.m_footprintWidth = dis.readByte(); this.m_footprintHeight = dis.readByte(); this.m_modelId = (short)-1; string str = RecObject.readXMLtoBinString(dis); StringBuffer stringBuffer = new StringBuffer(resPrefix); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(str); this.m_modelFilename = stringBuffer.toString(); int length1 = (int)dis.readByte(); sbyte[] numArray1 = new sbyte[length1]; sbyte[] numArray2 = new sbyte[length1]; for (int index1 = 0; index1 < length1; ++index1) { numArray1[index1] = dis.readByte(); numArray2[index1] = dis.readByte(); } int length2 = (int)dis.readByte(); short[] numArray3 = new short[length2]; for (int index1 = 0; index1 < length2; ++index1) { numArray3[index1] = dis.readShort(); } this.m_interestPointXs = numArray1; this.m_interestPointYs = numArray2; this.m_actions = numArray3; }
private string readXMLtoBinFilename(DataInputStream dis, string prefix) { string str = RecObject.readXMLtoBinString(dis); if (str == null || str.Length <= 0) { return((string)null); } if (prefix == null) { return(str); } StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(prefix); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(str); return(stringBuffer.toString()); }
public RecObject(RecObject rhs) { this.m_packId = rhs.m_packId; this.m_index = rhs.m_index; this.m_parent = rhs.m_parent; this.m_category = rhs.m_category; this.m_stringId = rhs.m_stringId; this.m_actionIcon = rhs.m_actionIcon; this.m_flags = rhs.m_flags; this.m_need = rhs.m_need; this.m_buyPrice = rhs.m_buyPrice; this.m_sellPrice = rhs.m_sellPrice; this.m_footprintWidth = rhs.m_footprintWidth; this.m_footprintHeight = rhs.m_footprintHeight; this.m_modelId = rhs.m_modelId; this.m_modelFilename = rhs.m_modelFilename; this.m_interestPointXs = rhs.m_interestPointXs; this.m_interestPointYs = rhs.m_interestPointYs; this.m_actions = rhs.m_actions; }
private DLCPack loadPack(int packId, int sellId) { AppEngine canvas = AppEngine.getCanvas(); SimWorld simWorld = canvas.getSimWorld(); SimData simData = canvas.getSimData(); TextManager textManager = canvas.getTextManager(); DLCPack dlcPack = new DLCPack(); StringBuffer stringBuffer = new StringBuffer(); stringBuffer.setLength(0); stringBuffer.append(this.m_rootFolder); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(sellId); string str1 = stringBuffer.toString(); stringBuffer.setLength(0); stringBuffer.append(str1); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(DLCManager.PACKDATA_FILENAME); DataInputStream dis = new DataInputStream(JavaLib.getResourceAsStream(stringBuffer.toString(), false)); stringBuffer.setLength(0); stringBuffer.append(str1); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(DLCManager.STRINGS_DLC_FILENAME); string filename = stringBuffer.toString(); int stringPooldId = textManager.addStringsFile(filename); dis.readInt(); dlcPack.d_packId = dis.readInt(); dlcPack.d_packName = RecObject.readXMLtoBinString(dis); string str2 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_objectTextureFilename = str2; string str3 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_objectScrollingTextureFilename = str3; dlcPack.d_objectScrollingTextureTiming = dis.readInt(); string str4 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_simMaleFilename = str4; string str5 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_simFemaleFilename = str5; string str6 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_miniCarModelFilename = str6; string str7 = this.readXMLtoBinFilename(dis, str1); dlcPack.d_miniCarTextureFilename = str7; int length1 = (int)dis.readByte(); short[] numArray1 = new short[length1]; for (int index = 0; index < length1; ++index) { int action = (int)dis.readShort(); numArray1[index] = (short)action; simData.unlockAction(action, packId); } int length2 = (int)dis.readShort(); RecObject[] recObjectArray = new RecObject[length2]; for (int index = 0; index < length2; ++index) { recObjectArray[index] = new RecObject(); recObjectArray[index].readDLC(dis, packId, index, stringPooldId, str1); } int length3 = (int)dis.readByte(); RecItem[] recItemArray = new RecItem[length3]; for (int index = 0; index < length3; ++index) { recItemArray[index] = new RecItem(); recItemArray[index].readDLC(dis, packId, index, stringPooldId, str1); } int length4 = (int)dis.readByte(); short[] numArray2 = new short[length4]; for (int index = 0; index < length4; ++index) { int wallId = (int)dis.readShort(); numArray2[index] = (short)wallId; simWorld.unlockWall(wallId, packId); } int length5 = (int)dis.readByte(); short[] numArray3 = new short[length5]; for (int index = 0; index < length5; ++index) { int floorId = (int)dis.readShort(); numArray3[index] = (short)floorId; simWorld.unlockFloor(floorId, packId); } int num = (int)dis.readByte(); int length6 = 15; short[][] numArray4 = new short[length6][]; int[][] numArray5 = new int[length6][]; string[][][] strArray1 = new string[length6][][]; for (int index1 = 0; index1 < length6; ++index1) { int length7 = (int)dis.readByte(); short[] numArray6 = new short[length7]; int[] numArray7 = new int[length7]; string[][] strArray2 = new string[length7][]; for (int index2 = 0; index2 < length7; ++index2) { numArray6[index2] = (short)dis.readInt(); numArray7[index2] = dis.readInt(); int length8 = (int)dis.readByte(); string[] strArray3 = new string[length8]; for (int index3 = 0; index3 < length8; ++index3) { string str8 = this.readXMLtoBinFilename(dis, str1); strArray3[index3] = str8; } strArray2[index2] = strArray3; } numArray4[index1] = numArray6; numArray5[index1] = numArray7; strArray1[index1] = strArray2; } dlcPack.d_objectRecords = recObjectArray; dlcPack.d_itemRecords = recItemArray; dlcPack.d_simAttribUserIds = numArray4; dlcPack.d_simAttribFlags = numArray5; dlcPack.d_simAttribTextureFilenames = strArray1; return(dlcPack); }