public void UpdateShape() { shape = null; if (ShapeChanged != null) { ShapeChanged.Invoke(); } }
protected virtual void OnShapeChanged(ShapeEventArgs e) { //EventHandler<ShapeEventArgs> handler = ShapeChanged; //if (handler != null) //{ // handler(this, e); //} ShapeChanged?.Invoke(this, e); }
// Responds to UP arrow button key down public void RotateShape() { if (currentShape == null) { return; } gameGrid = currentShape.RotateShape(gameGrid); HasChanged(gameGrid, false, -1); ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != null }
// On tick, all shapes move down one row private void TmrTick(object sender, EventArgs e) { if (missATick) { return; } if (moveCounter >= 27) { moveCounter = 0; NewShape(); if (listShapes.Count == 1) { currentShape = listShapes[0]; ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); } } MoveDown(); }
// Clears the game board and score and initiates a new game public void NewGame() { tmr.Stop(); tmr.Interval = 500; listShapes.Clear(); moveCounter = 0; gameGrid = new string[30][]; for (int x = 1; x <= 30; x++) { string[] row = new string[20]; gameGrid[x - 1] = (string[])row.Clone(); } NewShape(); currentShape = listShapes[0]; ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != NULL rowCounter = 0; tmr.Start(); flashtmr.Start(); }
// Responds to shape touchdown private void CurrentShapeTouchDown(Shape sender) { if (sender.CurrentPoints.Any(p => p.Y < 0)) { tmr.Stop(); } currentShape.TouchDown -= CurrentShapeTouchDown; listShapes.Remove(sender); if (listShapes.Count < 1) { currentShape = null; moveCounter = 27; } else { currentShape = listShapes[0]; ShapeChanged?.Invoke(currentShape.CurrentPoints, currentShape.ShapeColor); // ShapeChanged != NULL } }
protected virtual void OnShapeChanged(MyEventArgs e) { ShapeChanged?.Invoke(this, e); }
protected virtual void OnShapeChanged(ShapeEventArgs e) { ShapeChanged?.Invoke(this, e); // 当shape改变的时候 , 就调用事件 , 通知别人. }
private void EhShapeChanged(object sender, SelectionChangedEventArgs e) { GuiHelper.SynchronizeSelectionFromGui(_guiShape); ShapeChanged?.Invoke(((SelectableListNode)_guiShape.SelectedValue).Tag as Type); }