| 
					
				 | 
			
			
				@@ -79,10 +79,6 @@ namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _blankItem = UIPackage.CreateObject("ActivityHuaRongDao", "item"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _ui.target.AddChild(_blankItem); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            _ui.m_maskTouch.onTouchBegin.Add(TouchBegin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            _ui.m_maskTouch.onTouchEnd.Add(TouchEnd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         protected override void OnShown() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -232,6 +228,7 @@ namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 GObject gObject = UIPackage.CreateObject("ActivityHuaRongDao", "item"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 gObject.name = "item" + i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gObject.onClick.Add(OnItemClick); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _ui.m_items.target.AddChild(gObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _items.Add(gObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -253,103 +250,77 @@ namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             inputPos.y = context.inputEvent.y; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private void TouchEnd(EventContext context) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Grid CheckCanMove(int num) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            GridInfo numGrid = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            GridInfo nullGrid = new GridInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int indexX = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int indexY = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 找到空格子 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 找到格子 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (int i = 0; i < _gridNum; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (int j = 0; j < _gridNum; j++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (_gridArr[i, j].num == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (_gridArr[i, j].num == num) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nullGrid.row = i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nullGrid.col = j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        indexX = i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        indexY = j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 左 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ((context.inputEvent.x - inputPos.x) < 0 && Mathf.Abs(context.inputEvent.x - inputPos.x) > Mathf.Abs(context.inputEvent.y - inputPos.y)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                numGrid = CheckHaveNumGrid(nullGrid.row, nullGrid.col + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 右 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ((context.inputEvent.x - inputPos.x) > 0 && Mathf.Abs(context.inputEvent.x - inputPos.x) > Mathf.Abs(context.inputEvent.y - inputPos.y)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                numGrid = CheckHaveNumGrid(nullGrid.row, nullGrid.col - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 上 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ((context.inputEvent.y - inputPos.y) < 0 && Mathf.Abs(context.inputEvent.y - inputPos.y) > Mathf.Abs(context.inputEvent.x - inputPos.x)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 判断格子四个方向是否有空格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (CheckHaveNullGrid(indexX - 1, indexY) || CheckHaveNullGrid(indexX, indexY - 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                || CheckHaveNullGrid(indexX + 1, indexY) || CheckHaveNullGrid(indexX, indexY + 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                numGrid = CheckHaveNumGrid(nullGrid.row + 1, nullGrid.col); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 下 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ((context.inputEvent.y - inputPos.y) > 0 && Mathf.Abs(context.inputEvent.y - inputPos.y) > Mathf.Abs(context.inputEvent.x - inputPos.x)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                numGrid = CheckHaveNumGrid(nullGrid.row - 1, nullGrid.col); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (numGrid != null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                int num = numGrid.num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Grid grid = UpdateGridInfo(numGrid, nullGrid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                MoveItem(grid, num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return UpdateGridInfo(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private void MoveItem(Grid newGrid, int changeNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private bool CheckHaveNullGrid(int indexX, int indexY) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (int i = 0; i < _items.Count; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (indexX >= 0 && indexX < _gridNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                GObject obj = _items[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                int num = (int)obj.data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (num == changeNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (indexY >= 0 && indexY < _gridNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    _ui.m_maskGlobal.visible = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    obj.TweenMove(newGrid.pos, 0.1f).OnComplete(() => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        _ui.m_maskGlobal.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (CheckWin()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            ControlMenuItemVisual(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            Win(_cancellationTokenSource.Token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return _gridArr[indexX, indexY].num == 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// 查看空白格附近是否存在数字格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// <param name="indexX"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// <param name="indexY"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /// <returns></returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private GridInfo CheckHaveNumGrid(int indexX, int indexY) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Grid UpdateGridInfo(int num) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (indexX >= 0 && indexX < _gridNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Vector2 nullGridindex = new Vector2(-1, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Vector2 numGridindex = new Vector2(-1, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < _gridNum; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (indexY >= 0 && indexY < _gridNum) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int j = 0; j < _gridNum; j++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    GridInfo grid = new GridInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    grid.row = indexX; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    grid.col = indexY; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    grid.num = _gridArr[indexX, indexY].num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return grid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (_gridArr[i, j].num == num) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        numGridindex = new Vector2(i, j); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else if (_gridArr[i, j].num == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        nullGridindex = new Vector2(i, j); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (numGridindex.x != -1 && nullGridindex.x != -1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _gridArr[(int)numGridindex.x, (int)numGridindex.y].num = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _gridArr[(int)nullGridindex.x, (int)nullGridindex.y].num = num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return _gridArr[(int)nullGridindex.x, (int)nullGridindex.y]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /// <summary> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -554,7 +525,7 @@ namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void OnChangeLookOriginState() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             bool look = (_ui.m_state.selectedIndex == 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            _ui.m_maskTouch.touchable = !look; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_items.target.touchable = !look; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             _ui.m_items.target.visible = !look; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             _ui.m_itemsOrigin.target.visible = look; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -569,5 +540,25 @@ namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return ResPathUtil.GetHUARONGDAOPicPath(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void OnItemClick(EventContext eventContext) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            GObject obj = eventContext.sender as GObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int num = (int)obj.data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Grid newGrid = CheckCanMove(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (newGrid != null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_maskGlobal.visible = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                obj.TweenMove(newGrid.pos, 0.1f).OnComplete(() => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    _ui.m_maskGlobal.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (CheckWin()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ControlMenuItemVisual(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Win(_cancellationTokenSource.Token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |