public GameSystem(ref Canvas canvas) { this.canvas = canvas; StopAction += () => { movingTimer.Stop(); }; OnGameOver += () => { movingTimer.Stop(); }; State = new GameSystemDataState(); }
private void Window_SaveGame(GameSystemDataState obj) { if (obj != null) { Originator.SetMemento(obj); } }
private void SetInitialState() { clearCanvas(); State = new GameSystemDataState(); BrickDrawer.DrawGrid(State.bricks, ref canvas); Rectangle rectangleRed = (Rectangle)canvas.FindName("rectangleRed"); double left = Canvas.GetLeft(rectangleRed) + (rectangleRed.ActualWidth / 2); double top = canvas.ActualHeight - 60; State.RedGameBallLeft = left; State.RedGameBallTop = top; Canvas.SetLeft((Ellipse)canvas.FindName("GameBallRed"), State.RedGameBallLeft); Canvas.SetTop((Ellipse)canvas.FindName("GameBallRed"), State.RedGameBallTop); }