Пример #1
0
    /// <summary>
    /// 获取可放置区域
    /// </summary>
    public static List <Int2> GetCanPutArea(ShipBuildType type, bool bDeckRoom)
    {
        List <Int2> l = new List <Int2>();

        if (m_PutRoom.Count == 0)         //一个都未摆设,则所有区域都可以摆设了。
        {
            List <RoomGrid> ll = GetAllRoomGrid();
            foreach (RoomGrid g in ll)
            {
                l.Add(g.mPosRoomGrid);
            }
        }
        else          //根据现有的设置摆设区域。
        {
            if (type == ShipBuildType.Soldier)
            {
                List <RoomGrid> lAll = GetAllRoomGrid();
                foreach (RoomGrid r in lAll)
                {
                    if (r.CheckPosition((int)PutPosition.Soldier))
                    {
                        l.Add(r.mPosRoomGrid);
                    }
                }
                //List<RoomGrid>listRoomGrid = RoomMap.GetPutRoomGrid();
            }
            else if (type == ShipBuildType.BuildRoom)
            {
                if (bDeckRoom)
                {
                    foreach (RoomGrid r in m_DeckRoom)
                    {
                        if (r.CheckPosition((int)PutPosition.Floor))
                        {
                            l.Add(r.mPosRoomGrid);
                        }
                    }
                }
                else
                {
                    List <Int2>     listOld            = new List <Int2>();
                    List <Int2>     listNew            = new List <Int2>();
                    List <RoomGrid> listNoLinRoomGrid  = GetNoLinkRoom(listOld, listNew);
                    List <RoomGrid> listCanPutRoomGrid = new List <RoomGrid>();;
                    int             nCount             = m_PutRoom.Count;
                    for (int nCnt = 0; nCnt < nCount; nCnt++)
                    {
                        RoomGrid roolGrid = m_PutRoom[nCnt];
                        if (!listNoLinRoomGrid.Contains(roolGrid) && roolGrid.mPosRoomGrid.Layer < 4)
                        {
                            listCanPutRoomGrid.Add(roolGrid);
                        }
                    }
                    NDLink.JoinLink(new List <Int2>(), new List <Int2>(), listCanPutRoomGrid, m_RealMapSize);
                    l.AddRange(NDLink.GetCanPutArea());
                }
            }
        }
        return(l);
    }
Пример #2
0
    /// <summary>
    /// 是否可以正常连通到金库
    /// </summary>
    public static bool CheckLinkToGoldRoom(List <Int2> RemoveList, List <Int2> AddList, bool IsNewCreate)
    {
        if (IsNewCreate)
        {
            if (!NDLink.SameGridList(RemoveList, AddList))
            {
                //确认是否产生无效的甲板房间
                if (CheckHaveInvalidRoomGrid(RemoveList, AddList) == true)
                {
                    return(false);
                }

                //确认能否吸收新房间的
                if (CheckCanPutRoom(RemoveList, AddList) == false)
                {
                    return(false);
                }
            }
        }
        //确认是否覆盖了甲板房间或在甲板房间上面
        if (ChencUpCoverDeckRoom(AddList) == true)
        {
            return(false);
        }
        //联通性测试
        NDLink.JoinLink(RemoveList, AddList, m_PutRoom, m_RealMapSize);

        bool            bLinkOK           = true;
        List <Int2>     listOld           = new List <Int2>();
        List <Int2>     listNew           = new List <Int2>();
        List <RoomGrid> listNoLinRoomGrid = GetNoLinkRoom(listOld, listNew);
        int             nNewPosCount      = AddList.Count;
        int             nNewPosCnt        = 0;

        for (nNewPosCnt = 0; nNewPosCnt < nNewPosCount; nNewPosCnt++)
        {
            RoomGrid R = FindRoomGrid(AddList[nNewPosCnt], XYSYS.RoomGrid);
            if (listNoLinRoomGrid.Contains(R))
            {
                bLinkOK = false;
                break;
            }
        }
        return(bLinkOK);
    }