示例#1
0
        private void runMap()
        {
            Out.put("Starting drawing agents..");

            List <Agent> agents = MapSync.getProducedAgents();
            Dictionary <int, UIElement> rectangles = null;
            bool init       = true;
            var  copyMap    = master.getMapCopy();
            var  clusterGen = new ClusterGenerator(clusterSize);
            var  clusters   = clusterGen.generateClusters(copyMap);

            //drawPaths(clusters);

            while (simulationRun)
            {
                agents = MapSync.getProducedAgents();
                this.Dispatcher.Invoke((Action)(() =>
                {
                    if (init)
                    {
                        drawClusters(clusters);
                        //drawPaths(clusters);
                        init = false;
                    }
                    rectangles = updateAgents(agents, rectangles);
                }));
            }

            this.Dispatcher.Invoke((Action)(() =>
            {
                disposeAgents();
            }));

            Out.put("Agent drawing stopped...");
        }
示例#2
0
    public static MethodInfo GetCluster(NodeEffectTypes[] types)
    {
        List <System.Reflection.MethodInfo> methods = new ClusterGenerator().GetType().GetMethods().Where(p => p.GetCustomAttributes(typeof(ClusterAttribute), false).Select(p2 => p2 as ClusterAttribute).Where(p2 => types.Intersect(p2.types).Count() > 0).ToList().Count > 0).ToList();
        Dictionary <System.Reflection.MethodInfo, double> method_weight = new Dictionary <System.Reflection.MethodInfo, double>();

        foreach (System.Reflection.MethodInfo method in methods)
        {
            method_weight.Add(method, method.GetCustomAttributes(typeof(ClusterAttribute), false).Select(p2 => p2 as ClusterAttribute).First().weight);
        }
        float choice     = UnityEngine.Random.Range(0, (float)method_weight.Sum(p => p.Value));
        float currentVal = 0;

        foreach (var pair in method_weight)
        {
            currentVal += (float)pair.Value;
            if (choice < currentVal)
            {
                return(pair.Key);
            }
        }
        if (methods.Count == 0)
        {
        }
        return(method_weight.First().Key);
    }
示例#3
0
    public static List <Node> FourDiamond(List <NodeConnection> allConnections, out Node startConn, out Node endConn)
    {
        List <Node> nodes = new List <Node>();
        Node        n1    = new Node()
        {
            Cord = new Vector2()
            {
                x = 0, y = 0.33f
            }
        };
        Node n2 = new Node()
        {
            Cord = new Vector2()
            {
                x = .175f, y = 0.5f
            }
        };
        Node n3 = new Node()
        {
            Cord = new Vector2()
            {
                x = -.175f, y = 0.5f
            }
        };
        Node n4 = new Node()
        {
            Cord = new Vector2()
            {
                x = 0f, y = 0.66f
            }
        };

        nodes.Add(n1);
        nodes.Add(n2);
        nodes.Add(n3);
        nodes.Add(n4);
        allConnections.Add(new NodeConnection()
        {
            n1 = n1, n2 = n2
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n1, n2 = n3
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n2, n2 = n4
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n3, n2 = n4
        });
        startConn = n1;
        endConn   = n4;
        ClusterGenerator.GenerateCluster(0, nodes);
        return(nodes);
    }
示例#4
0
        public TemplateResults execute(int x, int y)
        {
            List <Rect> cluster        = new ClusterGenerator().execute(0, 0, .95, .5);
            var         formattedRects = applyTemplate(cluster);

            formattedRects = selectHallways(formattedRects);
            formattedRects = selectEntrances(formattedRects);
            formattedRects = scaleRoomsAndHallways(formattedRects);
            formattedRects = removeDoubleWalls(formattedRects);


            return(formattedRects);
        }
示例#5
0
    public static List <Node> ThreeNode(List <NodeConnection> allConnections, out Node startConn, out Node endConn)
    {
        List <Node> nodes = new List <Node>();
        Node        n1    = new Node()
        {
            Cord = new Vector2()
            {
                x = 0.2f, y = 0.33f
            }
        };
        Node n2 = new Node()
        {
            Cord = new Vector2()
            {
                x = -0.3f, y = 0.5f
            }, notable = true
        };
        Node n3 = new Node()
        {
            Cord = new Vector2()
            {
                x = 0.2f, y = 0.66f
            }
        };

        nodes.Add(n1);
        nodes.Add(n2);
        nodes.Add(n3);
        allConnections.Add(new NodeConnection()
        {
            n1 = n1, n2 = n2
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n2, n2 = n3
        });
        startConn = n1;
        endConn   = n3;
        ClusterGenerator.GenerateCluster(0, nodes);
        return(nodes);
    }
