/// <summary> /// WidthとHeightが変更されたときに更新 /// 余った部分部分は切り捨て /// 足りない部分は初期化 /// </summary> /// <param name="newWidth"></param> /// <param name="newHeight"></param> public void EditWidthHeight(int newWidth, int newHeight) { //変更がなかったら何もしない if (_mapChipList.GetLength(0) == newHeight && _mapChipList.GetLength(1) == newWidth) { return; } var newMapList = new MapChip[newHeight, newWidth]; Initialize(newMapList); var h = _mapChipList.GetLength(0); var w = _mapChipList.GetLength(1); newMapList.Run((c, y, x) => { if (h <= y || w <= x) { c.Clear(); } else { newMapList[y, x] = _mapChipList[y, x].Clone(); } }); _mapChipList = newMapList; }
public void FlipHorizontal() { var h = _mapChipList.GetLength(0); var w = _mapChipList.GetLength(1); var newMapList = new MapChip[h, w]; Initialize(newMapList); newMapList.Run((c, y, x) => { if (x == 0 || y == 0 || x == w - 1 || y == h - 1) { newMapList[y, x] = _mapChipList[y, x].Clone(); } else { var _x = Math.Abs(x - (w - 1)); newMapList[y, _x] = _mapChipList[y, x].Clone(); } }); _mapChipList = newMapList; }