/// <summary> /// 房间置换数据 /// </summary> public static void ExchangeCanvans(List <RoomGrid> l1, List <RoomGrid> l1MoveTo, List <RoomGrid> l2, List <RoomGrid> l2MoveTo) { if (l1 == null || l2 == null) { return; } //if(l1.Count != l2.Count) // return ; List <RoomGrid> lTemp1 = new List <RoomGrid>(); //交换数据 int nRoomGrid1Count = l1.Count; for (int nRoomGrid1Cnt = 0; nRoomGrid1Cnt < nRoomGrid1Count; nRoomGrid1Cnt++) { RoomGrid R = l1[nRoomGrid1Cnt]; if (l2MoveTo.Contains(R)) { RoomGrid rTemp = l1[nRoomGrid1Cnt]; R = new RoomGrid(); R.CopyPutData(rTemp); rTemp.EmptyRoomGrid(); RemovePutRoomGrid(rTemp); } lTemp1.Add(R); } List <RoomGrid> lTemp2 = new List <RoomGrid>(); nRoomGrid1Count = l2.Count; for (int nRoomGrid1Cnt = 0; nRoomGrid1Cnt < nRoomGrid1Count; nRoomGrid1Cnt++) { RoomGrid R = l2[nRoomGrid1Cnt]; if (l1MoveTo.Contains(R)) { RoomGrid rTemp = l2[nRoomGrid1Cnt]; R = new RoomGrid(); R.CopyPutData(rTemp); rTemp.EmptyRoomGrid(); RemovePutRoomGrid(rTemp); } lTemp2.Add(R); } MoveCanvans(lTemp1, l1MoveTo); MoveCanvans(lTemp2, l2MoveTo); lTemp1.Clear(); lTemp2.Clear(); }
/// <summary> /// 关闭地图 /// </summary> public static void CloseCanvans(List <Int2> l) { if (l == null || l.Count == 0) { return; } foreach (Int2 pos in l) { RoomGrid t = FindRoomGrid(pos, XYSYS.RoomGrid); if (t != null) { t.EmptyRoomGrid(); RemovePutRoomGrid(t); } } }