public Map16Tile16x16(byte[] data, int offset) { TileNumber = offset / 8; SubTiles[TopLeftIndex] = new Map16Tile8x8(data, offset + 0); SubTiles[BottomLeftIndex] = new Map16Tile8x8(data, offset + 2); SubTiles[TopRightIndex] = new Map16Tile8x8(data, offset + 4); SubTiles[BottomRightIndex] = new Map16Tile8x8(data, offset + 6); SubTiles.ForEach(t => t.Parent = this); }
/// <summary> /// Checks if two Map16Tile8x8 objects contain the same data /// </summary> /// <param name="obj">The object to compare</param> /// <returns><c>True</c> if both objects contain the same data</returns> public override bool Equals(object obj) { if (object.ReferenceEquals(obj, this)) { return(true); } if ((object)this == null) { return(false); } Map16Tile8x8 m = obj as Map16Tile8x8; if ((object)m == null) { return(false); } return(Data[0] == m.Data[0] && Data[1] == m.Data[1]); }
/// <summary> /// /// </summary> /// <param name="x8">Horizontal value on an 8x8 grid</param> /// <param name="y8">Vertical value on an 8x8 grid</param> public void Select(int x8, int y8, bool in8x8Mode) { int index = (y8 / 2) * 16 + (x8 / 2); //32 8x8 tiles per horizontal row Map16Tile16x16 tile16 = Map[index]; SelectedObject.PropertyChanged -= SelectedObject_PropertyChanged; if (!in8x8Mode) { SelectedObject = tile16; } else { int xPlus = (x8 % 2) * 2; // +2 if we're on the right side int yPlus = y8 % 2; // +1 if we're on the bottom Map16Tile8x8 tile8 = tile16.SubTiles[xPlus + yPlus]; SelectedObject = tile8; } SelectedObject.PropertyChanged += SelectedObject_PropertyChanged; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedObject))); }