public void ClearBlock()
 {
     this.MapBlocks = new MapBlock[50][];
     for (int i = 0; i < 50; i++)
     {
         MapBlocks[i] = new MapBlock[50];
     }
 }
 public MapGrid()
 {
     InitializeComponent();
     MapBlocks  = new MapBlock[50][];
     MapObjects = new ArrayList();
     for (int i = 0; i < 50; i++)
     {
         MapBlocks[i] = new MapBlock[50];
     }
 }
        public void SetBlock(MapPosition Target, MapBlock Block)
        {
            MapBlocks[Target.X][Target.Y] = Block;

            float Screen_X = Target.X * -_nextX + _startX;//取得X軸起點(X,0)座標
            float Screen_Y = Target.X * _nextY + _startY;


            Screen_X += Target.Y * _nextX;//加入Y軸偏移
            Screen_Y += Target.Y * _nextY;

            MapBlocks[Target.X][Target.Y].Margin = new Thickness(Screen_X, Screen_Y, 0, 0);
        }
        public object Clone()
        {
            MapBlock result = new MapBlock();

            result.LeftSideTextureUri  = _uLeftSideTexture;
            result.MainTextureUri      = _uMainTexture;
            result.RightSideTextureUri = _uRightSideTexture;
            result.SurfaceTextureUri   = _uSurfaceTexture;

            result._iLeftSideTexture  = _iLeftSideTexture;
            result._iRightSideTexture = _iRightSideTexture;
            result._iMainTexture      = _iMainTexture;
            result._iSurfaceTexture   = _iSurfaceTexture;

            result._direction = this.Direction;

            return(result);
        }
        public void Load(MapContent Content)
        {
            for (int i = 0; i < Content.BlockMap.Length; i++)
            {
                for (int j = 0; j < Content.BlockMap[i].Length; j++)
                {
                    MapBlock Temp = Content.Blocks[Content.BlockMap[i][j]].Clone <MapBlock>();
                    if (Content.DirectionMap != null)
                    {
                        Temp.Direction = (Direction)Content.DirectionMap[i][j];
                    }
                    if (Content.SurfaceMap != null)
                    {
                        Temp.SurfaceTextureUri = Content.Surfaces[Content.SurfaceMap[i][j]];
                    }


                    this[i, j] = Temp;
                }
            }


            for (int i = 0; i < Content.ViewMap.Length; i++)
            {
                for (int j = 0; j < Content.ViewMap[i].Length; j++)
                {
                    GameObject V = new Map.Object.GameObject("Test" + i + j, new MapPosition()
                    {
                        X = i, Y = j
                    });

                    if (Content.Views[Content.ViewMap[i][j]] == null)
                    {
                        continue;
                    }

                    V.Image = Content.Views[Content.ViewMap[i][j]];

                    this.AddGameObject(V);
                }
            }

            //for(int i = 0; i < Content.Blo)
        }
Пример #6
0
        public void MatrixAnimationUsingPathDoesRotateWithTangentExample()
        {
            // Create a NameScope for the page so that
            // we can use Storyboards.
            NameScope.SetNameScope(MainGrid, new NameScope());

            // Create a button.
            Map.MapBlock aButton = new Map.MapBlock();
            aButton.LeftSideVisable  = true;
            aButton.RightSideVisable = true;
            // Create a MatrixTransform. This transform
            // will be used to move the button.
            MatrixTransform buttonMatrixTransform = new MatrixTransform();

            aButton.RenderTransform = buttonMatrixTransform;

            // Register the transform's name with the page
            // so that it can be targeted by a Storyboard.
            MainGrid.RegisterName("ButtonMatrixTransform", buttonMatrixTransform);

            // Create a Canvas to contain the button
            // and add it to the page.
            // Although this example uses a Canvas,
            // any type of panel will work.
            Canvas mainPanel = new Canvas();

            mainPanel.Width  = 400;
            mainPanel.Height = 400;
            mainPanel.Children.Add(aButton);
            MainGrid.Children.Add(mainPanel);

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure   pFigure       = new PathFigure();

            pFigure.StartPoint = new Point(10, 100);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();

            pBezierSegment.Points.Add(new Point(35, 0));
            pBezierSegment.Points.Add(new Point(135, 0));
            pBezierSegment.Points.Add(new Point(160, 100));
            pBezierSegment.Points.Add(new Point(180, 190));
            pBezierSegment.Points.Add(new Point(285, 200));
            pBezierSegment.Points.Add(new Point(310, 100));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating
            // its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();

            matrixAnimation.PathGeometry   = animationPath;
            matrixAnimation.Duration       = TimeSpan.FromSeconds(5);
            matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the rectangle in addition
            // to moving it.
            matrixAnimation.DoesRotateWithTangent = true;

            // Set the animation to target the Matrix property
            // of the MatrixTransform named "ButtonMatrixTransform".
            Storyboard.SetTargetName(matrixAnimation, "ButtonMatrixTransform");
            Storyboard.SetTargetProperty(matrixAnimation,
                                         new PropertyPath(MatrixTransform.MatrixProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();

            pathAnimationStoryboard.Children.Add(matrixAnimation);

            // Start the storyboard when the button is loaded.
            aButton.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                // Start the storyboard.
                pathAnimationStoryboard.Begin(MainGrid);
            };
        }