Beispiel #1
0
        /// <summary>
        /// click help button
        /// </summary>
        /// <param name="view">View IVIEw</param>
        /// <param name="model">model IMOdel</param>
        public Help_w(IModel model, IView view)
        {
            InitializeComponent();
            m_model = model;
            m_view  = view;
            MazeCell1    wall   = new MazeCell1();
            GrassCell    grass  = new GrassCell();
            StepsCell    steps  = new StepsCell();
            ArrowControl jumper = new ArrowControl();
            StartControl start  = new StartControl();
            EndControl   end    = new EndControl();

            Grass.Children.Add(grass);
            Wall.Children.Add(wall);
            Steps.Children.Add(steps);
            Jumper.Children.Add(jumper);
            Start.Children.Add(start);
            Goal.Children.Add(end);
        }
Beispiel #2
0
        /// <summary>
        /// create the maze
        /// </summary>
        private void CreateTheMaze()
        {
            double PositionX = 0;
            double PositionY = 0;
            Maze2d maze2d    = m_maze.MAZE3dArray[cur_layer] as Maze2d;

            for (int row = 0; row < maze2d.MX * 2 - 1; row++)
            {
                PositionX = 0;
                for (int column = 0; column < maze2d.MY * 2 - 1; column++)
                {
                    if (cur_layer == 0 && maze2d.getStartPosition().X == row && maze2d.getStartPosition().Y == column)
                    {
                        StartControl s = new StartControl();
                        s.Width  = cellWidth;
                        s.Height = cellHeight;
                        Canvas.SetLeft(s, PositionX);
                        Canvas.SetTop(s, PositionY);
                        PanelDown.Children.Add(s);
                    }

                    else
                    {
                        if (cur_layer == goal_layer && maze2d.getGoalPosition().X == row && maze2d.getGoalPosition().Y == column)
                        {
                            EndControl EndCell = new EndControl();
                            EndCell.Width  = cellWidth;
                            EndCell.Height = cellHeight;
                            Canvas.SetLeft(EndCell, PositionX);
                            Canvas.SetTop(EndCell, PositionY);
                            PanelDown.Children.Add(EndCell);
                        }
                        else
                        {
                            if (maze2d.getGoalPosition().X == row && maze2d.getGoalPosition().Y == column)
                            {
                                ArrowControl arrow = new ArrowControl();
                                arrow.Width  = cellWidth;
                                arrow.Height = cellHeight;
                                Canvas.SetLeft(arrow, PositionX);
                                Canvas.SetTop(arrow, PositionY);
                                PanelDown.Children.Add(arrow);
                            }
                            else
                            {
                                if (maze2d.MAZE2d[row, column] == 1)
                                {
                                    MazeCell1 wall = new MazeCell1();
                                    wall.Width  = cellWidth;
                                    wall.Height = cellHeight;
                                    Canvas.SetLeft(wall, PositionX);
                                    Canvas.SetTop(wall, PositionY);
                                    PanelDown.Children.Add(wall);
                                }

                                else
                                {
                                    if (maze2d.MAZE2d[row, column] == 0)
                                    {
                                        GrassCell grass = new GrassCell();
                                        grass.Width  = cellWidth;
                                        grass.Height = cellHeight;
                                        Canvas.SetLeft(grass, PositionX);
                                        Canvas.SetTop(grass, PositionY);
                                        PanelDown.Children.Add(grass);
                                    }
                                }
                            }
                        }
                    }
                    PositionX += cellWidth;
                }
                PositionY += cellHeight;
            }
        }