Example #1
0
    bool GetAlphaTexInfo(int w, int h, out AlphaTexInfo info)
    {
        if (!m_alphaTexInfoIsInit[w, h])
        {
            if (!m_terrainInfoAsset.TerrainAlphaList[w * m_splitMap_X + h])
            {
                m_alphaTexInfoIsInit[w, h] = true;
                info = null;
                return(false);
            }
            string name = string.Format(m_alphaTexName, w, h);
#if TILEMAP_TEST
            var alphaTex = AssetDatabase.LoadAssetAtPath <AlphaTexInfo>(string.Format("{0}/{1}.asset", m_alphaTexPath, name));
            if (alphaTex != null)
            {
                alphaTex.Init();
                m_alphaTexInfo[w, h] = alphaTex;
            }
            m_alphaTexInfoIsInit[w, h] = true;
#else
            LoadManager.Instance.LoadAsset(m_alphaTexPath, name, "asset", typeof(AlphaTexInfo), (data) =>
            {
                var alphaTex = data as AlphaTexInfo;
                if (alphaTex != null)
                {
                    alphaTex.Init();
                    m_alphaTexInfo[w, h] = alphaTex;
                }
                m_alphaTexInfoIsInit[w, h] = true;
            }, false, false, false, m_fullPath);
#endif
        }
        info = m_alphaTexInfo[w, h];
        return(m_terrainInfoAsset.TerrainAlphaList[w * m_splitMap_X + h]);
    }
Example #2
0
    protected void CheckVisibleAlphaTex(int _pos_x, int _pos_z, int i, int j)
    {
        if (_pos_x >= m_map_W || _pos_x < 0 || _pos_z >= m_map_H || _pos_z < 0)
        {
            m_needVisibleAlphaTex[i, j].isShow = false;
            SetVisibleAlphaTexNUll(i, j);
            return;
        }
        int _index_x = _pos_x / m_tilemap_W;
        int _index_z = _pos_z / m_tilemap_H;

        AlphaTexInfo _AlphaTexInfo      = null;
        bool         hasAlphaTexMapInfo = GetAlphaTexInfo(_index_x, _index_z, out _AlphaTexInfo);

        int map_index = _pos_z * m_map_W + _pos_x;

        //透贴
        bool hasAlphaTexObj = false;

        if (hasAlphaTexMapInfo)
        {
            hasAlphaTexObj = _AlphaTexInfo.terrainAlphaDic.TryGetValue(map_index, out alphaTex_s);
            hasAlphaTexObj = hasAlphaTexObj ? alphaTex_s.level <= m_level : hasAlphaTexObj;
        }
        if (hasAlphaTexObj)
        {
            m_needVisibleAlphaTex[i, j].isShow   = true;
            m_needVisibleAlphaTex[i, j].itemName = alphaTex_s.objName;
        }
        else
        {
            m_needVisibleAlphaTex[i, j].isShow = false;
            SetVisibleAlphaTexNUll(i, j);
        }
    }