/// <summary> /// 检测该位置是否适合放置,新建摆放对象和显示可放不可放状态时使用 /// </summary> public static bool CheckCanPut(CanvasCore Core, Int2 posMapGrid) { if (Core == null) { return(false); } ShipPlan P = ShipPlanDC.GetCurShipPlan(); if (P == null) { return(false); } ShipPutInfo Info = P.GetShipBuildInfo(Core); if (Info == null) { return(false); } RoomGrid grid = RoomMap.FindRoomGrid(posMapGrid, XYSYS.MapGrid); if (grid != null) { bool result = BattleEnvironmentM.BuildInShape(grid.mPosRoomGrid); if (!result) { return(false); } } if (Core.m_type == ShipBuildType.BuildRoom) { List <Int2> AddList = Core.GetMovetoRoomGridPos(posMapGrid); if (Core.IsDeckRoom == false) { List <Int2> oldList = Core.GetPutRoomGridPos(); if (Core.IsNewCreate) { oldList.Clear();//新建连接房间没位置 } //连接房判定是否可放 bool bLinkOK = RoomMap.CheckLinkToGoldRoom(oldList, AddList, Core.IsNewCreate); if (bLinkOK) { List <RoomGrid> listRoomGrid = RoomMap.GetPutRoomGrid(Core); List <RoomGrid> listMovetoRoomGrid = RoomMap.GetMovetoRoomGrid(Core, posMapGrid); if (listRoomGrid.Count != listMovetoRoomGrid.Count) { return(false); } int nMoveToCount = listMovetoRoomGrid.Count; int nMoveCnt = 0; for (nMoveCnt = 0; nMoveCnt < nMoveToCount; nMoveCnt++) { RoomGrid roomGrid = listMovetoRoomGrid[nMoveCnt]; CanvasCore buildCore = roomGrid.GetBuildRoom(); //所放的地方有其它的连接房或甲板房则不能临时放 if (buildCore.m_ID != RoomGrid.EMPTYGRIDID && buildCore.m_ID != Core.m_ID && buildCore.m_type == ShipBuildType.BuildRoom) { return(false); } } return(bLinkOK); } } else { //甲板房放置判定 return(RoomMap.CheckCanPutDeckBuild(Core.m_ID, AddList)); } } else if (Core.m_type == ShipBuildType.BuildStair) { //楼梯需保证在活动范围内移动。 Int2 Area = RoomMap.GetStairActiveArea(Info.cyMapGrid, Info.cxMapGrid); if (posMapGrid.Unit < Area.Layer || posMapGrid.Unit > Area.Unit) { return(false); } if (posMapGrid.Layer != Info.cyMapGrid) { return(false); } RoomMap.RemoveMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); RoomMap.AddMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); return(true); } else if (Core.m_type == ShipBuildType.Soldier) { //原占有先移除 if (!Core.IsNewCreate) { RoomMap.RemoveMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); } //new bool ret = RoomMap.CheckMapPosition(RoomMap.GetMovetoRoomGridPosition(Core, posMapGrid)); //原占有复原 if (!Core.IsNewCreate) { RoomMap.AddMapPosition(Core, RoomMap.GetPutRoomGridPosition(Core)); } return(ret); } return(false); }