示例#1
0
 /// <summary>
 /// Inits the boxs.
 /// </summary>
 /// <param name="downRow">Down row. 从多少行开始</param>
 /// <param name="numRow">Number row. 往上加载多少行</param>
 public void InitBoxs(int downRow, int numRow)
 {
     lock (_lock) {
         topRow = downRow - numRow + 1;
         if (topRow == 0)
         {
             //加载banner和boss
             GameObject banner = Instantiate(m_resource.GetResFromName(ConstValue.GAME_T_BANNER),
                                             Vector3.zero,
                                             Quaternion.identity) as GameObject;
             banner.transform.parent   = transform;
             banner.transform.position = new Vector3(0, GetTopPosition() + ConstValue.TopBannerHeight / 2, 0);
             if (ConstValue.currentLevel.boss > 0)
             {
                 boss = Instantiate(m_resource.GetResFromName(ConstValue.bosses[ConstValue.currentLevel.boss]),
                                    Vector3.zero, Quaternion.identity) as GameObject;
                 boss.transform.parent   = transform;
                 boss.transform.position = new Vector3(0, banner.transform.position.y + ConstValue.BossHeight / 2, 0);
                 InvokeRepeating("BossFight", 1f, 3f);
             }
         }
         for (int i = downRow; i >= topRow; i--)
         {
             for (int j = 0; j < m_level.width; j++)
             {
                 int index = i * m_level.width + j;
                 Debug.Log(downRow + "," + topRow + "," + index);
                 if (m_level.data[index] != 0)
                 {
                     GameObject boxClone = Instantiate(m_resource.GetResFromName(ConstValue.GAME_LIAN_PRE + m_level.data[index]),
                                                       GetPosFromXY(j, i),
                                                       Quaternion.identity) as GameObject;
                     boxClone.transform.parent    = transform;
                     boxClone.transform.position += transform.position;
                     ComBox cb = boxClone.GetComponent <ComBox>();
                     cb.index         = m_level.data[index];
                     cb.ice           = m_level.meta[index];
                     cb.x             = j;
                     cb.y             = i;
                     cb.fall          = false;
                     boxManager[j, i] = cb;
                 }
             }
         }
         bottomRow = boxManager.GetBottomNullRow();
     }
 }