Esempio n. 1
0
        public OrganismVisual(Organism source, Ellipse organism, Polygon sight, PointCollection boundaries, TextBlock energy)
        {
            this.source = source;

            source.OnDeath += source_OnDeath;

            this.organism = organism;

            this.boundaries = boundaries;

            this.energy = energy;

            organism.Dispatcher.Invoke(new Action(() => organism.Fill = new SolidColorBrush(Colors.Red)));
            organism.Dispatcher.Invoke(new Action(() => organism.Height = source.getSize()));
            organism.Dispatcher.Invoke(new Action(() => organism.Width = source.getSize()));

            this.sight = sight;
            sight.Dispatcher.Invoke(new Action(() => sight.Fill = new SolidColorBrush(Color.FromArgb(50, 200, 200, 200))));
            sight.Dispatcher.Invoke(new Action(() => sight.Points = boundaries));

            energy.Dispatcher.Invoke(new Action(() => energy.Foreground = new SolidColorBrush(Colors.White)));
            energy.Dispatcher.Invoke(new Action(() => energy.HorizontalAlignment = HorizontalAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.VerticalAlignment = VerticalAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.TextAlignment = TextAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.Height = 15));
            energy.Dispatcher.Invoke(new Action(() => energy.Width = 40));

            constructPointCollection();
        }