コード例 #1
0
        void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, int tileCoordX, int tileCoordY, bool updateBuffer = true)
        {
            int flattenedTileIndex    = FlattenedTileIndex(tileCoordX, tileCoordY);
            CCTileGidAndFlags tileGID = TileGIDAndFlagsArray[flattenedTileIndex];

            if (drawBufferManager.TileSetInfo.FirstGid <= tileGID.Gid && drawBufferManager.TileSetInfo.LastGid >= tileGID.Gid || tileGID.Gid == 0)
            {
                CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedTileIndex);
                drawBuffer.UpdateQuad(flattenedTileIndex, ref tileGID, updateBuffer);
            }
        }
コード例 #2
0
        CCTileMapDrawBufferManager InitialiseDrawBuffer(CCTileSetInfo tileSetInfo)
        {
            CCTileMapDrawBufferManager drawBufferManager = new CCTileMapDrawBufferManager(LayerSize.Row, LayerSize.Column, this, tileSetInfo);

            for (int y = 0; y < LayerSize.Row; y++)
            {
                for (int x = 0; x < LayerSize.Column; x++)
                {
                    UpdateQuadAt(drawBufferManager, x, y, false);
                }
            }
            drawBufferManager.UpdateQuadBuffers();
            return(drawBufferManager);
        }
コード例 #3
0
        public void SetTileGID(CCTileGidAndFlags gidAndFlags, CCTileMapCoordinates tileCoords)
        {
            if (gidAndFlags.Gid == 0)
            {
                RemoveTile(tileCoords);
                return;
            }

            if (AreValidTileCoordinates(tileCoords) == false)
            {
                Debug.Assert(false, String.Format("CCTileMapLayer: Invalid tile coordinates row: {0} column: {1}",
                                                  tileCoords.Row, tileCoords.Column));
                return;
            }

            CCTileGidAndFlags currentGID = TileGIDAndFlags(tileCoords);

            if (currentGID == gidAndFlags)
            {
                return;
            }
            CCTileMapDrawBufferManager drawBufferManager = GetDrawBufferManagerByGid(gidAndFlags.Gid);

            if (drawBufferManager == null)
            {
                foreach (CCTileSetInfo tileSetInfo in mapInfo.Tilesets)
                {
                    if (tileSetInfo.FirstGid <= gidAndFlags.Gid && tileSetInfo.LastGid >= gidAndFlags.Gid)
                    {
                        drawBufferManager = InitialiseDrawBuffer(tileSetInfo);
                        break;
                    }
                }
                if (drawBufferManagers == null)
                {
                    Debug.Assert(false, String.Format("CCTileMapLayer: Invalid tile grid id: {0}", gidAndFlags.Gid));
                    return;
                }

                drawBufferManagers.Add(drawBufferManager);
                visibleTileRangeDirty = true;
            }
            SetBatchRenderedTileGID(tileCoords.Column, tileCoords.Row, gidAndFlags);
        }
コード例 #4
0
ファイル: CCTileMapLayer.cs プロジェクト: zhuruvl/CocosSharp
        void InitialiseDrawBuffers()
        {
            drawBufferManager = new CCTileMapDrawBufferManager(LayerSize.Row, LayerSize.Column);

            // Initialize the QuadsVertexBuffers
            if (tileSetTexture.ContentSizeInPixels != CCSize.Zero)
            {
                for (int y = 0; y < LayerSize.Row; y++)
                {
                    for (int x = 0; x < LayerSize.Column; x++)
                    {
                        UpdateQuadAt(x, y, false);
                    }
                }
            }

            // Initialise the IndexBuffers
            var numOfTiles = (int)NumberOfTiles;

            for (int tileIndex = 0; tileIndex < numOfTiles; tileIndex++)
            {
                var buffer  = drawBufferManager.GetDrawBufferAtIndex(tileIndex);
                var indices = buffer.IndexBuffer.Data;

                int quadVertIndex     = (tileIndex - buffer.TileStartIndex) * NumOfCornersPerQuad;
                int indexBufferOffset = (tileIndex - buffer.TileStartIndex) * NumOfVerticesPerQuad;

                indices[indexBufferOffset + 0] = (short)(quadVertIndex + 0);
                indices[indexBufferOffset + 1] = (short)(quadVertIndex + 1);
                indices[indexBufferOffset + 2] = (short)(quadVertIndex + 2);
                indices[indexBufferOffset + 3] = (short)(quadVertIndex + 3);
                indices[indexBufferOffset + 4] = (short)(quadVertIndex + 2);
                indices[indexBufferOffset + 5] = (short)(quadVertIndex + 1);
            }

            drawBufferManager.UpdateBuffers();
        }
コード例 #5
0
 void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, CCTileMapCoordinates tileCoords, bool updateBuffer = true)
 {
     UpdateQuadAt(drawBufferManager, tileCoords.Column, tileCoords.Row, updateBuffer);
 }
コード例 #6
0
 void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, int tileCoordX, int tileCoordY, bool updateBuffer = true)
 {
     int flattenedTileIndex = FlattenedTileIndex(tileCoordX, tileCoordY);
     CCTileGidAndFlags tileGID = TileGIDAndFlagsArray[flattenedTileIndex];
     if (drawBufferManager.TileSetInfo.FirstGid <= tileGID.Gid && drawBufferManager.TileSetInfo.LastGid >= tileGID.Gid || tileGID.Gid == 0)
     {
         CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedTileIndex);
         drawBuffer.UpdateQuad(flattenedTileIndex, ref tileGID, updateBuffer);
     }
 }
コード例 #7
0
 void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, CCTileMapCoordinates tileCoords, bool updateBuffer = true)
 {
     UpdateQuadAt(drawBufferManager, tileCoords.Column, tileCoords.Row, updateBuffer);
 }
コード例 #8
0
        CCTileMapDrawBufferManager InitialiseDrawBuffer(CCTileSetInfo tileSetInfo)
        {
            CCTileMapDrawBufferManager drawBufferManager = new CCTileMapDrawBufferManager(LayerSize.Row, LayerSize.Column, this, tileSetInfo);

            for (int y = 0; y < LayerSize.Row; y++)
            {
                for (int x = 0; x < LayerSize.Column; x++)
                {
                    UpdateQuadAt(drawBufferManager, x, y, false);
                }
            }
            drawBufferManager.UpdateQuadBuffers();
            return drawBufferManager;
        }