//if Tetris grid has generator with prediction - save ptr to property private void SetShapeGenerator(TetrisFE positionGrid) { //unsubsribe from event if (_shapeGenerator != null) { _shapeGenerator.ShapePoped -= OnShapeGeneratorPoped; } //get predicting shape generator _shapeGenerator = positionGrid.ShapeGenerator as IShapeGeneratorWithPrediction; //subrscibe event when shape is generated _shapeGenerator.ShapePoped += OnShapeGeneratorPoped; }
public PredictionFE(IShapeGeneratorWithPrediction sapeGenerator) { _shapeGenerator = sapeGenerator; _shapeGenerator.ShapePoped += OnShapeGeneratorPoped; OnShapeGeneratorPoped(null); }