示例#6
0
    public static List <Node> FiveNodeSingleConnection(List <NodeConnection> allConnections, out Node startConn, out Node endConn)
    {
        List <Node> nodes = new List <Node>();
        Node        n1    = new Node()
        {
            Cord = new Vector2()
            {
                x = .3f, y = 0.5f
            }
        };
        Node n2 = new Node()
        {
            Cord = new Vector2()
            {
                x = .175f, y = 0.5f
            }
        };
        Node n3 = new Node()
        {
            Cord = new Vector2()
            {
                x = 0f, y = 0.67f
            }
        };
        Node n4 = new Node()
        {
            Cord = new Vector2()
            {
                x = 0.085f, y = 0.33f
            }
        };
        Node n5 = new Node()
        {
            Cord = new Vector2()
            {
                x = -0.085f, y = 0.33f
            }
        };
        Node n6 = new Node()
        {
            Cord = new Vector2()
            {
                x = -.175f, y = 0.5f
            }, notable = true
        };

        nodes.Add(n1);
        nodes.Add(n2);
        nodes.Add(n3);
        nodes.Add(n4);
        nodes.Add(n5);
        nodes.Add(n6);
        allConnections.Add(new NodeConnection()
        {
            n1 = n1, n2 = n2
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n2, n2 = n3
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n3, n2 = n6
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n2, n2 = n4
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n4, n2 = n5
        });
        allConnections.Add(new NodeConnection()
        {
            n1 = n5, n2 = n6
        });
        startConn = n1;
        endConn   = n1;
        ClusterGenerator.GenerateCluster(0, nodes);
        return(nodes);
    }
        private async void Init()
        {
            var settings = await _settingsService.GetSettingsAsync();
            if (settings.LastLocation != null && settings.LastLocation.ZoomLevel != 0)
            {
                MapCtrl.Center = new Geopoint(new BasicGeoposition { Latitude = _settingsService.Settings.LastLocation.Latitude, Longitude = _settingsService.Settings.LastLocation.Longitude });
                MapCtrl.ZoomLevel = _settingsService.Settings.LastLocation.ZoomLevel;
            }

           StatusBar.GetForCurrentView().BackgroundOpacity = 0.4;
#if DEBUG
            //MapCtrl.Center = new Geopoint(new BasicGeoposition { Latitude = 48.8791, Longitude = 2.354 });
            //MapCtrl.Center = new Geopoint(new BasicGeoposition { Latitude = 36.40, Longitude = 119.20 });
            //MapCtrl.ZoomLevel = 15.5;
#endif
            // leave the UI loading the page
            await Task.Delay(50);

            if (_settingsService.Settings.IsLocalisationOn)
            {
                EnableLocalization();
            }
            clusterGenerator = new ClusterGenerator(MapCtrl, Resources["StationTemplate"] as ControlTemplate);

            (DataContext as MainViewModel).FireGoToFavorite += MainPage_FireGoToFavorite;
            (DataContext as MainViewModel).LoadPreviousTile();

           _notificationService.OnNotify += _notificationService_OnNotify;

            HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            NorthIndicatorStoryboard = Resources["NorthIndicatorStoryboard"] as Storyboard;
            NorthIndicatorRotationAnimation = NorthIndicatorStoryboard.Children.First() as DoubleAnimation;

            UserLocationStoryboard = Resources["UserLocationStoryboard"] as Storyboard;
            UserLocationRotationAnimation = UserLocationStoryboard.Children.First() as DoubleAnimation;

            AccuracyStoryboard = Resources["AccuracyStoryboard"] as Storyboard;
            AccuracyScaleX = AccuracyStoryboard.Children[0] as DoubleAnimation;
            AccuracyScaleY = AccuracyStoryboard.Children[1] as DoubleAnimation;

            if (compass != null)
            {
                compass.ReportInterval = 200;
                compass.ReadingChanged -= compass_ReadingChanged;
                compass.ReadingChanged += compass_ReadingChanged;
                VisualStateManager.GoToState(this, "compassState", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "noCompassState", true);
            }

            MapCtrl.DoubleTapped += MapCtrl_DoubleTapped;
            Observable.FromEventPattern(MapCtrl, "HeadingChanged")
                            .Throttle(TimeSpan.FromMilliseconds(100))
                            .Subscribe(x =>
                            {
                                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    if (MapCtrl.Heading != 0)
                                    {
                                        VisualStateManager.GoToState(this, "NorthIndicatorVisible", true);
                                    }
                                    else
                                    {
                                        VisualStateManager.GoToState(this, "NorthIndicatorHidden", true);
                                    }
                                    UpdateNorthElementAngle(MapCtrl.Heading);
                                });
                            });


            Observable.FromEventPattern(MapCtrl, "ZoomLevelChanged")
                                    .Throttle(TimeSpan.FromMilliseconds(200))
                                    .Subscribe(x =>
                                    {
                                        Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                        {
                                            refreshAccuracyIndicator();
                                        });
                                    });
            TouchPanel.Holding += TouchPanel_Holding;
            TouchPanel.ManipulationStarted += TouchPanel_ManipulationStarted;
            TouchPanel.ManipulationStarting += TouchPanel_ManipulationStarting;

            // trigger a map center changed to refresh the view
            Map.Center = new Geopoint(new BasicGeoposition() { Longitude = Map.Center.Position.Longitude + 0.000001, Latitude = Map.Center.Position.Latitude });

            _mapLoaded.SetResult(true);
        }