コード例 #1
0
ファイル: Chunk.cs プロジェクト: JBillingsley/eecs-390-rts
    private int[] makeCollisionIndices(int cx, int cy)
    {
        List <int> indices = new List <int>();
        int        i       = 0;
        int        off     = 4 * map.chunkSize * map.chunkSize;
        IVector2   v;

        for (int y = 0; y < map.chunkSize; y++)
        {
            for (int x = 0; x < map.chunkSize; x++, i++)
            {
                v = new IVector2(cx * map.chunkSize + x, cy * map.chunkSize + y);
                TileSpec tile = map.getForeground(v);
                if (tile.solid)
                {
                    tile.getRender(Map.hash(v.x, v.y)).getCollisionIndices(4 * i, off, (byte)~map.getRenderContext(v), indices);
                }
            }
        }
        return(indices.ToArray());
    }
コード例 #2
0
ファイル: Chunk.cs プロジェクト: JBillingsley/eecs-390-rts
    private Vector2[] makeTextures(int cx, int cy)
    {
        Vector2[] textures = new Vector2[8 * map.chunkSize * map.chunkSize];
        float     ix       = 1f / map.tileset.width;
        float     iy       = 1f / map.tileset.height;
        int       i        = 0;

        for (int y = 0; y < map.chunkSize; y++)
        {
            for (int x = 0; x < map.chunkSize; x++)
            {
                IVector2  v     = new IVector2(cx * map.chunkSize + x, cy * map.chunkSize + y);
                TileSpec  tile  = map.getRenderForeground(v);
                int       texID = tile.getRender(Map.hash(v.x, v.y)).getTexID(map.getRenderContext(v));
                Vector2[] tex   = map.tileset.getTex(texID);
                textures [i * 4]     = tex[0];
                textures [i * 4 + 1] = tex[1];
                textures [i * 4 + 2] = tex[2];
                textures [i * 4 + 3] = tex[3];
                i++;
            }
        }
        for (int y = 0; y < map.chunkSize; y++)
        {
            for (int x = 0; x < map.chunkSize; x++)
            {
                IVector2  v     = new IVector2(cx * map.chunkSize + x, cy * map.chunkSize + y);
                TileSpec  tile  = map.getRenderBackground(v);
                int       texID = tile.getRender(Map.hash(v.x, v.y)).getTexID(map.getBackgroundRenderContext(v));
                Vector2[] tex   = map.tileset.getTex(texID);
                textures [i * 4]     = tex[0];
                textures [i * 4 + 1] = tex[1];
                textures [i * 4 + 2] = tex[2];
                textures [i * 4 + 3] = tex[3];
                i++;
            }
        }
        return(textures);
    }