예제 #1
0
 public AnimatedTitle(AnimationType animationType, string title, params string[] names)
 {
     _animationType = animationType;
     Title          = title;
     foreach (string name in names)
     {
         NamesCollection.Add(name);
     }
 }
예제 #2
0
        public async Task Initialize()
        {
            Bars.Clear();
            Cars = new Car[NumberOfCars];
            int teemoNum = RandomGen2.Next() % (NumberOfCars - 1) + 1;

            MainGrid.RowDefinitions.Add(new RowDefinition());
            for (int i = 0; i < NumberOfCars; i++)
            {
                MainGrid.RowDefinitions.Add(new RowDefinition());
                // Add CarRaceBar in mainGrid
                CarRaceBar bar = new CarRaceBar()
                {
                    Maximum             = (double)Distance,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };
                MainGrid.Children.Add(bar);
                Grid.SetColumn(bar, 1);
                Grid.SetRow(bar, i + 1);

                // Set color of car.
                if (i == 0)
                {
                    await bar.SetColor(PlayerColor);
                }
                else
                {
                    await bar.SetColor(Color.FromArgb(255, (byte)(RandomGen2.Next() % 255),
                                                      (byte)(RandomGen2.Next() % 255), (byte)(RandomGen2.Next() % 255)));
                }
                Bars.Add(bar);

                // Make text
                TextBlock description = new TextBlock()
                {
                    Name                    = $"Text{i}",
                    Foreground              = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff)),
                    HorizontalAlignment     = HorizontalAlignment.Center,
                    VerticalAlignment       = VerticalAlignment.Center,
                    TextAlignment           = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center
                };
                MainGrid.Children.Add(description);
                Grid.SetColumn(description, 2);
                Grid.SetRow(description, i + 1);

                Image placeImage = new Image();
                placeImage.Source = new BitmapImage(new Uri(@"appx:///Assets/0.png"));
                placeImage.HorizontalAlignment = HorizontalAlignment.Center;
                placeImage.VerticalAlignment   = VerticalAlignment.Center;
                MainGrid.Children.Add(placeImage);
                Grid.SetColumn(placeImage, 0);
                Grid.SetRow(placeImage, i + 1);

                if (i == 0)
                {
                    Cars[i] = Car.NapraviAuto(Account.CurrentAccount.Nickname, bar, description);
                }
                else if (i == teemoNum)
                {
                    Cars[i] = Car.NapraviAuto("Teemo", bar, description);
                }
                else
                {
                    NamesCollection names = NamesCollection.GetInstance();
                    await names.ReadNamesAsync();

                    Cars[i] = Car.NapraviAuto(names[RandomGen2.Next() % names.Names.Count], bar, description);
                }
            }
            MainGrid.RowDefinitions.Add(new RowDefinition());
            MainGrid.Children.Add(BackButton);

            ButtonStyle(BackButton, "BACK", 0, NumberOfCars + 1);
            ButtonStyle(StartRaceButton, "START RACE", 1, NumberOfCars + 1);
        }
 public MainWindow()
 {
     NamesCollection.Add(new NamesItem("Sport", "Chief"));
     InitializeComponent();
 }
예제 #4
0
        public async Task Initialize()
        {
            Bars.Clear();
            Cars = new Car[NumberOfCars];
            int teemoNum = RandomGen2.Next() % (NumberOfCars - 1) + 1;

            for (int i = 0; i < NumberOfCars; i++)
            {
                CarRaceBar bar = new CarRaceBar()
                {
                    Name                = "Progress" + i,
                    Maximum             = (double)Distance,
                    Margin              = new Thickness(50, 160 * i, 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Width               = 1200,
                    Height              = 80,
                };
                if (i == 0)
                {
                    await bar.SetColor(PlayerColor);
                }
                else
                {
                    await bar.SetColor(Color.FromArgb(255, (byte)(RandomGen2.Next() % 255),
                                                      (byte)(RandomGen2.Next() % 255), (byte)(RandomGen2.Next() % 255)));
                }
                Bars.Add(bar);
                Grid grid = new Grid()
                {
                    Name   = "Text" + i,
                    Margin = new Thickness(50, 80 * (2 * i + 1), 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Width  = 900,
                    Height = 80,
                };

                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(25, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(25, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(25, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(25, GridUnitType.Star)
                });

                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(30, GridUnitType.Pixel)
                });

                grid.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

                var textBlocks = new[]
                {
                    new TextBlock {
                        Text = ""
                    },
                    new TextBlock {
                        Text = ""
                    },
                    new TextBlock {
                        Text = ""
                    },
                    new TextBlock {
                        Text = ""
                    }
                };

                int index = 0;
                foreach (var textBlock in textBlocks)
                {
                    grid.Children.Add(textBlock);
                    textBlock.TextAlignment = TextAlignment.Center;
                    textBlock.Foreground    = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                    Grid.SetColumn(textBlock, index++);
                }

                TextBlock text = new TextBlock()
                {
                    Name = "Text" + i,
                    IsColorFontEnabled  = true,
                    Foreground          = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff)),
                    Margin              = new Thickness(50, 160 * i, 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Width  = 400,
                    Height = 80
                };
                Grid.Children.Add(bar);
                Grid.Children.Add(grid);
                Grid.Children.Add(text);

                StackPanel.Height += 80;
                if (i == 0)
                {
                    Cars[i] = Car.NapraviAuto(Account.CurrentAccount.Nickname, bar, textBlocks);
                }
                else if (i == teemoNum)
                {
                    Cars[i] = Car.NapraviAuto("Teemo", bar, textBlocks);
                }
                else
                {
                    NamesCollection names = NamesCollection.GetInstance();
                    await names.ReadNamesAsync();

                    Cars[i] = Car.NapraviAuto(names[RandomGen2.Next() % names.Names.Count], bar, textBlocks);
                }
            }
            Button.Margin = new Thickness(0, 160 * NumberOfCars, 0, 0);
            Button.HorizontalAlignment = HorizontalAlignment.Center;
            Button.VerticalAlignment   = VerticalAlignment.Top;
            Button.Width  = 100;
            Button.Height = 40;
        }