コード例 #1
0
        /// <summary>
        /// construct geometry of wall and pills for a specific level
        /// </summary>
        /// <param name="newValue"></param>

        private void ConstructWallAndPills(Labyrinth newValue)
        {
            this.Wall.Children.Clear();
            this.Pills.Children.Clear();
            CurrentGame._pillCoord.Clear();
            if (newValue == null)
            {
                return;
            }
            TPillGame.RemainingPills = 0;
            for (int xx = 0; xx < Labyrinth.WIDTH; xx++)
            {
                for (int yy = 0; yy < Labyrinth.HEIGHT; yy++)
                {
                    UInt16 b = newValue[xx, yy];
                    if (b == 0)
                    {
                        continue;
                    }
                    double x, y;
                    newValue.GetScreenCoord(xx, yy, out x, out y);
                    switch (b)
                    {
                    case 1:                            //pill
                    case 2:
                        TPillGame pill = new TPillGame(this);
                        this.Pills.Children.Add(pill);
                        CurrentGame._pillCoord.Add(new Point(xx, yy), pill);
                        pill.Width  = Constants.GRID_WIDTH * 1.5;
                        pill.Height = Constants.GRID_HEIGHT * 1.5;
                        pill.tsk    = newValue.chars[xx, yy];
                        pill.center = new Point(x + Constants.GRID_WIDTH_2, y + Constants.GRID_HEIGHT_2);
                        pill.init();
                        pill.isBig = (b == 2);
                        break;

                    case 4:                             //gate of ghost's house
                        break;

                    case 5:                            //wall
                        Geometry current = GetGeometry(xx, yy, (int)x, (int)y, newValue);
                        //if (current == null)
                        //{
                        //    RectangleGeometry r = new RectangleGeometry();
                        //    //if (i == 0)
                        //    //    r.Rect = new Rect(x + Constants.GRID_WIDTH_2, y, Constants.GRID_WIDTH_2, Constants.GRID_HEIGHT);
                        //    //else
                        //    r.Rect = new Rect(x, y, Constants.GRID_WIDTH, Constants.GRID_HEIGHT);
                        //    current = r;
                        //}
                        if (current != null)
                        {
                            this.Wall.Children.Add(current);
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
ファイル: GamePresenter.cs プロジェクト: pgourlain/pacman
        /// <summary>
        /// construct geometry of wall and pills for a specific level
        /// </summary>
        /// <param name="newValue"></param>
        private void ConstructWallAndPills(Labyrinth newValue)
        {
            this.Wall.Children.Clear();
            this.Pills.Children.Clear();
            _pillCoord.Clear();
            if (newValue == null)
            {
                return;
            }
            for (int i = 0; i < Labyrinth.WIDTH; i++)
            {
                for (int j = 0; j < Labyrinth.HEIGHT; j++)
                {
                    byte b = newValue[i, j];
                    if (b == 0)
                    {
                        continue;
                    }
                    int x, y;
                    newValue.GetScreenCoord(i, j, out x, out y);
                    switch (b)
                    {
                    case 1:    //pill
                        EllipseGeometry p = new EllipseGeometry();
                        p.Center  = new Point(x + Constants.GRID_WIDTH_2, y + Constants.GRID_HEIGHT_2);
                        p.RadiusX = 2;
                        p.RadiusY = 2;
                        this.Pills.Children.Add(p);
                        _pillCoord.Add(new Point(i, j), p);
                        break;

                    case 2:    //super pill
                        RectangleGeometry superPill = new RectangleGeometry();
                        superPill.Rect = new Rect(x + Constants.GRID_WIDTH_4, y + Constants.GRID_WIDTH_4, 8, 8);
                        this.Pills.Children.Add(superPill);
                        _pillCoord.Add(new Point(i, j), superPill);
                        break;

                    case 3:     //gate of ghost's house
                        break;

                    case 4:    //wall
                        Geometry current = GetGeometry(i, j, x, y, newValue);
                        //if (current == null)
                        //{
                        //    RectangleGeometry r = new RectangleGeometry();
                        //    //if (i == 0)
                        //    //    r.Rect = new Rect(x + Constants.GRID_WIDTH_2, y, Constants.GRID_WIDTH_2, Constants.GRID_HEIGHT);
                        //    //else
                        //    r.Rect = new Rect(x, y, Constants.GRID_WIDTH, Constants.GRID_HEIGHT);
                        //    current = r;
                        //}
                        if (current != null)
                        {
                            this.Wall.Children.Add(current);
                        }
                        break;
                    }
                }
            }
        }