예제 #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
 /// <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;
             }
         }
     }
 }