示例#1
0
 private void LevelBuild_Click(object sender, EventArgs e)
 {
     Reset();
     DesignerController.newDesign((int)this.WidthInput.Value, (int)this.HeightInput.Value);
     WidthInput.Value  = 0;
     HeightInput.Value = 0;
 }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            /* << VIEWS >> */
            BaseForm  baseForm = new BaseForm();
            IGameView gameView = new GameFormView(); // injecting new << View >>
            //IGameView_Render gameView = new GameFormView_Render(); // injecting new << View >>
            //IGameView_Manual gameView = new GameFormView_Manual();
            IFilerView    filerView    = new FilerFormView();
            IDesignerView designerView = new DesignerFormView();

            /* << MODELS >> */
            IFiler    filer            = new Filer();
            IDesigner designer         = new Designer();
            IFileable designerFileable = (IFileable)designer;
            IGame     game             = new Game();
            IFileable gameFileable     = (IFileable)game;

            /* << CONTROLLER(S) >> */
            IGameController     gameController     = new GameController(gameView, filerView, filer, game, gameFileable);
            IDesignerController designerController = new DesignerController(filerView, designerView, filer, designer, designerFileable);

            baseForm.SetControllers(gameController, designerController);
            //gameView.SetController(gameController); // Set Controller for injected View
            Application.Run(baseForm);
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int width  = (int)numericUpDown_Width.Value;
            int height = (int)numericUpDown_Height.Value;

            //Controller.NewLevel(width, height);
            DesignerController.NewLevel(width, height);
            SetClicks();
        }
示例#4
0
        protected void WhoClicked(object sender, EventArgs e)
        {
            PictureBox btnWho = sender as PictureBox;

            string[] output = btnWho.Name.Split('_', '_');

            int x = int.Parse(output[1]);
            int y = int.Parse(output[2]);

            DesignerController.AddToLevel(x, y, symbol);
        }
示例#5
0
        protected void WhoClicked(object sender, EventArgs e)
        {
            Button btnWho = sender as Button;

            string[] output = btnWho.Name.Split('_', '_');
            int      column = int.Parse(output[1]);
            int      row    = int.Parse(output[2]);

            //Controller.EditLevel(Part, row, column);
            DesignerController.EditLevel(Part, row, column);
        }
示例#6
0
        public void UpdateLevel()
        {
            int rowCount = DesignerController.GetHeight();
            int colCount = DesignerController.GetWidth();

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    Parts enumParts = DesignerController.GetPart(col, row);
                    char  charParts = (char)enumParts.GetHashCode();

                    if (enumParts == Parts.Wall)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.Wall).ToString();
                    }
                    if (enumParts == Parts.Player)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.Player).ToString();
                    }
                    if (enumParts == Parts.Block)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.Block).ToString();
                    }
                    if (enumParts == Parts.Goal)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.Goal).ToString();
                    }
                    if (enumParts == Parts.BlockOnGoal)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.BlockOnGoal).ToString();
                    }
                    if (enumParts == Parts.PlayerOnGoal)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.PlayerOnGoal).ToString();
                    }
                    if (enumParts == Parts.Empty)
                    {
                        Button btn = (Button)this.Controls.Find("btn_" + (col + "_" + row), true)[0];
                        btn.Text = ((char)Parts.Empty).ToString();
                    }
                }
            }
        }
示例#7
0
文件: Program.cs 项目: jav244/sokoban
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //<<VIEW>>
            BaseForm   baseFrm   = new BaseForm();
            IGameView  gameView  = new GameFormView();
            IFilerView filerView = new FilerFormView();
            /*MANUAL DESIGNER*/
            //IManualDesignerView manualDesignerView = new ManualDesignerFormView();
            /*DYNAMIC BUTTONS*/
            //IDesignerButtonView designerButtonView = new DesignerButtonFormView();
            /*DYNAMIC DRAWING VIEW*/
            IDesignerView designerView = new DesignerFormView();


            //<<MODELS>>
            IFiler    filer            = new Filer();
            IDesigner designer         = new Designer();
            IGame     game             = new Game();
            IFileable designerFileable = (IFileable)designer;
            IFileable gameFileable     = (IFileable)game;

            baseFrm.StartPosition = FormStartPosition.CenterScreen;

            //<<CONTROLLERS>>
            IGameController gameController = new GameController(gameView, filerView, filer, game, gameFileable);
            /*MANUAL DESIGNER*/
            //IDesignerController designerController = new DesignerController(manualDesignerView, filerView, filer, designer, designerFileable);
            /*DYNAMIC BUTTONS*/
            //IDesignerController designerController = new DesignerController(designerButtonView, filerView, filer, designer, designerFileable);
            /*DYNAMIC DRAWING VIEW*/
            IDesignerController designerController = new DesignerController(designerView, filerView, filer, designer, designerFileable);


            //<<SET CONTROLLERS>>
            baseFrm.SetControllers(gameController, designerController);
            /*MANUAL DESIGNER*/
            //manualDesignerView.SetController(designerController);

            Application.Run(baseFrm);
        }
示例#8
0
        public void UpdateLevel()
        {
            int rowCount = DesignerController.GetHeight();
            int colCount = DesignerController.GetWidth();

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    Parts enumParts = DesignerController.GetPart(col, row);
                    char  charParts = (char)enumParts.GetHashCode();

                    if (enumParts == Parts.Wall)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.Wall;//Image.FromFile(@"../Pics/Wall.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.Player)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.Player; //Image.FromFile(@"../Pics/Player.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.Block)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.Block; //Image.FromFile(@"../Pics/Block.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.Goal)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.Goal; //Image.FromFile(@"../Pics/Goal.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.BlockOnGoal)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.BlockOnGoal; //Image.FromFile(@"../Pics/BlockOnGoal.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.PlayerOnGoal)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.PlayerOnGoal; //Image.FromFile(@"../Pics/PlayerOnGoal.jpg");
                        mybox.Refresh();
                    }
                    if (enumParts == Parts.Empty)
                    {
                        PictureBox mybox = (PictureBox)this.Controls.Find("pictureBox_" + (col + "_" + row), true)[0];
                        mybox.Image.Dispose();
                        mybox.Image = Properties.Resources.Empty; //Image.FromFile(@"../Pics/Empty.jpg");
                        mybox.Refresh();
                    }
                }
            }
        }
示例#9
0
 private void Save_Click_1(object sender, EventArgs e)
 {
     DesignerController.SaveDesign();
 }