コード例 #1
0
 public void combine(TilePhysicsManager src_Manager, ArrayList mapsID)
 {
     for (int i = 0; i < src_Manager.getElementCount(); i++)
     {
         TilePhysicsElement srcTile = src_Manager.getElement(i);
         //检查是否被源关卡所用到
         bool usingBySrc = false;
         for (int j = 0; j < mapsID.Count; j++)
         {
             MapElement map = src_Manager.mapsManager.getElement((int)mapsID[j]);
             if (map.getTileUsedTime(srcTile) > 0)
             {
                 usingBySrc = true;
                 break;
             }
         }
         if (!usingBySrc)
         {
             continue;
         }
         //进入合并
         TilePhysicsElement newTile = null;
         for (int j = 0; j < getElementCount(); j++)
         {
             TilePhysicsElement localTile = getElement(j);
             if (localTile.equlasTo(srcTile))
             {
                 newTile = localTile;
                 break;
             }
         }
         if (newTile == null)
         {
             newTile = srcTile.clone(this);
         }
         if (!PhyTilesList.Contains(newTile))
         {
             this.addElement(newTile);
         }
         //转移引用
         for (int k = 0; k < src_Manager.mapsManager.getElementCount(); k++)
         {
             MapElement map = src_Manager.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);
                     if (mapTile.tile_physic != null && mapTile.tile_physic.Equals(srcTile))
                     {
                         mapTile.tile_physic = newTile;
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        public TilePhysicsManager cloneForExport(MapsManager mapsManagerT)
        {
            TilePhysicsManager newInstance = new TilePhysicsManager(mapsManagerT);

            for (int i = 0; i < getElementCount(); i++)
            {
                TilePhysicsElement elementI = getElement(i);
                newInstance.addElement(elementI.clone(newInstance));
            }
            return(newInstance);
        }