internal bool Fits(Tile other) { SideHash[] sides = new SideHash[] { other.GetHashForSide(Sides.Left), other.GetHashForSide(Sides.Top), other.GetHashForSide(Sides.Right), other.GetHashForSide(Sides.Bottom) }; //Top if (this.LeftTile == 0 && FitsLeft(other, sides)) { return(true); } //Right if (this.RightTile == 0 && FitsRight(other, sides)) { return(true); } //Bottom if (this.BottomTile == 0 && FitsBottom(other, sides)) { return(true); } //Left if (this.TopTile == 0 && FitsTop(other, sides)) { return(true); } return(false); }
private bool FitsLeft(Tile other, SideHash[] otherHashes) { SideHash sideHash = GetHashForSide(Sides.Left); for (int i = 0; i < otherHashes.Length; i++) { SideHash otherHash = otherHashes[i]; if (sideHash.Match(otherHash, out bool flip)) { this.SetTile(Sides.Left, other.Id); other.SetTile(Sides.Right, this.Id); other.RotateAndFlip((2 - i), false, flip); return(true); } } return(false); }
private bool FitsBottom(Tile other, SideHash[] otherHashes) { SideHash sideHash = GetHashForSide(Sides.Bottom); for (int i = 0; i < otherHashes.Length; i++) { SideHash otherHash = otherHashes[i]; if (sideHash.Match(otherHash, out bool flip)) { this.SetTile(Sides.Bottom, other.Id); other.SetTile(Sides.Top, this.Id); other.RotateAndFlip((1 - i), flip, false); return(true); } } return(false); }