static public void NewBoxReadyToDown() { if (grid == null) { new Exception("缺少活动区域"); } if (waitingGrid == null) { new Exception("缺少等候区域"); } if (WaitingBox == null) { WaitingBox = BoxFactory.GetRandomBox(ref grid); } waitingGrid.Children.Clear(); if (waitingGrid == null) { ActivityBox = BoxFactory.GetRandomBox(ref grid); } else { ActivityBox = WaitingBox; } ActivityBox.OnButtom += ActivityBox_OnButtom; ActivityBox.Ready(); ActivityBox.AutoDown(); WaitingBox = BoxFactory.GetRandomBox(ref grid); waitingGrid.Children.Clear(); WaitingBox.ShowWaiting(ref waitingGrid); if (ActivityBox.IsOverlapping()) { ActivityBox.Pause(); if (OnGameOver != null) { OnGameOver(null, null); } } }
/// <summary> /// 构造函数,参数为主体网格,以及行数列数 /// </summary> /// <param name="grid"></param> /// <param name="row"></param> /// <param name="column"></param> public GameFrame(Grid grid, int row, int column) { boxDropInterval = 500; this.grid = grid; this.row = row; this.column = column; State = GameState.Stoped; boxNum = 0; Hard = 1; for (int i = 0; i < column; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < row; i++) { grid.RowDefinitions.Add(new RowDefinition()); } container = new Container(row, column); boxFactory = new BoxFactory(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { Label lbl = new Label(); container.map[i, j] = new GridData(); container.map[i, j].Lbl = lbl; container.map[i, j].Value = BoxShape.NULL; lbl.SetValue(Grid.RowProperty, i); lbl.SetValue(Grid.ColumnProperty, j); grid.Children.Add(lbl); } } ClearMap(); }