Example #1
0
 void houseLayerSort()
 {
     for (int i = 0; i < m_giList.Count; i++)
     {
         for (int j = i + 1; j < m_giList.Count; j++)
         {
             if (m_giList[i].hypeLength > m_giList[j].hypeLength)
             {
                 if (m_giList[i].mesh_list[0].y < m_giList[j].mesh_list[0].y)
                 {
                     swap(i, j);
                 }
             }
             else
             {
                 if (m_giList[i].mesh_list[0].y <= m_giList[j].mesh_list[0].y)
                 {
                     HouseData hd = MapBasicData.GetHouseData(m_giList[i].gt);
                     float     w  = hd.width;
                     float     h  = hd.height - 0.4f;
                     if (m_giList[i].mesh_list[0].x + w >= m_giList[j].mesh_list[0].x &&
                         m_giList[i].mesh_list[0].y + h >= m_giList[j].mesh_list[0].y)
                     {
                         swap(i, j);
                     }
                 }
             }
         }
     }
 }
Example #2
0
    /// <summary>
    /// 初始化数据
    /// @param HouseData 房子的基本数据
    /// @param GoodsTYpe 建筑的基本类型
    /// @param name      建筑名字
    /// @param nId       建筑的id
    /// </summary>
    public void InitData(string name, int id, BuildManager bm = null)
    {
        gt = MapBasicData.GetHouseType(name);
        HouseData hd = MapBasicData.GetHouseData(gt);

        raw       = hd.raw;
        col       = hd.col;
        width     = hd.width;
        height    = hd.height;
        oldMesh   = hd.srcMesh;
        mesh_list = new Vector2[raw * col];
        obj_list  = new GameObject[raw * col];
        nId       = id;

        InitMeshList();
        m_buildManager = bm;
        transform.GetComponent <Renderer>().sortingOrder = m_buildManager.GoodsList.Count;
        m_buildManager.AddGoods(nId, gt, gameObject, mesh_list, oldMesh, name);
    }