Exemplo n.º 1
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public WebMapTile Grab(WebMapTileSlot slot)
    {
        WebMapTile tile = null;

        if (slot != null)
        {
            for (int entry = m_size - 1; entry >= 0; --entry)
            {
                if (m_entries[entry].location.coordGrid == slot.coordGrid)
                {
                    tile = m_entries[entry];

                    m_entries[entry] = m_entries[--m_size];

                    break;
                }
            }

            if (tile == null)
            {
                tile = (m_size > 0) ? m_entries[--m_size] : null;
            }

            if (tile != null)
            {
                slot.Bind(tile);

                tile.pool = null;

                tile.gameObject.SetActive(true);
            }
        }

        return(tile);
    }
Exemplo n.º 2
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void Release(WebMapTile tile)
    {
        if (tile == null)
        {
            return;
        }

        if (tile.pool != null)
        {
            return;
        }

        if (m_size >= m_entries.Length)
        {
            return;
        }

        m_entries[m_size++] = tile;

        tile.pool = this;


        if (tile.slot != null)
        {
            tile.slot.Unbind();
        }

        tile.gameObject.SetActive(false);
    }
Exemplo n.º 3
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void LoadMaps()
    {
        UnityEngine.Plane[] planes = GeometryUtility.CalculateFrustumPlanes(m_camera);

        Bounds bounds = new Bounds(Vector3.zero, new Vector3(m_tilesSize, 0.0f, m_tilesSize));

        for (int slot = 0; slot < m_nbSlotsUsed; ++slot)
        {
            WebMapTile Tile = m_slotsUsed[m_loadSeq[slot]].tile;

            if (Tile != null)
            {
                bounds.center = Tile.position;

                if (GeometryUtility.TestPlanesAABB(planes, bounds))
                {
                    Tile.SubmitLoadingRequest(m_loader, m_loadingIcon);
                }
                else
                {
                    Tile.CancelLoadingRequest();
                }
            }
        }
    }
Exemplo n.º 4
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public WebMapTile CreateTile(string name, GameObject mdl, Quaternion q, Transform parent, float size)
    {
        GameObject obj = (mdl != null) ? GameObject.Instantiate(mdl, Vector3.zero, q, (parent != null) ? parent.transform : null) as GameObject : null;

        WebMapTile tile = (obj != null) ? obj.GetComponent <WebMapTile>() : null;

        if (tile != null)
        {
            tile.Setup(name, size);
        }

        return(tile);
    }
Exemplo n.º 5
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void Bind(WebMapTile tile)
    {
        if (m_tile != tile)
        {
            if (tile != null)
            {
                if (tile.slot != null)
                {
                    tile.slot.tile = null;
                }
                tile.slot = this;
            }

            if (m_tile != null)
            {
                m_tile.slot = null;
            }

            m_tile = tile;
        }
    }
Exemplo n.º 6
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void FlushTextures()
    {
        if (m_loader != null)
        {
            m_loader.Cancel(); m_loader.FlushCache();
        }

        for (int entry = 0; entry < m_pool.size; ++entry)
        {
            WebMapTile tile = m_pool     [entry];      if (tile != null)
            {
                tile.FlushTexture();
            }
        }

        for (int slot = 0; slot < m_nbSlotsUsed; ++slot)
        {
            WebMapTile tile = m_slotsUsed[slot].tile; if (tile != null)
            {
                tile.FlushTexture();
            }
        }
    }