Ejemplo n.º 1
0
        public GameStage()
        {
            InitializeComponent();

            // Init. all data members
            // 1. View
            int drawWidth = (Model.Model.TOT_BLOCK_CNT_X - 1) * Model.Model.BLOCK_MARGIN
                            + Model.Model.TOT_BLOCK_CNT_X * Model.Model.BLOCK_SIZE_X;
            int drawHeight = (Model.Model.TOT_BLOCK_CNT_Y - 1) * Model.Model.BLOCK_MARGIN
                             + Model.Model.TOT_BLOCK_CNT_Y * Model.Model.BLOCK_SIZE_Y
                             + ScoreView.SCORE_VIEW_HEIGHT;
            int wigetWidth  = drawWidth + DRAW_OFFSET_W;
            int wigetHeight = drawHeight + DRAW_OFFSET_H;

            this.Size = new Size(wigetWidth, wigetHeight); // Reset size of the main form
            Rectangle drawSize = new Rectangle(0, 0, drawWidth, drawHeight);

            _viewManager = new ViewManager(this.CreateGraphics(), drawSize);
            // 2. Model
            _mainModel = new Model.Model(this);
            // - Bind all Views
            _viewManager.Bind(new TipView(_mainModel));
            _viewManager.Bind(new MainView(_mainModel));
            _viewManager.Bind(new ScoreView(_mainModel, new Size(drawWidth, drawHeight)));
            _viewManager.Bind(new PathView(_mainModel));
            _viewManager.Bind(new MainMenuView(_mainModel, drawSize, @"images/MainMenu.jpg"));
            _viewManager.Bind(new GameEndView(_mainModel, drawSize, @"images/Win.jpg"));
            _viewManager.Bind(new ScoreBoardView(_mainModel, drawSize, @"images/ScoreBoard.jpg"));
            _viewManager.Bind(new GuideView(_mainModel, drawSize, @"images/Guide.jpg"));
            // 3. Controller
            _mainController = new Controller.Controller(_mainModel);

            // Set Timer
            ViewUpdateTimer.Interval = 1000 / FPS;
        }