/// <summary> /// 设置可放置区域颜色 /// </summary> public static void SetCanPutArea(ShipBuildType type, bool bDeckRoom) { List <Int2> l = RoomMap.GetCanPutArea(type, bDeckRoom); SetGridsBgStates(l, CanvasUnitState.CanPut, true); }
/// <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); }