public MapChipModel(MapModel parent, MapChipPack[] mapChipPack) { _parent = parent; _mapChipList = new MapChip[parent.MapCellHeight, parent.MapCellWidth]; for (int i = 0; i < mapChipPack.Length; i++) { var y = i / parent.MapCellWidth; var x = i % parent.MapCellWidth; _mapChipList[y, x] = new MapChip(mapChipPack[i]); } }
public MapChipCommand(Point point, MapChip chip) { MapChipPointList = new[] { new MapChipPoint(point, (MapChip)chip.Clone()), }; }
public MapChipPoint(Point point, MapChip chip) { Point = point; MapChip = chip.Clone(); }
/// <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; }
private static void Initialize(MapChip[,] mapChipList) { var d1 = mapChipList.GetLength(0); var d2 = mapChipList.GetLength(1); for (var i = 0; i < d1; i++) { for (int j = 0; j < d2; j++) { mapChipList[i, j] = new MapChip(); } } }
public void Set(Point point, MapChip mapChip) { if (Get(point).ID != mapChip.ID) { _mapChipList[point.Y, point.X] = mapChip; RaisePropertyChanged("MapChipModel"); } }
public void Set(int x, int y, MapChip mapChip) { Set(new Point(x, y), mapChip); }
public void ReplaceByArray2D(int[,] newMapList) { _mapChipList.Run((m, y, x) => _mapChipList[y, x] = new MapChip(newMapList[y, x])); }
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; }
private string GetCurrentPositionInformation(MapChip mapchip, ObjectChip objectChip) { var pos = string.Format("横 : {0} 縦 : {1}", MapCellWidth, MapCellHeight); var mc = mapchip == null ? "" : string.Format("MapChipID : {0}", mapchip.ID); var oc = objectChip == null ? "" : string.Format("ObjectChipID : {0} Status : {1} Parameter : {2} SubParam1 : {3} SubParam2 : {4}", objectChip.ID, objectChip.Status, objectChip.Param, objectChip.SubParam1, objectChip.SubParam2); return string.Join(" ", new[] { pos, mc, oc }); }