public void clearSpilth(bool clearNotUsed) { //清除未使用的单元 if (clearNotUsed) { for (int i = 0; i < this.Count(); i++) { AntetypeFolder folder = this[i]; for (int j = 0; j < folder.Count(); j++) { if (folder[i].getUsedTime() <= 0) { folder.RemoveAt(j); j--; } } } } //清除重复的单元 for (int i = 0; i < GetSonsCount(); i++) { Antetype srcElement = (Antetype)getAntetypeBySumID(i); for (int j = i + 1; j < GetSonsCount(); j++) { Antetype compElement = (Antetype)getAntetypeBySumID(j); if (compElement.equalsAnteType(srcElement))//重复的单元 { //转移引用 for (int k = 0; k < mapsManager.getElementCount(); k++) { MapElement map = mapsManager.getElement(k); for (int x = 0; x < map.getMapW(); x++) { for (int y = 0; y < map.getMapH(); y++) { MapTileElement mapTile = map.getTile(x, y); for (int z = 0; z < mapTile.tile_objectList.Count; z++) { if (mapTile.tile_objectList[z] != null && mapTile.tile_objectList[z].antetype != null && mapTile.tile_objectList[z].antetype.Equals(compElement)) { mapTile.tile_objectList[z].antetype = srcElement; } } if (mapTile.tile_object_mask != null && mapTile.tile_object_mask.antetype != null && mapTile.tile_object_mask.antetype.Equals(compElement)) { mapTile.tile_object_mask.antetype = srcElement; } if (mapTile.tile_object_bg != null && mapTile.tile_object_bg.antetype != null && mapTile.tile_object_bg.antetype.Equals(compElement)) { mapTile.tile_object_bg.antetype = srcElement; } } } } //删除重复的单元 compElement.getFolder().Remove(compElement); j--; } } } }