private void GroupSelect_SelectedIndexChanged(object sender, EventArgs e) { this.iSelectedGroup = (ClsTerrain)this.GroupSelect.SelectedItem; this.PictureBox3.Image = (Image)Art.GetLand((int)this.iSelectedGroup.TileID); this.Box_TileID.Text = StringType.FromInteger((int)this.iSelectedGroup.TileID); this.Box_TileID_Hex.Text = string.Format("{0:X4}", (object)this.iSelectedGroup.TileID); }
public Transition(string iDescription, ClsTerrain iGroupA, ClsTerrain iGroupB, string iHashKey, MapTile iMapTile) { this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = null; this.m_File = null; this.m_Description = iDescription; byte b = 0; do { string sLeft = Strings.Mid(iHashKey, (int)checked (b + 1), 1); if (StringType.StrCmp(sLeft, "A", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupA.GroupID)); } else { if (StringType.StrCmp(sLeft, "B", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupB.GroupID)); } } b += 1; }while (b <= 8); this.m_MapTiles.Add(iMapTile); }
public Transition(string iDescription, ClsTerrain iGroupA, ClsTerrain iGroupB, string iHashKey, MapTile iMapTile) { this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = null; this.m_File = null; this.m_Description = iDescription; byte num = 0; do { string str = Strings.Mid(iHashKey, checked (num + 1), 1); if (StringType.StrCmp(str, "A", false) == 0) { this.m_HashKey.Add(new Transition.HashKey(iGroupA.GroupID)); } else if (StringType.StrCmp(str, "B", false) == 0) { this.m_HashKey.Add(new Transition.HashKey(iGroupB.GroupID)); } num = checked ((byte)(num + 1)); }while (num <= 8); this.m_MapTiles.Add(iMapTile); }
public Transition(string iDescription, ClsTerrain iGroupA, ClsTerrain iGroupB, ClsTerrain iGroupC, string iHashKey) { this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = (RandomStatics)null; this.m_File = (string)null; this.m_Description = iDescription; byte num = (byte)0; do { string sLeft = Strings.Mid(iHashKey, checked ((int)num + 1), 1); if (StringType.StrCmp(sLeft, "A", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupA.GroupID)); } else if (StringType.StrCmp(sLeft, "B", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupB.GroupID)); } else if (StringType.StrCmp(sLeft, "C", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupC.GroupID)); } ++num; }while ((int)num <= 8); }
private void Panel3_Paint(object sender, PaintEventArgs e) { IEnumerator enumerator = null; Graphics graphics = e.Graphics; Pen pen = new Pen(Color.Gray); ClsTerrain selectedItem = (ClsTerrain)this.GroupSelect.SelectedItem; int num = 0; do { int num1 = 0; do { int num2 = num1; int num3 = num; if (selectedItem != null) { e.Graphics.DrawImage(Art.GetLand(selectedItem.TileID), checked (this.StaticGrid[num2, num3].X - 22), checked (this.StaticGrid[num2, num3].Y - 22)); } e.Graphics.DrawLine(pen, checked (this.StaticGrid[num2, num3].X - 22), this.StaticGrid[num2, num3].Y, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y + 22)); e.Graphics.DrawLine(pen, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y + 22), checked (this.StaticGrid[num2, num3].X + 22), this.StaticGrid[num2, num3].Y); e.Graphics.DrawLine(pen, checked (this.StaticGrid[num2, num3].X + 22), this.StaticGrid[num2, num3].Y, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y - 22)); e.Graphics.DrawLine(pen, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y - 22), checked (this.StaticGrid[num2, num3].X - 22), this.StaticGrid[num2, num3].Y); num1++; }while (num1 <= 12); num++; }while (num <= 12); pen = new Pen(Color.Red); int num4 = Convert.ToInt32(decimal.Add(new decimal(6L), this.Yaxis.Value)); int num5 = Convert.ToInt32(decimal.Add(new decimal(6L), this.Xaxis.Value)); e.Graphics.DrawLine(pen, checked (this.StaticGrid[num4, num5].X - 22), this.StaticGrid[num4, num5].Y, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y + 22)); e.Graphics.DrawLine(pen, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y + 22), checked (this.StaticGrid[num4, num5].X + 22), this.StaticGrid[num4, num5].Y); e.Graphics.DrawLine(pen, checked (this.StaticGrid[num4, num5].X + 22), this.StaticGrid[num4, num5].Y, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y - 22)); e.Graphics.DrawLine(pen, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y - 22), checked (this.StaticGrid[num4, num5].X - 22), this.StaticGrid[num4, num5].Y); try { enumerator = this.ListBox2.Items.GetEnumerator(); while (enumerator.MoveNext()) { RandomStatic current = (RandomStatic)enumerator.Current; int y = checked (6 + current.Y); int x = checked (6 + current.X); Bitmap @static = Art.GetStatic(current.TileID); Point point = new Point(checked ((int)Math.Round((double)this.StaticGrid[y, x].X - (double)@static.Width / 2)), checked (checked (this.StaticGrid[y, x].Y - @static.Height) + 22)); e.Graphics.DrawImage(@static, point); } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } graphics = null; }
public void Clone(ClsTerrain iGroupA, ClsTerrain iGroupB) { this.m_Description = this.m_Description.Replace(iGroupA.Name, iGroupB.Name); int groupID = 0; do { if (this.m_HashKey[groupID].Key == iGroupA.GroupID) { this.m_HashKey[groupID].Key = checked ((byte)iGroupB.GroupID); } groupID++; }while (groupID <= 8); }
public void Clone(ClsTerrain iGroupA, ClsTerrain iGroupB) { this.m_Description = this.m_Description.Replace(iGroupA.Name, iGroupB.Name); int index = 0; do { if ((int)this.m_HashKey[index].Key == iGroupA.GroupID) { this.m_HashKey[index].Key = checked ((byte)iGroupB.GroupID); } checked { ++index; } }while (index <= 8); }
public void Clone(ClsTerrain iGroupA, ClsTerrain iGroupB) { this.m_Description = this.m_Description.Replace(iGroupA.Name, iGroupB.Name); int num = 0; checked { do { if ((int)this.m_HashKey[num].Key == iGroupA.GroupID) { this.m_HashKey[num].Key = (byte)iGroupB.GroupID; } num++; }while (num <= 8); } }
private void toolStripButton9_Click(object sender, EventArgs e) { ToolStripButton button = sender as ToolStripButton; if (button == null) { return; } ClsTerrain clsTerrain = (ClsTerrain)this.GroupSelect.SelectedItem; if (clsTerrain == null) { return; } this.iTransition.SetHashKey(IntegerType.FromObject(button.Tag), checked ((byte)clsTerrain.GroupID)); this.PictureBox1.Refresh(); }
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { if (this.ListBox1.SelectedItem == null) { return; } switch (this.i_Menu) { case 0: ClsTerrain clsTerrain = (ClsTerrain)this.ListBox1.SelectedItem; this.PropertyGrid1.SelectedObject = (object)clsTerrain; this.PictureBox1.Image = (Image)Art.GetLand((int)clsTerrain.TileID); break; case 1: this.PropertyGrid1.SelectedObject = (object)(ClsAltitude)this.ListBox1.SelectedItem; break; } }
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { if (this.ListBox1.SelectedItem != null) { switch (this.i_Menu) { case 0: { ClsTerrain selectedItem = (ClsTerrain)this.ListBox1.SelectedItem; this.PropertyGrid1.SelectedObject = selectedItem; this.PictureBox1.Image = Art.GetLand(selectedItem.TileID); break; } case 1: { ClsElevation clsAltitude = (ClsElevation)this.ListBox1.SelectedItem; this.PropertyGrid1.SelectedObject = clsAltitude; break; } } } }
private void MenuTerrain_Click(object sender, EventArgs e) { MapInfo mapInfo = (MapInfo)this.ComboBox2.SelectedItem; if (mapInfo == null) { this.iLogger.LogMessage("Error: Select a Map Type."); } else if (StringType.StrCmp(this.ProjectName.Text, string.Empty, false) == 0) { this.iLogger.LogMessage("Error: Enter a project Name."); } else { string path = string.Format("{0}/{1}/Map{2}", (object)this.ProjectPath.Text, (object)this.ProjectName.Text, (object)mapInfo.MapNumber); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } byte DefaultTerrain; byte DefaultAlt; if (this.ComboBox1.SelectedItem == null) { DefaultTerrain = (byte)9; DefaultAlt = (byte)66; } else { ClsTerrain clsTerrain = (ClsTerrain)this.ComboBox1.SelectedItem; DefaultTerrain = checked ((byte)clsTerrain.GroupID); DefaultAlt = clsTerrain.AltID; } this.iLogger.LogMessage("Creating Terrain Image."); this.iLogger.StartTask(); try { string filename = string.Format("{0}/{1}", (object)path, (object)this.TerrainFile.Text); Bitmap bitmap = this.MakeTerrainMap(mapInfo.XSize, mapInfo.YSize, DefaultTerrain, this.Dungeon.Checked); bitmap.Palette = this.iTerrain.GetPalette(); bitmap.Save(filename, ImageFormat.Bmp); bitmap.Dispose(); } catch (Exception ex) { ProjectData.SetProjectError(ex); this.iLogger.LogMessage("Error: Problem creating Terrain Image."); ProjectData.ClearProjectError(); } this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Creating Altitude Image."); this.iLogger.StartTask(); try { string filename = string.Format("{0}/{1}", (object)path, (object)this.AltitudeFile.Text); Bitmap bitmap = this.MakeAltMap(mapInfo.XSize, mapInfo.YSize, DefaultAlt, this.Dungeon.Checked); bitmap.Palette = this.iAltitude.GetAltPalette(); bitmap.Save(filename, ImageFormat.Bmp); bitmap.Dispose(); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; this.iLogger.LogMessage("Error: Problem creating Altitude Image."); this.iLogger.LogMessage(exception.Message); ProjectData.ClearProjectError(); } this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } }
private void Panel2_Paint(object sender, PaintEventArgs e) { string name = null; string str = null; Point point; Graphics graphics = e.Graphics; graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(5, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(197, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 29)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 221)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 79)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(78, 102)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(124, 102)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(55, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(147, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(78, 148)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(124, 148)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 171)); if (!this.ViewTiles) { if (this.iMapOuterTopLeft.GetNodeCount(true) > 0) { Bitmap land = Art.GetLand(IntegerType.FromObject(this.iMapOuterTopLeft.Nodes[0].Tag)); point = new Point(101, 29); graphics.DrawImage(land, point); } if (this.iMapInnerTopLeft.GetNodeCount(true) > 0) { Bitmap bitmap = Art.GetLand(IntegerType.FromObject(this.iMapInnerTopLeft.Nodes[0].Tag)); point = new Point(101, 79); graphics.DrawImage(bitmap, point); } if (this.iMapInnerTop.GetNodeCount(true) > 0) { Bitmap land1 = Art.GetLand(IntegerType.FromObject(this.iMapInnerTop.Nodes[0].Tag)); point = new Point(124, 102); graphics.DrawImage(land1, point); } if (this.iMapInnerTopRight.GetNodeCount(true) > 0) { Bitmap bitmap1 = Art.GetLand(IntegerType.FromObject(this.iMapInnerTopRight.Nodes[0].Tag)); point = new Point(147, 125); graphics.DrawImage(bitmap1, point); } if (this.iMapOuterTopRight.GetNodeCount(true) > 0) { Bitmap land2 = Art.GetLand(IntegerType.FromObject(this.iMapOuterTopRight.Nodes[0].Tag)); point = new Point(197, 125); graphics.DrawImage(land2, point); } if (this.iMapInnerLeft.GetNodeCount(true) > 0) { Bitmap bitmap2 = Art.GetLand(IntegerType.FromObject(this.iMapInnerLeft.Nodes[0].Tag)); point = new Point(78, 102); graphics.DrawImage(bitmap2, point); } if (this.iMapInnerRight.GetNodeCount(true) > 0) { Bitmap land3 = Art.GetLand(IntegerType.FromObject(this.iMapInnerRight.Nodes[0].Tag)); point = new Point(124, 148); graphics.DrawImage(land3, point); } if (this.iMapOuterBottomLeft.GetNodeCount(true) > 0) { Bitmap bitmap3 = Art.GetLand(IntegerType.FromObject(this.iMapOuterBottomLeft.Nodes[0].Tag)); point = new Point(5, 125); graphics.DrawImage(bitmap3, point); } if (this.iMapInnerBottomLeft.GetNodeCount(true) > 0) { Bitmap land4 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottomLeft.Nodes[0].Tag)); point = new Point(55, 125); graphics.DrawImage(land4, point); } if (this.iMapInnerBottom.GetNodeCount(true) > 0) { Bitmap bitmap4 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottom.Nodes[0].Tag)); point = new Point(78, 148); graphics.DrawImage(bitmap4, point); } if (this.iMapInnerBottomRight.GetNodeCount(true) > 0) { Bitmap land5 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottomRight.Nodes[0].Tag)); point = new Point(101, 171); graphics.DrawImage(land5, point); } if (this.iMapOuterBottomRight.GetNodeCount(true) > 0) { Bitmap bitmap5 = Art.GetLand(IntegerType.FromObject(this.iMapOuterBottomRight.Nodes[0].Tag)); point = new Point(101, 221); graphics.DrawImage(bitmap5, point); } } else { if (this.iStaticOuterTopLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterTopLeft.Nodes[0].Tag), 101, 29, e); } if (this.iStaticInnerTopLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTopLeft.Nodes[0].Tag), 101, 79, e); } if (this.iStaticInnerTop.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTop.Nodes[0].Tag), 124, 102, e); } if (this.iStaticInnerTopRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTopRight.Nodes[0].Tag), 147, 125, e); } if (this.iStaticOuterTopRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterTopRight.Nodes[0].Tag), 197, 125, e); } if (this.iStaticInnerLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerLeft.Nodes[0].Tag), 78, 102, e); } if (this.iStaticInnerRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerRight.Nodes[0].Tag), 124, 148, e); } if (this.iStaticOuterBottomLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterBottomLeft.Nodes[0].Tag), 5, 125, e); } if (this.iStaticInnerBottomLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottomLeft.Nodes[0].Tag), 55, 125, e); } if (this.iStaticInnerBottom.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottom.Nodes[0].Tag), 78, 148, e); } if (this.iStaticInnerBottomRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottomRight.Nodes[0].Tag), 101, 171, e); } if (this.iStaticOuterBottomRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterBottomRight.Nodes[0].Tag), 101, 221, e); } } Pen pen = new Pen(Color.Red); if (this.iMapOuterTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 29)); } if (this.iMapInnerTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 79)); } if (this.iMapInnerTop.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 102)); } if (this.iMapInnerTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(147, 125)); } if (this.iMapOuterTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(197, 125)); } if (this.iMapInnerLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 102)); } if (this.iMapInnerRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 148)); } if (this.iMapOuterBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(5, 125)); } if (this.iMapInnerBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(55, 125)); } if (this.iMapInnerBottom.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 148)); } if (this.iMapInnerBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 171)); } if (this.iMapOuterBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 221)); } pen = new Pen(Color.Magenta); if (this.iStaticOuterTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 29)); } if (this.iStaticInnerTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 79)); } if (this.iStaticInnerTop.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 102)); } if (this.iStaticInnerTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(147, 125)); } if (this.iStaticOuterTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(197, 125)); } if (this.iStaticInnerLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 102)); } if (this.iStaticInnerRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 148)); } if (this.iStaticOuterBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(5, 125)); } if (this.iStaticInnerBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(55, 125)); } if (this.iStaticInnerBottom.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 148)); } if (this.iStaticInnerBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 171)); } if (this.iStaticOuterBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 221)); } ClsTerrain selectedItem = (ClsTerrain)this.Select_Group_A.SelectedItem; if (selectedItem != null) { Bitmap land6 = Art.GetLand(selectedItem.TileID); point = new Point(5, 242); graphics.DrawImage(land6, point); Bitmap bitmap6 = Art.GetLand(selectedItem.TileID); point = new Point(101, 125); graphics.DrawImage(bitmap6, point); name = selectedItem.Name; } selectedItem = (ClsTerrain)this.Select_Group_B.SelectedItem; if (selectedItem != null) { Bitmap land7 = Art.GetLand(selectedItem.TileID); point = new Point(55, 242); graphics.DrawImage(land7, point); str = selectedItem.Name; } #region Label Formatting //Edit The '↔' To Change How You Want Your Labels To Look //Original 'To' Was The Transition Keyword For The Labels //This Keyword Was Changed To Arrows To Show The Back And Forth Between Transitions this.TextBox1.Text = string.Format("{0} ↔ {1}", name, str); #endregion graphics = null; #endregion }
public Transition(string iDescription, string iHashKey, ClsTerrain iGroupA, ClsTerrain iGroupB, MapTileCollection iMapTiles, StaticTileCollection iStaticTiles) { IEnumerator enumerator = null; IEnumerator enumerator1 = null; this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = null; this.m_File = null; this.m_Description = iDescription; byte num = 0; do { string str = Strings.Mid(iHashKey, checked (num + 1), 1); if (StringType.StrCmp(str, "A", false) == 0) { this.m_HashKey.Add(new Transition.HashKey(iGroupA.GroupID)); } else if (StringType.StrCmp(str, "B", false) == 0) { this.m_HashKey.Add(new Transition.HashKey(iGroupB.GroupID)); } num = checked ((byte)(num + 1)); }while (num <= 8); if (iMapTiles != null) { try { enumerator1 = iMapTiles.GetEnumerator(); while (enumerator1.MoveNext()) { MapTile current = (MapTile)enumerator1.Current; this.m_MapTiles.Add(current); } } finally { if (enumerator1 is IDisposable) { ((IDisposable)enumerator1).Dispose(); } } } if (iStaticTiles != null) { try { enumerator = iStaticTiles.GetEnumerator(); while (enumerator.MoveNext()) { Transition.StaticTile staticTile = (Transition.StaticTile)enumerator.Current; this.m_StaticTiles.Add(staticTile); } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } } }
private void Make() { short altID = 0; string str; byte num = 0; int num1; int num2; int num3; int num4; IEnumerator enumerator = null; TransitionTable transitionTable = new TransitionTable(); DateTime now = DateTime.Now; this.iLogger.StartTask(); this.iLogger.LogMessage("Loading Terrain Image."); try { str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.TerrainFile.Text); this.iLogger.LogMessage(str); this.i_Terrain = new Bitmap(str); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; this.iLogger.LogMessage("Problem with Loading Terrain Image."); this.iLogger.LogMessage(exception.Message); ProjectData.ClearProjectError(); return; } this.iLogger.LogMessage("Loading Altitude Image."); try { str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.AltitudeFile.Text); this.iLogger.LogMessage(str); this.i_Altitude = new Bitmap(str); } catch (Exception exception3) { ProjectData.SetProjectError(exception3); Exception exception2 = exception3; this.iLogger.LogMessage("Problem with Loading Altitude Image."); this.iLogger.LogMessage(exception2.Message); ProjectData.ClearProjectError(); return; } //this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Preparing Image Files."); this.iLogger.StartTask(); int width = this.i_Terrain.Width; int height = this.i_Terrain.Height; Rectangle rectangle = new Rectangle(0, 0, width, height); BitmapData bitmapDatum = this.i_Terrain.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0 = bitmapDatum.Scan0; int width1 = checked (bitmapDatum.Width * bitmapDatum.Height); byte[] numArray = new byte[checked (checked (width1 - 1) + 1)]; Marshal.Copy(scan0, numArray, 0, width1); BitmapData bitmapDatum1 = this.i_Altitude.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr intPtr = bitmapDatum1.Scan0; int width2 = checked (bitmapDatum1.Width * bitmapDatum1.Height); byte[] numArray1 = new byte[checked (checked (width2 - 1) + 1)]; Marshal.Copy(intPtr, numArray1, 0, width2); //this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Creating Master Terrian Table."); this.iLogger.StartTask(); MapCell[,] mapCell = new MapCell[checked (width + 1), checked (height + 1)]; ClsAltitudeTable clsAltitudeTable = new ClsAltitudeTable(); clsAltitudeTable.Load(); try { int num5 = checked (width - 1); for (int i = 0; i <= num5; i++) { int num6 = checked (height - 1); for (int j = 0; j <= num6; j++) { int num7 = checked (checked (j * width) + i); ClsAltitude getAltitude = clsAltitudeTable.GetAltitude(numArray1[num7]); mapCell[i, j] = new MapCell(numArray[num7], getAltitude.GetAltitude); } } } catch (Exception exception4) { ProjectData.SetProjectError(exception4); this.iLogger.LogMessage("Altitude image needs to be rebuilt"); ProjectData.ClearProjectError(); return; } this.i_Terrain.Dispose(); this.i_Altitude.Dispose(); this.iLogger.LogTimeStamp(); width--; height--; int num8 = checked ((int)Math.Round((double)width / 8 - 1)); int num9 = checked ((int)Math.Round((double)height / 8 - 1)); this.iLogger.LogMessage("Load Transition Tables."); this.iLogger.StartTask(); string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; #region Data Directory Modification baseDirectory = string.Concat(baseDirectory, "Data\\Engine\\Transitions\\"); #endregion if (Directory.Exists(baseDirectory)) { transitionTable.MassLoad(baseDirectory); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Preparing Static Tables"); Collection[,] collections = new Collection[checked (num8 + 1), checked (num9 + 1)]; int num10 = num8; for (int k = 0; k <= num10; k++) { int num11 = num9; for (int l = 0; l <= num11; l++) { collections[k, l] = new Collection(); } } this.iLogger.LogMessage("Applying Transition Tables."); this.iLogger.StartTask(); this.ProgressBar1.Maximum = width; ClsTerrainTable clsTerrainTable = new ClsTerrainTable(); clsTerrainTable.Load(); MapTile mapTile = new MapTile(); Transition.Transition transition = new Transition.Transition(); short[] numArray2 = new short[16]; short num12 = checked ((short)width); for (short m = 0; m <= num12; m = checked ((short)(m + 1))) { num1 = (m != 0 ? checked (m - 1) : width); num2 = (m != width ? checked (m + 1) : 0); short num13 = checked ((short)height); for (short n = 0; n <= num13; n = checked ((short)(n + 1))) { num4 = (n != 0 ? checked (n - 1) : height); num3 = (n != height ? checked (n + 1) : 0); object[] groupID = new object[] { mapCell[num1, num4].GroupID, mapCell[m, num4].GroupID, mapCell[num2, num4].GroupID, mapCell[num1, n].GroupID, mapCell[m, n].GroupID, mapCell[num2, n].GroupID, mapCell[num1, num3].GroupID, mapCell[m, num3].GroupID, mapCell[num2, num3].GroupID }; string str1 = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}", groupID); try { transition = (Transition.Transition)(transitionTable.GetTransitionTable[str1]); if (transition == null) { ClsTerrain terrianGroup = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID); mapCell[m, n].TileID = terrianGroup.TileID; mapCell[m, n].AltID = altID; terrianGroup = null; } else { altID = mapCell[m, n].AltID; mapTile = transition.GetRandomMapTile(); if (mapTile == null) { ClsTerrain clsTerrain = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID); mapCell[m, n].TileID = clsTerrain.TileID; mapCell[m, n].ChangeAltID((short)clsTerrain.AltID); clsTerrain = null; } else { MapTile mapTile1 = mapTile; mapCell[m, n].TileID = mapTile1.TileID; mapCell[m, n].ChangeAltID(mapTile1.AltIDMod); mapTile1 = null; } transition.GetRandomStaticTiles(m, n, altID, collections, this.i_RandomStatic); } if (mapCell[m, n].GroupID == 254) { mapCell[m, n].TileID = 1078; mapCell[m, n].AltID = 0; } } catch (Exception exception6) { ProjectData.SetProjectError(exception6); Exception exception5 = exception6; LoggerForm loggerForm = this.iLogger; groupID = new object[] { m, n, altID, str1 }; loggerForm.LogMessage(string.Format("\r\nLocation: X:{0}, Y:{1}, Z:{2} Hkey:{3}", groupID)); this.iLogger.LogMessage(exception5.ToString()); ProjectData.ClearProjectError(); return; } } this.ProgressBar1.Value = m; } this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Second Pass."); this.iLogger.StartTask(); short[] altID1 = new short[9]; RoughEdge roughEdge = new RoughEdge(); short num14 = checked ((short)width); for (short o = 0; o <= num14; o = checked ((short)(o + 1))) { num1 = (o != 0 ? checked (o - 1) : width); num2 = (o != width ? checked (o + 1) : 0); short num15 = checked ((short)height); for (short p = 0; p <= num15; p = checked ((short)(p + 1))) { num4 = (p != 0 ? checked (p - 1) : height); num3 = (p != height ? checked (p + 1) : 0); mapCell[o, p].ChangeAltID(roughEdge.CheckCorner(mapCell[num1, num4].TileID)); mapCell[o, p].ChangeAltID(roughEdge.CheckLeft(mapCell[num1, p].TileID)); mapCell[o, p].ChangeAltID(roughEdge.CheckTop(mapCell[o, num4].TileID)); if (mapCell[o, p].GroupID == 20) { altID1[0] = mapCell[num1, num4].AltID; altID1[1] = mapCell[o, num4].AltID; altID1[2] = mapCell[num2, num4].AltID; altID1[3] = mapCell[num1, p].AltID; altID1[4] = mapCell[o, p].AltID; altID1[5] = mapCell[num2, p].AltID; altID1[6] = mapCell[num1, num3].AltID; altID1[7] = mapCell[o, num3].AltID; altID1[8] = mapCell[num2, num3].AltID; Array.Sort(altID1); float single = 10f * VBMath.Rnd(); if (single == 0f) { mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 4))); } else if (single >= 1f && single <= 2f) { mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 2))); } else if (single >= 3f && single <= 7f) { mapCell[o, p].AltID = altID1[8]; } else if (single >= 8f && single <= 9f) { mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 2))); } else if (single == 10f) { mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 4))); } } if (clsTerrainTable.TerrianGroup(mapCell[o, p].GroupID).RandAlt) { float single1 = 10f * VBMath.Rnd(); if (single1 == 0f) { mapCell[o, p].ChangeAltID(-4); } else if (single1 >= 1f && single1 <= 2f) { mapCell[o, p].ChangeAltID(-2); } else if (single1 >= 8f && single1 <= 9f) { mapCell[o, p].ChangeAltID(2); } else if (single1 == 10f) { mapCell[o, p].ChangeAltID(4); } } } this.ProgressBar1.Value = o; } this.iLogger.LogTimeStamp(); int num16 = 1; int num17 = width; if (num17 == 6143) { num = 0; } else if (num17 == 2303) { num = 2; } else if (num17 == 2559) { num = 3; } this.iLogger.LogMessage("\r\n"); this.iLogger.LogMessage("Load . . . . . Import Tiles."); this.iLogger.StartTask(); ImportTiles importTile = new ImportTiles(collections, this.ProjectPath.Text); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("\r\n"); this.iLogger.LogMessage("Write Mul Files."); this.iLogger.StartTask(); str = string.Format("{0}/Map{1}.mul", this.ProjectPath.Text, num); this.iLogger.LogMessage(str); FileStream fileStream = new FileStream(str, FileMode.Create); BinaryWriter binaryWriter = new BinaryWriter(fileStream); int num18 = width; for (int q = 0; q <= num18; q = checked (q + 8)) { int num19 = height; for (int r = 0; r <= num19; r = checked (r + 8)) { binaryWriter.Write(num16); int num20 = 0; do { int num21 = 0; do { mapCell[checked (q + num21), checked (r + num20)].WriteMapMul(binaryWriter); num21++; }while (num21 <= 7); num20++; }while (num20 <= 7); } } binaryWriter.Close(); fileStream.Close(); str = string.Format("{0}/StaIdx{1}.mul", this.ProjectPath.Text, num); FileStream fileStream1 = new FileStream(str, FileMode.Create); this.iLogger.LogMessage(str); str = string.Format("{0}/Statics{1}.mul", this.ProjectPath.Text, num); FileStream fileStream2 = new FileStream(str, FileMode.Create); this.iLogger.LogMessage(str); BinaryWriter binaryWriter1 = new BinaryWriter(fileStream1); BinaryWriter binaryWriter2 = new BinaryWriter(fileStream2); int num22 = num8; for (int s = 0; s <= num22; s++) { int num23 = num9; for (int t = 0; t <= num23; t++) { int num24 = 0; int position = checked ((int)binaryWriter2.BaseStream.Position); try { enumerator = collections[s, t].GetEnumerator(); while (enumerator.MoveNext()) { ((StaticCell)enumerator.Current).Write(binaryWriter2); num24 = checked (num24 + 7); } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } if (num24 == 0) { position = -1; } binaryWriter1.Write(position); binaryWriter1.Write(num24); binaryWriter1.Write(num16); } } binaryWriter2.Close(); binaryWriter1.Close(); fileStream2.Close(); fileStream1.Close(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } else { this.iLogger.LogMessage("Unable to find Transition Data files in the following path: "); this.iLogger.LogMessage(baseDirectory); } }
private void Panel2_Paint(object sender, PaintEventArgs e) { string name = null; string str = null; Point point; Graphics graphics = e.Graphics; graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(5, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(197, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 29)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 221)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 79)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(78, 102)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(124, 102)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(55, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(147, 125)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(78, 148)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(124, 148)); graphics.DrawPolygon(new Pen(Color.Blue), this.GetPoints(101, 171)); if (!this.ViewTiles) { if (this.iMapOuterTopLeft.GetNodeCount(true) > 0) { Bitmap land = Art.GetLand(IntegerType.FromObject(this.iMapOuterTopLeft.Nodes[0].Tag)); point = new Point(101, 29); graphics.DrawImage(land, point); } if (this.iMapInnerTopLeft.GetNodeCount(true) > 0) { Bitmap bitmap = Art.GetLand(IntegerType.FromObject(this.iMapInnerTopLeft.Nodes[0].Tag)); point = new Point(101, 79); graphics.DrawImage(bitmap, point); } if (this.iMapInnerTop.GetNodeCount(true) > 0) { Bitmap land1 = Art.GetLand(IntegerType.FromObject(this.iMapInnerTop.Nodes[0].Tag)); point = new Point(124, 102); graphics.DrawImage(land1, point); } if (this.iMapInnerTopRight.GetNodeCount(true) > 0) { Bitmap bitmap1 = Art.GetLand(IntegerType.FromObject(this.iMapInnerTopRight.Nodes[0].Tag)); point = new Point(147, 125); graphics.DrawImage(bitmap1, point); } if (this.iMapOuterTopRight.GetNodeCount(true) > 0) { Bitmap land2 = Art.GetLand(IntegerType.FromObject(this.iMapOuterTopRight.Nodes[0].Tag)); point = new Point(197, 125); graphics.DrawImage(land2, point); } if (this.iMapInnerLeft.GetNodeCount(true) > 0) { Bitmap bitmap2 = Art.GetLand(IntegerType.FromObject(this.iMapInnerLeft.Nodes[0].Tag)); point = new Point(78, 102); graphics.DrawImage(bitmap2, point); } if (this.iMapInnerRight.GetNodeCount(true) > 0) { Bitmap land3 = Art.GetLand(IntegerType.FromObject(this.iMapInnerRight.Nodes[0].Tag)); point = new Point(124, 148); graphics.DrawImage(land3, point); } if (this.iMapOuterBottomLeft.GetNodeCount(true) > 0) { Bitmap bitmap3 = Art.GetLand(IntegerType.FromObject(this.iMapOuterBottomLeft.Nodes[0].Tag)); point = new Point(5, 125); graphics.DrawImage(bitmap3, point); } if (this.iMapInnerBottomLeft.GetNodeCount(true) > 0) { Bitmap land4 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottomLeft.Nodes[0].Tag)); point = new Point(55, 125); graphics.DrawImage(land4, point); } if (this.iMapInnerBottom.GetNodeCount(true) > 0) { Bitmap bitmap4 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottom.Nodes[0].Tag)); point = new Point(78, 148); graphics.DrawImage(bitmap4, point); } if (this.iMapInnerBottomRight.GetNodeCount(true) > 0) { Bitmap land5 = Art.GetLand(IntegerType.FromObject(this.iMapInnerBottomRight.Nodes[0].Tag)); point = new Point(101, 171); graphics.DrawImage(land5, point); } if (this.iMapOuterBottomRight.GetNodeCount(true) > 0) { Bitmap bitmap5 = Art.GetLand(IntegerType.FromObject(this.iMapOuterBottomRight.Nodes[0].Tag)); point = new Point(101, 221); graphics.DrawImage(bitmap5, point); } } else { if (this.iStaticOuterTopLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterTopLeft.Nodes[0].Tag), 101, 29, e); } if (this.iStaticInnerTopLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTopLeft.Nodes[0].Tag), 101, 79, e); } if (this.iStaticInnerTop.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTop.Nodes[0].Tag), 124, 102, e); } if (this.iStaticInnerTopRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerTopRight.Nodes[0].Tag), 147, 125, e); } if (this.iStaticOuterTopRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterTopRight.Nodes[0].Tag), 197, 125, e); } if (this.iStaticInnerLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerLeft.Nodes[0].Tag), 78, 102, e); } if (this.iStaticInnerRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerRight.Nodes[0].Tag), 124, 148, e); } if (this.iStaticOuterBottomLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterBottomLeft.Nodes[0].Tag), 5, 125, e); } if (this.iStaticInnerBottomLeft.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottomLeft.Nodes[0].Tag), 55, 125, e); } if (this.iStaticInnerBottom.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottom.Nodes[0].Tag), 78, 148, e); } if (this.iStaticInnerBottomRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticInnerBottomRight.Nodes[0].Tag), 101, 171, e); } if (this.iStaticOuterBottomRight.GetNodeCount(true) > 0) { this.DrawStatic(ShortType.FromObject(this.iStaticOuterBottomRight.Nodes[0].Tag), 101, 221, e); } } Pen pen = new Pen(Color.Red); if (this.iMapOuterTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 29)); } if (this.iMapInnerTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 79)); } if (this.iMapInnerTop.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 102)); } if (this.iMapInnerTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(147, 125)); } if (this.iMapOuterTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(197, 125)); } if (this.iMapInnerLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 102)); } if (this.iMapInnerRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 148)); } if (this.iMapOuterBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(5, 125)); } if (this.iMapInnerBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(55, 125)); } if (this.iMapInnerBottom.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 148)); } if (this.iMapInnerBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 171)); } if (this.iMapOuterBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 221)); } pen = new Pen(Color.Magenta); if (this.iStaticOuterTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 29)); } if (this.iStaticInnerTopLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 79)); } if (this.iStaticInnerTop.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 102)); } if (this.iStaticInnerTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(147, 125)); } if (this.iStaticOuterTopRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(197, 125)); } if (this.iStaticInnerLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 102)); } if (this.iStaticInnerRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(124, 148)); } if (this.iStaticOuterBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(5, 125)); } if (this.iStaticInnerBottomLeft.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(55, 125)); } if (this.iStaticInnerBottom.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(78, 148)); } if (this.iStaticInnerBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 171)); } if (this.iStaticOuterBottomRight.IsSelected) { graphics.DrawPolygon(pen, this.GetPoints(101, 221)); } ClsTerrain selectedItem = (ClsTerrain)this.Select_Group_A.SelectedItem; if (selectedItem != null) { Bitmap land6 = Art.GetLand(selectedItem.TileID); point = new Point(5, 242); graphics.DrawImage(land6, point); Bitmap bitmap6 = Art.GetLand(selectedItem.TileID); point = new Point(101, 125); graphics.DrawImage(bitmap6, point); name = selectedItem.Name; } selectedItem = (ClsTerrain)this.Select_Group_B.SelectedItem; if (selectedItem != null) { Bitmap land7 = Art.GetLand(selectedItem.TileID); point = new Point(55, 242); graphics.DrawImage(land7, point); str = selectedItem.Name; } this.TextBox1.Text = string.Format("{0} To {1}", name, str); graphics = null; }
private void Make() { TransitionTable transitionTable = new TransitionTable(); DateTime now = DateTime.Now; this.iLogger.StartTask(); this.iLogger.LogMessage("Loading Terrain Image."); try { string str = string.Format("{0}\\{1}", (object)this.ProjectPath.Text, (object)this.TerrainFile.Text); this.iLogger.LogMessage(str); this.i_Terrain = new Bitmap(str); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; this.iLogger.LogMessage("Problem with Loading Terrain Image."); this.iLogger.LogMessage(exception.Message); ProjectData.ClearProjectError(); return; } this.iLogger.LogMessage("Loading Altitude Image."); try { string str = string.Format("{0}\\{1}", (object)this.ProjectPath.Text, (object)this.AltitudeFile.Text); this.iLogger.LogMessage(str); this.i_Altitude = new Bitmap(str); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; this.iLogger.LogMessage("Problem with Loading Altitude Image."); this.iLogger.LogMessage(exception.Message); ProjectData.ClearProjectError(); return; } this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Preparing Image Files."); this.iLogger.StartTask(); int width = this.i_Terrain.Width; int height = this.i_Terrain.Height; Rectangle rect = new Rectangle(0, 0, width, height); BitmapData bitmapData1 = this.i_Terrain.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0_1 = bitmapData1.Scan0; int length1 = checked (bitmapData1.Width * bitmapData1.Height); byte[] destination1 = new byte[checked (length1 - 1 + 1)]; Marshal.Copy(scan0_1, destination1, 0, length1); BitmapData bitmapData2 = this.i_Altitude.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0_2 = bitmapData2.Scan0; int length2 = checked (bitmapData2.Width * bitmapData2.Height); byte[] destination2 = new byte[checked (length2 - 1 + 1)]; Marshal.Copy(scan0_2, destination2, 0, length2); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Creating Master Terrian Table."); this.iLogger.StartTask(); MapCell[,] mapCellArray = new MapCell[checked (width + 1), checked (height + 1)]; ClsAltitudeTable clsAltitudeTable = new ClsAltitudeTable(); clsAltitudeTable.Load(); try { int num1 = 0; int num2 = checked (width - 1); int index1 = num1; while (index1 <= num2) { int num3 = 0; int num4 = checked (height - 1); int index2 = num3; while (index2 <= num4) { int index3 = checked (index2 * width + index1); ClsAltitude clsAltitude = clsAltitudeTable.get_GetAltitude((int)destination2[index3]); mapCellArray[index1, index2] = new MapCell(destination1[index3], clsAltitude.GetAltitude); checked { ++index2; } } checked { ++index1; } } } catch (Exception ex) { ProjectData.SetProjectError(ex); this.iLogger.LogMessage("Altitude image needs to be rebuilt"); ProjectData.ClearProjectError(); return; } this.i_Terrain.Dispose(); this.i_Altitude.Dispose(); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); int num5 = checked (width - 1); int num6 = checked (height - 1); int num7 = checked ((int)Math.Round(unchecked ((double)num5 / 8.0 - 1.0))); int num8 = checked ((int)Math.Round(unchecked ((double)num6 / 8.0 - 1.0))); this.iLogger.LogMessage("Load Transition Tables."); this.iLogger.StartTask(); string str1 = AppDomain.CurrentDomain.BaseDirectory + "Data\\Transitions\\"; if (!Directory.Exists(str1)) { this.iLogger.LogMessage("Unable to find Transition Data files in the following path: "); this.iLogger.LogMessage(str1); } else { transitionTable.MassLoad(str1); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Preparing Static Tables"); Collection[,] StaticMap = new Collection[checked (num7 + 1), checked (num8 + 1)]; int num1 = 0; int num2 = num7; int index1 = num1; while (index1 <= num2) { int num3 = 0; int num4 = num8; int index2 = num3; while (index2 <= num4) { StaticMap[index1, index2] = new Collection(); checked { ++index2; } } checked { ++index1; } } this.iLogger.LogMessage("Applying Transition Tables."); this.iLogger.StartTask(); this.ProgressBar1.Maximum = num5; ClsTerrainTable clsTerrainTable = new ClsTerrainTable(); clsTerrainTable.Load(); MapTile mapTile1 = new MapTile(); Transition transition1 = new Transition(); short[] numArray1 = new short[16]; int num9 = 0; short num10 = checked ((short)num5); for (short X = (short)num9; (int)X <= (int)num10; ++X) { int index2 = (int)X != 0 ? checked ((int)X - 1) : num5; int index3 = (int)X != num5 ? checked ((int)X + 1) : 0; int num3 = 0; short num4 = checked ((short)num6); for (short Y = (short)num3; (int)Y <= (int)num4; ++Y) { int index4 = (int)Y != 0 ? checked ((int)Y - 1) : num6; int index5 = (int)Y != num6 ? checked ((int)Y + 1) : 0; string iKey = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}", (object)mapCellArray[index2, index4].GroupID, (object)mapCellArray[(int)X, index4].GroupID, (object)mapCellArray[index3, index4].GroupID, (object)mapCellArray[index2, (int)Y].GroupID, (object)mapCellArray[(int)X, (int)Y].GroupID, (object)mapCellArray[index3, (int)Y].GroupID, (object)mapCellArray[index2, index5].GroupID, (object)mapCellArray[(int)X, index5].GroupID, (object)mapCellArray[index3, index5].GroupID); short altId; try { Transition transition2 = transitionTable.get_Transition(iKey); if (transition2 != null) { altId = mapCellArray[(int)X, (int)Y].AltID; MapTile randomMapTile = transition2.GetRandomMapTile(); if (randomMapTile != null) { MapTile mapTile2 = randomMapTile; mapCellArray[(int)X, (int)Y].TileID = mapTile2.TileID; mapCellArray[(int)X, (int)Y].ChangeAltID(mapTile2.AltIDMod); } else { ClsTerrain clsTerrain = clsTerrainTable.get_TerrianGroup((int)mapCellArray[(int)X, (int)Y].GroupID); mapCellArray[(int)X, (int)Y].TileID = clsTerrain.TileID; mapCellArray[(int)X, (int)Y].ChangeAltID((short)clsTerrain.AltID); } transition2.GetRandomStaticTiles(X, Y, altId, StaticMap, this.i_RandomStatic); } else { ClsTerrain clsTerrain = clsTerrainTable.get_TerrianGroup((int)mapCellArray[(int)X, (int)Y].GroupID); mapCellArray[(int)X, (int)Y].TileID = clsTerrain.TileID; mapCellArray[(int)X, (int)Y].AltID = altId; } if ((int)mapCellArray[(int)X, (int)Y].GroupID == 254) { mapCellArray[(int)X, (int)Y].TileID = (short)1078; mapCellArray[(int)X, (int)Y].AltID = (short)0; } } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; this.iLogger.LogMessage(string.Format("\r\nLocation: X:{0}, Y:{1}, Z:{2} Hkey:{3}", (object)X, (object)Y, (object)altId, (object)iKey)); this.iLogger.LogMessage(exception.ToString()); ProjectData.ClearProjectError(); return; } } this.ProgressBar1.Value = (int)X; } this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Second Pass."); this.iLogger.StartTask(); short[] numArray2 = new short[9]; RoughEdge roughEdge = new RoughEdge(); int num11 = 0; short num12 = checked ((short)num5); for (short index2 = (short)num11; (int)index2 <= (int)num12; ++index2) { int index3 = (int)index2 != 0 ? checked ((int)index2 - 1) : num5; int index4 = (int)index2 != num5 ? checked ((int)index2 + 1) : 0; int num3 = 0; short num4 = checked ((short)num6); for (short index5 = (short)num3; (int)index5 <= (int)num4; ++index5) { int index6 = (int)index5 != 0 ? checked ((int)index5 - 1) : num6; int index7 = (int)index5 != num6 ? checked ((int)index5 + 1) : 0; mapCellArray[(int)index2, (int)index5].ChangeAltID(roughEdge.CheckCorner(mapCellArray[index3, index6].TileID)); mapCellArray[(int)index2, (int)index5].ChangeAltID(roughEdge.CheckLeft(mapCellArray[index3, (int)index5].TileID)); mapCellArray[(int)index2, (int)index5].ChangeAltID(roughEdge.CheckTop(mapCellArray[(int)index2, index6].TileID)); if ((int)mapCellArray[(int)index2, (int)index5].GroupID == 20) { numArray2[0] = mapCellArray[index3, index6].AltID; numArray2[1] = mapCellArray[(int)index2, index6].AltID; numArray2[2] = mapCellArray[index4, index6].AltID; numArray2[3] = mapCellArray[index3, (int)index5].AltID; numArray2[4] = mapCellArray[(int)index2, (int)index5].AltID; numArray2[5] = mapCellArray[index4, (int)index5].AltID; numArray2[6] = mapCellArray[index3, index7].AltID; numArray2[7] = mapCellArray[(int)index2, index7].AltID; numArray2[8] = mapCellArray[index4, index7].AltID; Array.Sort((Array)numArray2); float num13 = 10f * VBMath.Rnd(); if ((double)num13 == 0.0) { mapCellArray[(int)index2, (int)index5].AltID = checked ((short)((int)numArray2[8] - 4)); } else if ((double)num13 >= 1.0 && (double)num13 <= 2.0) { mapCellArray[(int)index2, (int)index5].AltID = checked ((short)((int)numArray2[8] - 2)); } else if ((double)num13 >= 3.0 && (double)num13 <= 7.0) { mapCellArray[(int)index2, (int)index5].AltID = numArray2[8]; } else if ((double)num13 >= 8.0 && (double)num13 <= 9.0) { mapCellArray[(int)index2, (int)index5].AltID = checked ((short)((int)numArray2[8] + 2)); } else if ((double)num13 == 10.0) { mapCellArray[(int)index2, (int)index5].AltID = checked ((short)((int)numArray2[8] + 4)); } } if (clsTerrainTable.get_TerrianGroup((int)mapCellArray[(int)index2, (int)index5].GroupID).RandAlt) { float num13 = 10f * VBMath.Rnd(); if ((double)num13 == 0.0) { mapCellArray[(int)index2, (int)index5].ChangeAltID((short)-4); } else if ((double)num13 >= 1.0 && (double)num13 <= 2.0) { mapCellArray[(int)index2, (int)index5].ChangeAltID((short)-2); } else if ((double)num13 >= 8.0 && (double)num13 <= 9.0) { mapCellArray[(int)index2, (int)index5].ChangeAltID((short)2); } else if ((double)num13 == 10.0) { mapCellArray[(int)index2, (int)index5].ChangeAltID((short)4); } } } this.ProgressBar1.Value = (int)index2; } this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); int num14 = 1; byte num15; switch (num5) { case 6143: num15 = (byte)0; break; case 2303: num15 = (byte)2; break; case 2559: num15 = (byte)3; break; } this.iLogger.LogMessage("\r\n"); this.iLogger.LogMessage("Load . . . . . Import Tiles."); this.iLogger.StartTask(); ImportTiles importTiles = new ImportTiles(StaticMap, this.ProjectPath.Text); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("\r\n"); this.iLogger.LogMessage("Write Mul Files."); this.iLogger.StartTask(); string str2 = string.Format("{0}/Map{1}.mul", (object)this.ProjectPath.Text, (object)num15); this.iLogger.LogMessage(str2); FileStream fileStream1 = new FileStream(str2, FileMode.Create); BinaryWriter i_MapFile = new BinaryWriter((Stream)fileStream1); int num16 = 0; int num17 = num5; int num18 = num16; while (num18 <= num17) { int num3 = 0; int num4 = num6; int num13 = num3; while (num13 <= num4) { i_MapFile.Write(num14); int num19 = 0; do { int num20 = 0; do { mapCellArray[checked (num18 + num20), checked (num13 + num19)].WriteMapMul(i_MapFile); checked { ++num20; } }while (num20 <= 7); checked { ++num19; } }while (num19 <= 7); checked { num13 += 8; } } checked { num18 += 8; } } i_MapFile.Close(); fileStream1.Close(); string str3 = string.Format("{0}/StaIdx{1}.mul", (object)this.ProjectPath.Text, (object)num15); FileStream fileStream2 = new FileStream(str3, FileMode.Create); this.iLogger.LogMessage(str3); string str4 = string.Format("{0}/Statics{1}.mul", (object)this.ProjectPath.Text, (object)num15); FileStream fileStream3 = new FileStream(str4, FileMode.Create); this.iLogger.LogMessage(str4); BinaryWriter binaryWriter = new BinaryWriter((Stream)fileStream2); BinaryWriter i_StaticFile = new BinaryWriter((Stream)fileStream3); int num21 = 0; int num22 = num7; int index8 = num21; while (index8 <= num22) { int num3 = 0; int num4 = num8; int index2 = num3; while (index2 <= num4) { int num13 = 0; int num19 = checked ((int)i_StaticFile.BaseStream.Position); try { foreach (StaticCell staticCell in StaticMap[index8, index2]) { staticCell.Write(i_StaticFile); checked { num13 += 7; } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } if (num13 == 0) { num19 = -1; } binaryWriter.Write(num19); binaryWriter.Write(num13); binaryWriter.Write(num14); checked { ++index2; } } checked { ++index8; } } i_StaticFile.Close(); binaryWriter.Close(); fileStream3.Close(); fileStream2.Close(); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } }
public Transition(string iDescription, string iHashKey, ClsTerrain iGroupA, ClsTerrain iGroupB, MapTileCollection iMapTiles, StaticTileCollection iStaticTiles) { this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = null; this.m_File = null; this.m_Description = iDescription; byte b = 0; do { string sLeft = Strings.Mid(iHashKey, (int)checked (b + 1), 1); if (StringType.StrCmp(sLeft, "A", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupA.GroupID)); } else { if (StringType.StrCmp(sLeft, "B", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupB.GroupID)); } } b += 1; }while (b <= 8); if (iMapTiles != null) { IEnumerator enumerator = iMapTiles.GetEnumerator(); try { while (enumerator.MoveNext()) { MapTile value = (MapTile)enumerator.Current; this.m_MapTiles.Add(value); } } finally { if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } } if (iStaticTiles != null) { IEnumerator enumerator2 = iStaticTiles.GetEnumerator(); try { while (enumerator2.MoveNext()) { StaticTile value2 = (StaticTile)enumerator2.Current; this.m_StaticTiles.Add(value2); } } finally { if (enumerator2 is IDisposable) { ((IDisposable)enumerator2).Dispose(); } } } }
private void MakeTerrainAndAltitudeBitmaps(object sender, EventArgs e) { byte altID; byte groupID; MapInfo selectedItem = (MapInfo)this.ComboBox2.SelectedItem; if (selectedItem == null) { this.iLogger.LogMessage("Error: Select a Map Type."); } else if (StringType.StrCmp(this.ProjectName.Text, string.Empty, false) != 0) { string str = string.Format("{0}/{1}/Map{2}", this.ProjectPath.Text, this.ProjectName.Text, selectedItem.MapNumber); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } if (this.ComboBox1.SelectedItem != null) { ClsTerrain clsTerrain = (ClsTerrain)this.ComboBox1.SelectedItem; groupID = checked ((byte)clsTerrain.GroupID); altID = clsTerrain.AltID; } else { groupID = 9; altID = 66; } this.iLogger.LogMessage("Creating Terrain Image."); this.iLogger.StartTask(); try { string str1 = string.Format("{0}/{1}", str, this.TerrainFile.Text); Bitmap palette = this.MakeTerrainMap(selectedItem.XSize, selectedItem.YSize, groupID, this.Dungeon.Checked); palette.Palette = this.iTerrain.GetPalette(); palette.Save(str1, ImageFormat.Bmp); palette.Dispose(); } catch (Exception exception) { ProjectData.SetProjectError(exception); this.iLogger.LogMessage("Error: Problem creating Terrain Image."); ProjectData.ClearProjectError(); } //this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Creating Altitude Image."); this.iLogger.StartTask(); try { string str2 = string.Format("{0}/{1}", str, this.AltitudeFile.Text); Bitmap altPalette = this.MakeAltMap(selectedItem.XSize, selectedItem.YSize, altID, this.Dungeon.Checked); altPalette.Palette = this.iAltitude.GetAltPalette(); altPalette.Save(str2, ImageFormat.Bmp); altPalette.Dispose(); } catch (Exception exception2) { ProjectData.SetProjectError(exception2); Exception exception1 = exception2; this.iLogger.LogMessage("Error: Problem creating Altitude Image."); this.iLogger.LogMessage(exception1.Message); ProjectData.ClearProjectError(); } //this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } else { this.iLogger.LogMessage("Error: Enter a project Name."); } }
public Transition(string iDescription, string iHashKey, ClsTerrain iGroupA, ClsTerrain iGroupB, MapTileCollection iMapTiles, StaticTileCollection iStaticTiles) { this.m_HashKey = new HashKeyCollection(); this.m_StaticTiles = new StaticTileCollection(); this.m_MapTiles = new MapTileCollection(); this.m_RandomTiles = (RandomStatics)null; this.m_File = (string)null; this.m_Description = iDescription; byte num = (byte)0; do { string sLeft = Strings.Mid(iHashKey, checked ((int)num + 1), 1); if (StringType.StrCmp(sLeft, "A", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupA.GroupID)); } else if (StringType.StrCmp(sLeft, "B", false) == 0) { this.m_HashKey.Add(new HashKey(iGroupB.GroupID)); } ++num; }while ((int)num <= 8); if (iMapTiles != null) { try { foreach (MapTile mapTile in (CollectionBase)iMapTiles) { this.m_MapTiles.Add(mapTile); } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } } if (iStaticTiles == null) { return; } try { foreach (StaticTile staticTile in (CollectionBase)iStaticTiles) { this.m_StaticTiles.Add(staticTile); } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { ((IDisposable)enumerator).Dispose(); } } }