public PlanetIcon(CelestialObject planet, IMapIcon parentIcon, MapTab mapTab)
        {
            this.mapTab = mapTab;
            InitializeComponent();
            ParentIcon = parentIcon;
            Body       = planet;
            Canvas.SetZIndex(this, planet.Size);
            Label.Text     = planet.Name;
            Ellipse.Width  = Body.Size;
            Ellipse.Height = Body.Size;
            Ellipse.Fill   = Body.Brush;

            /*for (var i = 0; i < Body.MetalDensity*3; i++) {
             *  MetalPanel.Children.Add(new Ellipse { Width = 5, Height = 5, Fill = new SolidColorBrush(Colors.Gray), Margin = new Thickness(1) });
             * }
             * for (var i = 0; i < Body.FoodDensity*3; i++) {
             *  FoodPanel.Children.Add(new Ellipse { Width = 5, Height = 5, Fill = new SolidColorBrush(Colors.Green), Margin = new Thickness(1) });
             * }
             * for (var i = 0; i < Body.DarkMatterDensity*3; i++) {
             *  DarkMatterPanel.Children.Add(new Ellipse
             *                                   { Width = 5, Height = 5, Fill = new SolidColorBrush(Colors.Brown), Margin = new Thickness(1) });
             * }
             * for (var i = 0; i < Body.QuantiumDensity*3; i++) {
             *  QuantumPanel.Children.Add(new Ellipse { Width = 5, Height = 5, Fill = new SolidColorBrush(Colors.Purple), Margin = new Thickness(1) });
             * }
             * InfoText.Text = MakeDescription();
             * if (App.Player != null && Body.OwnerID != App.Player.PlayerID) {
             *  Structures.IsEnabled = false;
             *  Ships.IsEnabled = false;
             * }*/
        }
Пример #2
0
        public OrbitIcon(IMapIcon mapIcon, MapTab mapTab)
        {
            this.mapIcon = mapIcon;
            this.mapTab  = mapTab;
            InitializeComponent();
            ParentIcon = mapIcon.ParentIcon;

            maxOrbitRadius = mapIcon.Body.Children.Max(c => c.OrbitDistance) * MapTab.MapScale;

            foreach (var child in mapIcon.Body.Children)
            {
                var orbitRadius = child.OrbitDistance;
                var ellipse     = new Ellipse();
                ellipse.Stroke          = new SolidColorBrush(Colors.White);
                ellipse.StrokeThickness = strokeSize / mapTab.ZoomControl.Zoom;
                Canvas.SetLeft(ellipse, maxOrbitRadius - child.OrbitDistance * MapTab.MapScale);
                Canvas.SetTop(ellipse, maxOrbitRadius - child.OrbitDistance * MapTab.MapScale);
                ellipse.Width  = orbitRadius * 2 * MapTab.MapScale;
                ellipse.Height = orbitRadius * 2 * MapTab.MapScale;
                LayoutRoot.Children.Add(ellipse);
            }

            Canvas.SetZIndex(this, -1);

            if (mapIcon.Body.OrbitNestingLevel == 0)
            {
                // orbit doesn't move, just set the position once
                Canvas.SetLeft(this, mapIcon.X - maxOrbitRadius);
                Canvas.SetTop(this, mapIcon.Y - maxOrbitRadius);
            }

            Update();
        }
        public OrbitIcon(IMapIcon mapIcon, MapTab mapTab)
        {
            this.mapIcon = mapIcon;
            this.mapTab = mapTab;
            InitializeComponent();
            ParentIcon = mapIcon.ParentIcon;

            maxOrbitRadius = mapIcon.Body.Children.Max(c => c.OrbitDistance)*MapTab.MapScale;

            foreach (var child in mapIcon.Body.Children) {
                var orbitRadius = child.OrbitDistance;
                var ellipse = new Ellipse();
                ellipse.Stroke = new SolidColorBrush(Colors.White);
                ellipse.StrokeThickness = strokeSize/mapTab.ZoomControl.Zoom;
                Canvas.SetLeft(ellipse, maxOrbitRadius - child.OrbitDistance*MapTab.MapScale);
                Canvas.SetTop(ellipse, maxOrbitRadius - child.OrbitDistance*MapTab.MapScale);
                ellipse.Width = orbitRadius*2*MapTab.MapScale;
                ellipse.Height = orbitRadius*2*MapTab.MapScale;
                LayoutRoot.Children.Add(ellipse);
            }

            Canvas.SetZIndex(this, -1);

            if (mapIcon.Body.OrbitNestingLevel == 0) {
                // orbit doesn't move, just set the position once
                Canvas.SetLeft(this, mapIcon.X - maxOrbitRadius);
                Canvas.SetTop(this, mapIcon.Y - maxOrbitRadius);
            }

            Update();
        }
 void ProcessSatellites(IMapIcon parent, IEnumerable<CelestialObject> objects)
 {
     foreach (var body in objects.Where(o => o.ParentObject == parent.Body.CelestialObjectID)) {
         var icon = new PlanetIcon(body, parent, this);
         MapCanvas.Children.Add(icon); // add planet/moon/asteroid to canvas
         if (body.Children.Any()) MapCanvas.Children.Add(new OrbitIcon(icon, this)); // add orbits to canvas
         ProcessSatellites(icon, objects);
     }
 }
Пример #5
0
 void ProcessSatellites(IMapIcon parent, IEnumerable <CelestialObject> objects)
 {
     foreach (var body in objects.Where(o => o.ParentObject == parent.Body))
     {
         var icon = new PlanetIcon(body, parent, this);
         MapCanvas.Children.Add(icon); // add planet/moon/asteroid to canvas
         if (body.Children.Any())
         {
             MapCanvas.Children.Add(new OrbitIcon(icon, this));                      // add orbits to canvas
         }
         ProcessSatellites(icon, objects);
     }
 }
Пример #6
0
        public static MapIcon Create(IMapIcon iconObject)
        {
            var go      = new GameObject("KKMapIcon", typeof(MapIcon), typeof(Image));
            var mapIcon = go.GetComponent <MapIcon> ();
            var image   = go.GetComponent <Image> ();

            var rect = mapIcon.rectTransform;

            rect.SetParent(MapViewCanvasUtil.NodeContainer);
            rect.anchorMin = new Vector2(0, 0);
            rect.anchorMax = new Vector2(0, 0);
            rect.pivot     = new Vector2(0.5f, 0.5f);
            rect.sizeDelta = new Vector2(16, 16);

            mapIcon.iconObject = iconObject;
            mapIcon.image      = image;

            image.sprite = iconObject.Icon;

            return(mapIcon);
        }