Exemplo n.º 1
0
 public void SetUI()
 {
     string [] l = m_shape.Split(',');
     m_height = l.Length;
     for (int i = 0; i < l.Length; i++)
     {
         for (int j = 0; j < l[i].Length; j++)
         {
             GameObject go = NDLoad.LoadWndItem("ShipModelItem", TableList[i].transform);
             if (go != null)
             {
                 ShipModelItem item = go.GetComponent <ShipModelItem>();
                 if (item != null)
                 {
                     if (l[i][j] == '1')
                     {
                         item.SetSize(GetSingleWidth(), GetSingleWidth());
                     }
                     //有可能是甲板层.
                     else if (l[i][j] == '0')
                     {
                         //如果他的下一层不为0则是甲板层.
                         bool deck = BattleEnvironmentM.CheckIsDeckGrid(l, i, j);
                         item.SetSize(GetSingleWidth(), GetSingleWidth(), deck);
                         item.gameObject.SetActive(deck);
                     }
                 }
             }
         }
         TableList[i].Reposition();
         TableList[i].repositionNow = true;
     }
     StartCoroutine(RepositionTable(1));
 }
Exemplo n.º 2
0
    /// <summary>
    /// 新增房间/炮弹兵 获取可放置的格子位置
    /// </summary>
    /// <returns></returns>
    public static bool GetBornPos(CanvasCore core, ref Int2 gridPos)
    {
        if (core == null)
        {
            return(false);
        }

        /*
         * List<RoomGrid> ListCanPut = new List<RoomGrid>();
         * if (core.m_type == ShipBuildType.BuildRoom&&core.IsDeckRoom)
         *
         *      ListCanPut = RoomMap.GetCanPutBuildIdleRoom ();
         * else {
         *      ListCanPut = RoomMap.GetCanPutSoldierIdleRoom();
         * };
         */
        List <Int2> posListCanPutRoomGrid = RoomMap.GetCanPutArea(core.m_type, core.IsDeckRoom);

        foreach (Int2 pos in posListCanPutRoomGrid)
        {
            Int2 posMap = RoomMap.GetMapGrid(pos);
            //if(core.m_type == ShipBuildType.BuildRoom)
            //{
            //	pos = grid.BuildPos;
            //}
            //else pos = grid.SoldierPos;
            if (CheckCanPut(core, posMap))
            {
                gridPos = posMap;
                bool isDeck = BattleEnvironmentM.CheckIsDeckGrid(gridPos);
                if (!core.IsDeckRoom && isDeck)
                {
                    return(false);
                }
                if (core.m_type == ShipBuildType.Soldier)
                {
                    gridPos.Unit += 1;
                }

                return(true);
            }
        }
        List <RoomGrid> ListCanPut = RoomMap.GetAllRoomGrid();

        foreach (RoomGrid grid in ListCanPut)
        {
            Int2 pos = Int2.zero;
            if (core.m_type == ShipBuildType.BuildRoom)
            {
                pos = grid.BuildPos;
            }
            else
            {
                pos = grid.SoldierPos;
            }
            if (CheckCanTempPut(core, pos))
            {
                gridPos = pos;
                return(true);
            }
        }
        return(false);
    }