public TileGfxContainer(TileGfxManager tileGfxManagerT, String nameT) : base(tileGfxManagerT.mapsManager.form_Main) { name = "默认风格"; parent = tileGfxManagerT; if (nameT != null) { name = nameT; } }
public SmallDialog_NewMap(String text, TileGfxManager tileGfxManagerT, bool create) { InitializeComponent(); tileGfxManager = tileGfxManagerT; comboBox_Style.Items.Clear(); for (int i = 0; i < tileGfxManager.Count(); i++) { comboBox_Style.Items.Add(tileGfxManager[i].name); } byte expFlag = 55; if (!create) { textBox_mapName.Text = element.getName(); numericUpDown_TileW.Value = element.getTileW(); numericUpDown_TileH.Value = element.getTileH(); numericUpDown_MapW.Value = element.getMapW(); numericUpDown_MapH.Value = element.getMapH(); comboBox_mapType.SelectedIndex = element.getMapType() - MapElement.TYPE_COMMON; comboBox_Style.SelectedIndex = element.tileGfxContainer.GetID(); comboBox_Style.Enabled = false; panel_MapColor.BackColor = GraphicsUtil.getColor(element.getColor()); //地图类型 if (element.getMapType() == MapElement.TYPE_COMMON) { comboBox_mapType.SelectedIndex = 0; } else if (element.getMapType() == MapElement.TYPE_45) { comboBox_mapType.SelectedIndex = 1; } //地图导出标记 expFlag = element.getMapExpFlag(); } else { comboBox_Style.Enabled = true; comboBox_mapType.SelectedIndex = 0; comboBox_Style.SelectedIndex = 0; } //地图导出标记 for (int i = 0; i < checkedListBox_Level.Items.Count; i++) { if ((expFlag & (1 << i)) != 0) { checkedListBox_Level.SetItemChecked(i, true); } else { checkedListBox_Level.SetItemChecked(i, false); } } this.Text = text; }
//复制自己 public TileGfxManager clone() { TileGfxManager newInstance = new TileGfxManager(mapsManager, imagesManager); newInstance.RemoveAt(0); for (short i = 0; i < this.Count(); i++) { TileGfxContainer gfxContainer = this[i]; TileGfxContainer newGfxContainer = gfxContainer.clone(); newInstance.Add(newGfxContainer); } return(newInstance); }
//复制自己 public TileGfxManager cloneForExport(MapsManager mapsManagerT, MImgsManager imagesManagerT) { TileGfxManager newInstance = new TileGfxManager(mapsManagerT, imagesManagerT); newInstance.RemoveAt(0); for (short i = 0; i < this.Count(); i++) { TileGfxContainer gfxContainer = this[i]; TileGfxContainer newGfxContainer = gfxContainer.cloneForExceport(mapsManagerT, imagesManagerT); newInstance.Add(newGfxContainer); } return(newInstance); }
//合并 public String combine(TileGfxManager src_Manager, ArrayList mapsID) { String errorString = null; for (int srcConIndex = 0; srcConIndex < src_Manager.Count(); srcConIndex++) { TileGfxContainer srcContainer = src_Manager[srcConIndex]; //检查是否被源关卡所用到 bool usingBySrc = false; for (int j = 0; j < mapsID.Count; j++) { MapElement map = src_Manager.mapsManager[(int)mapsID[j]]; if (map.tileGfxContainer.Equals(srcContainer)) { usingBySrc = true; break; } } if (!usingBySrc) { continue; } TileGfxContainer destContainer = null; //检查重复的图形容器 for (int localConIndex = 0; localConIndex < Count(); localConIndex++) { TileGfxContainer localContainer = this[localConIndex]; if (localContainer.name.Equals(srcContainer.name)) { destContainer = localContainer; break; } } if (destContainer == null) { destContainer = new TileGfxContainer(this, srcContainer.name); this.Add(destContainer); } //转移地图中的图形容器的引用 for (int k = 0; k < src_Manager.mapsManager.Count(); k++) { MapElement map = src_Manager.mapsManager[k]; if (map.tileGfxContainer.Equals(srcContainer)) { map.tileGfxContainer = destContainer; } } //向目标容器添加图形元素 for (int elementIndex = 0; elementIndex < srcContainer.Count(); elementIndex++) { TileGfxElement srcElement = (TileGfxElement)srcContainer[elementIndex]; TileGfxElement newElement = null; //检查重复的图形元素 if (!destContainer.Equals(srcContainer)) { for (int j = 0; j < destContainer.Count(); j++) { TileGfxElement localClip = (TileGfxElement)destContainer[j]; if (localClip.equalsClip(srcElement)) { newElement = localClip; break; } } } if (newElement == null) { newElement = srcElement.Clone(destContainer); } if (!destContainer.Contains(newElement)) { if (!destContainer.Add(newElement)) { errorString = "合并图形容器“" + srcContainer.name + "”时,图形元素数量超出65536。"; break; } } //转移地图中的块的引用 for (int k = 0; k < src_Manager.mapsManager.Count(); k++) { MapElement map = src_Manager.mapsManager[k]; for (int x = 0; x < map.getMapW(); x++) { for (int y = 0; y < map.getMapH(); y++) { MapTileElement mapTile = map.getTile(x, y); if (mapTile.tile_gfx_ground != null && mapTile.tile_gfx_ground.tileGfxElement != null && mapTile.tile_gfx_ground.tileGfxElement.Equals(srcElement)) { mapTile.tile_gfx_ground.tileGfxElement = newElement; } if (mapTile.tile_gfx_surface != null && mapTile.tile_gfx_surface.tileGfxElement != null && mapTile.tile_gfx_surface.tileGfxElement.Equals(srcElement)) { mapTile.tile_gfx_surface.tileGfxElement = newElement; } } } } } if (errorString != null) { break; } } return(errorString); }
public TileGfxContainer(TileGfxManager tileGfxManagerT) : base(tileGfxManagerT.mapsManager.form_Main) { name = "默认风格"; parent = tileGfxManagerT; }