public override void Do()
        {
            if (akce_budovy == "Mnozeni")
            {
                List <Postava> pouzity = new List <Postava>();
                Postava        hleda   = new Postava();
                foreach (Postava milenec in pracovnici)
                {
                    bool je_pouzity = false;
                    foreach (Postava pouzita_postava in pouzity)
                    {
                        if (milenec == pouzita_postava)
                        {
                            je_pouzity = true;
                        }
                    }


                    if (!je_pouzity)
                    {
                        foreach (Postava milenka in pracovnici)
                        {
                            if (milenka != milenec)
                            {
                                bool je_pouzita = false;
                                foreach (Postava pouzita_postava in pouzity)
                                {
                                    if (milenka == pouzita_postava)
                                    {
                                        je_pouzita = true;
                                    }
                                    if (milenec.muzstvi != milenka.muzstvi)
                                    {
                                        je_pouzita = true;
                                    }
                                }
                                if (!je_pouzita)
                                {
                                    Postava novy = new Bezny_obyvatel {
                                        ID = Vesnice.Obyvatele.Count()
                                    };
                                    if (Vesnice.rnd_s.Next(1, 3) == 1)
                                    {
                                        novy.muzstvi = true;
                                    }
                                    else
                                    {
                                        novy.muzstvi = false;
                                    }
                                    Vesnice.Obyvatele.Add(novy);
                                    pouzity.Add(milenec);
                                    pouzity.Add(milenka);
                                }
                            }
                        }
                    }
                }
            }
            pracovnici = new List <Postava>();
        }
Beispiel #2
0
        public void vypis_postavu(Postava postava, int number_in_list)
        {
            Border okoli = new Border {
                BorderBrush = Brushes.Black, BorderThickness = new Thickness(3, 3, 3, 3), Width = 230, Height = 30, Margin = new Thickness(2, 2, 2, 2)
            };
            StackPanel obsah = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };
            Image obr = new Image()
            {
                Margin = new Thickness(5, 0, 5, 0), Height = 20, Width = 20
            };
            BitmapImage bit = new BitmapImage();

            bit.BeginInit();
            bit.UriSource = new Uri("../img/" + postava.obr_odkaz, UriKind.Relative);
            bit.EndInit();
            obr.Source = bit;
            obsah.Children.Add(obr);
            TextBlock Vek = new TextBlock()
            {
                Margin = new Thickness(5, 0, 5, 0), Text = "Věk: " + postava.vek
            };

            obsah.Children.Add(Vek);
            string pohlav = "pohlaví";

            if (postava.muzstvi)
            {
                pohlav = "muž";
            }
            else
            {
                pohlav = "žena";
            }
            TextBlock Pohlavi = new TextBlock()
            {
                Margin = new Thickness(5, 0, 5, 0), Text = " Pohlaví: " + pohlav
            };

            obsah.Children.Add(Pohlavi);
            Button button = new Button()
            {
                Margin = new Thickness(5, 0, 5, 0), Content = "X", Height = 20, FontWeight = FontWeights.Bold, Width = 20, Foreground = Brushes.Red, Name = "ID" + number_in_list
            };

            button.Click += new RoutedEventHandler(Odebrat_Click);
            obsah.Children.Add(button);

            okoli.Child = obsah;

            pracovnici.Children.Add(okoli);
        }