public Tile(Int32 aWidth, Int32 aHeight) { mLength = aWidth * aHeight; mContent = new List<Int32>(mLength); for (Int32 i = 0; i < mLength - 1; i++) { mContent.Add(i); } mContent.Add(BLANK_TILE); mWidth = aWidth; mHeight = aHeight; mMaxFlags = mLength - 2; mBlank = new Vector2D(aWidth, aHeight); }
public bool HandleClick(Int32 aX, Int32 aY) { if (ValidClick(aX, aY) != Direction.None) { #if DEBUG Debug.WriteLine("####### YES,CLICK RIGHT ########"); #endif Int32 i = (aY - 1) * Width + aX - 1; Int32 j = (Blank.Y - 1) * Width + Blank.X - 1; Int32 tmp = mContent[i]; mContent[i] = mContent[j]; mContent[j] = tmp; Blank = new Vector2D(aX, aY); return true; } #if DEBUG else { Debug.WriteLine("------- NO,TRY AGAIN ---------"); } #endif return false; }