示例#1
0
        //public void SetCellIndex(int x, int y, int Collided)
        //{
        //    if ((y >= 0) && (y < LayerHeightinTiles) &&
        //        (x >= 0) && (x <= LayerWidthinTiles))
        //        layer[y, x] = Index;
        //}


        private void modifyCollisionMap()
        {
            int maxWidth  = -1;
            int maxHeight = -1;

            foreach (TileLayer layer in Layers)
            {
                if (layer.LayerWidthinTiles > maxWidth)
                {
                    maxWidth = layer.LayerWidthinTiles;
                }
                if (layer.LayerHeightinTiles > maxHeight)
                {
                    maxHeight = layer.LayerHeightinTiles;
                }
            }


            if (Layers.Count > 0)
            {
                if (CollisionMap != null)
                {
                    int[,] TempMap = (int[, ])CollisionMap.Clone();

                    CollisionMap = new int[maxWidth, maxHeight];

                    for (int x = 0; x < Math.Min(maxWidth, TempMap.GetLength(0)); x++)
                    {
                        for (int y = 0; y < Math.Min(maxHeight, TempMap.GetLength(1)); y++)
                        {
                            CollisionMap[x, y] = TempMap[x, y];
                        }
                    }
                }
                else
                {
                    CollisionMap = new int[maxWidth, maxHeight];
                }
            }
            else
            {
                CollisionMap = null;
            }
        }