コード例 #1
0
        public MainWindow holderWin; // to change the size of main window

        public GameModeSelectionPage()
        {
            // layout
            InitializeComponent();

            Grid aGrid = ButtonGrid1(holder);

            addChildrenGrid(holder, aGrid, 1);

            StringGrid s = new StringGrid("G", SquareGenerator.squareSize * 1.5);

            s.noAnimation();

            aCanvas.Children.Add(s);
            s.SetValue(Canvas.RightProperty, 0.0);
            s.SetValue(Canvas.TopProperty,
                       (WindowSizeGenerator.screenHeight - s.getHeight()) / 2);
            s.SetValue(Canvas.ZIndexProperty, 2);

            Pic.PicGen     pic = new Pic.CatGen();
            Pic.PicGenGrid pg  = new Pic.PicGenGrid(pic, SquareGenerator.picSquareSize / 1.2);
            aCanvas.Children.Add(pg);
            pg.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetRight(pg, 2);
            Canvas.SetBottom(pg, 2);
        }
コード例 #2
0
        // the starting animation(ready go)
        protected void startAnimation()
        {
            int timeStart = 10;
            int timeStep  = 1000;
            int timeDelay = timeStep + 100;


            welcomeString1 = new StringGrid("READY", SquareGenerator.squareSize / 1.8);

            Canvas.SetLeft(welcomeString1,
                           (Styles.WindowSizeGenerator.screenWidth - welcomeString1.getWidth()) / 2);
            Canvas.SetTop(welcomeString1,
                          (outerGrid.Height - welcomeString1.getHeight()) / 2);
            Canvas.SetZIndex(welcomeString1, 10);

            aCanvas.Children.Add(welcomeString1);
            welcomeString1.startAnimation(timeStep, timeStart);

            Console.WriteLine(outerGrid.Width);
            Console.WriteLine(welcomeString1.getWidth());
            Console.WriteLine((holderWin.Width - welcomeString1.getWidth()) / 2);

            welcomeString2 = new StringGrid("GO", SquareGenerator.squareSize);
            Canvas.SetLeft(welcomeString2,
                           (Styles.WindowSizeGenerator.screenWidth - welcomeString2.getWidth()) / 2);
            Canvas.SetTop(welcomeString2,
                          (holderWin.Height - welcomeString2.getHeight()) / 2);
            Canvas.SetZIndex(welcomeString2, 10);

            aCanvas.Children.Add(welcomeString2);
            welcomeString2.startAnimation(timeStep, timeDelay + timeStart);

            welcomeString2.story.Completed += whatHappenWhenAnimationStop;


            welcomeString1.beginAnimation();
            welcomeString2.beginAnimation();

            gameOver = new StringGrid("Game Over", SquareGenerator.squareSize / 2.5);

            aCanvas.Children.Add(gameOver);

            Canvas.SetLeft(gameOver,
                           (Styles.WindowSizeGenerator.screenWidth - gameOver.getWidth()) / 2);
            Canvas.SetTop(gameOver,
                          (outerGrid.Height - gameOver.getHeight()) / 2);
            Canvas.SetZIndex(gameOver, 10);

            gameOver.startAnimation(1500, 0);
        }