Пример #1
0
    public static void MapClear(int mapId, int clearPoint = 1)
    {
        Map clearMap = userMaps.Find(map => map.id == (mapId) || map.id.Equals(mapId));
        Map openMap  = maps.Find(map => map.id == (mapId + 1) || map.id.Equals(mapId + 1));

        if (clearMap != null)
        {
            clearMap.clearPoint = clearPoint;
            if (openMap != null)
            {
                userMaps.Add(openMap);
            }
            MapDatabase.AddMapClear(clearMap.id, openMap.id);
        }
        else
        {
            Debugging.LogWarning("클리어 할 맵을 찾지못함 >> " + mapId);
        }
    }
Пример #2
0
        /// <summary>
        /// Export SQL Script to delete orphan record
        /// </summary>
        /// <param name="database"></param>
        /// <param name="filePath"></param>
        public static void ExportScriptToDeleteOrphan(MapDatabase database, string filePath)
        {
            //
            // Initialize
            StreamWriter writer = null;

            try
            {
                writer = new StreamWriter(filePath);
            }
            catch (Exception excCreateStream)
            {
                LogService.Log.Error("Can not create stream writer at " + filePath, excCreateStream);
                return;
            }



            //
            // Write out
            string databaseName = database.GetDatabaseName();

            writer.WriteLine("USE [" + database.GetDatabaseName() + "]");
            writer.WriteLine("GO");
            foreach (ErrorRecord error in _listErrorRecords)
            {
                if (error.Type == ErrorType.Orphan)
                {
                    string script = GenerateDeleteScript(database, databaseName, error);
                    writer.WriteLine(script);
                    writer.WriteLine("GO");
                }
            }


            //
            // Clean
            writer.Close();
        }
Пример #3
0
    public static void LoadMap()
    {
        maps.Clear();
        userMaps.Clear();
        string      path   = Application.persistentDataPath + "/Xml/Map.Xml";
        MapDatabase md     = null;
        MapDatabase userMd = null;

        if (System.IO.File.Exists(path))
        {
            md     = MapDatabase.Load();
            userMd = MapDatabase.LoadUser();
        }
        else
        {
            md     = MapDatabase.InitSetting();
            userMd = MapDatabase.LoadUser();
        }
        if (md != null)
        {
            foreach (Map map in md.maps)
            {
                maps.Add(map);
            }
        }
        if (userMd != null)
        {
            foreach (Map map in userMd.maps)
            {
                userMaps.Add(map);
            }
        }
        if (maps != null && userMaps != null)
        {
            Debugging.LogSystem("MapDatabase is loaded Succesfully.");
        }
    }
Пример #4
0
        private void Awake()
        {
            DontDestroyOnLoad(gameObject);
            Instance = this;

            #if UNRELEASED
            var startingmem = GC.GetTotalMemory(true);

            //var folder = Path.Combine(Environment.CurrentDirectory, "userdata","streamcore");

            //List<FileInfo> files = new List<FileInfo>();  // List that will hold the files and subfiles in path
            //List<DirectoryInfo> folders = new List<DirectoryInfo>(); // List that hold direcotries that cannot be accessed

            //DirectoryInfo di = new DirectoryInfo(folder);

            //Dictionary<string, string> remap = new Dictionary<string, string>();

            //foreach (var entry in listcollection.OpenList("all.list").list)
            //    {
            //    //Instance.QueueChatMessage($"Map {entry}");

            //    string[] remapparts = entry.Split('-');
            //    if (remapparts.Length == 2)
            //    {
            //        int o;
            //        if (Int32.TryParse(remapparts[1], out o))
            //        {
            //            try
            //            {
            //                remap.Add(remapparts[0], o.ToString("x"));
            //            }
            //            catch
            //            { }
            //            //Instance.QueueChatMessage($"Map {remapparts[0]} : {o.ToString("x")}");
            //        }
            //    }
            //}

            //Instance.QueueChatMessage($"Scanning lists");

            //FullDirList(di, "*.deck");
            //void FullDirList(DirectoryInfo dir, string searchPattern)
            //{
            //    try
            //    {
            //        foreach (FileInfo f in dir.GetFiles(searchPattern))
            //        {
            //            var List = listcollection.OpenList(f.Name).list;
            //            for (int i=0;i<List.Count;i++)
            //                {
            //                if (remap.ContainsKey(List[i]))
            //                {
            //                    //Instance.QueueChatMessage($"{List[i]} : {remap[List[i]]}");
            //                    List[i] = remap[List[i]];
            //                }
            //                }
            //            listcollection.OpenList(f.Name).Writefile(f.Name);
            //        }
            //    }
            //    catch
            //    {
            //        Console.WriteLine("Directory {0}  \n could not be accessed!!!!", dir.FullName);
            //        return;
            //    }
            //}

            //NOTJSON.UNITTEST();
#endif

            playedfilename = Path.Combine(Plugin.DataPath, "played.dat"); // Record of all the songs played in the current session

            try
            {
                string filesToDelete = Path.Combine(Environment.CurrentDirectory, "FilesToDelete");
                if (Directory.Exists(filesToDelete))
                {
                    EmptyDirectory(filesToDelete);
                }


                try
                {
                    DateTime LastBackup;
                    if (!DateTime.TryParse(RequestBotConfig.Instance.LastBackup, out LastBackup))
                    {
                        LastBackup = DateTime.MinValue;
                    }
                    TimeSpan TimeSinceBackup = DateTime.Now - LastBackup;
                    if (TimeSinceBackup > TimeSpan.FromHours(RequestBotConfig.Instance.SessionResetAfterXHours))
                    {
                        Backup();
                    }
                }
                catch (Exception ex)
                {
                    Plugin.Log(ex.ToString());
                    Instance.QueueChatMessage("Failed to run Backup");
                }

                try
                {
                    TimeSpan PlayedAge = GetFileAgeDifference(playedfilename);
                    if (PlayedAge < TimeSpan.FromHours(RequestBotConfig.Instance.SessionResetAfterXHours))
                    {
                        played = ReadJSON(playedfilename);                                                                                // Read the songsplayed file if less than x hours have passed
                    }
                }
                catch (Exception ex)
                {
                    Plugin.Log(ex.ToString());
                    Instance.QueueChatMessage("Failed to clear played file");
                }

                if (RequestBotConfig.Instance.PPSearch)
                {
                    GetPPData();                                     // Start loading PP data
                }
                MapDatabase.LoadDatabase();

                if (RequestBotConfig.Instance.LocalSearch)
                {
                    MapDatabase.LoadCustomSongs(); // This is a background process
                }
                RequestQueue.Read();               // Might added the timespan check for this too. To be decided later.
                RequestHistory.Read();
                listcollection.OpenList("banlist.unique");

#if UNRELEASED
                //GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                //GC.Collect();
                //Instance.QueueChatMessage($"hashentries: {SongMap.hashcount} memory: {(GC.GetTotalMemory(false) - startingmem) / 1048576} MB");
#endif

                listcollection.ClearOldList("duplicate.list", TimeSpan.FromHours(RequestBotConfig.Instance.SessionResetAfterXHours));

                UpdateRequestUI();
                InitializeCommands();

                //EnhancedStreamChat.ChatHandler.ChatMessageFilters += MyChatMessageHandler; // TODO: Reimplement this filter maybe? Or maybe we put it directly into EnhancedStreamChat


                COMMAND.CommandConfiguration();
                RunStartupScripts();


                ProcessRequestQueue();

                RequestBotConfig.Instance.ConfigChangedEvent += OnConfigChangedEvent;
            }
            catch (Exception ex)
            {
                Plugin.Log(ex.ToString());
                Instance.QueueChatMessage(ex.ToString());
            }
        }
Пример #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var loc = (Location)value;

            return(Environment.CurrentDirectory + "/resources/images/maps/" + MapDatabase.GetMapId(loc.World, loc.Guard, loc.Section) + ".jpg");
        }
        /// <summary>
        /// Validate data
        /// </summary>
        /// <param name="recordValidation"></param>
        /// <param name="manager"></param>
        /// <param name="database"></param>
        public void Validate <T>(MappingManager manager, MapDatabase database) where T : RecordValidation, new()
        {
            T validator = new T();

            validator.Validate(manager, database);
        }
Пример #7
0
 void LeaveCurrentRoom()
 {
     PhotonNetwork.LeaveRoom();                      //only leave the Room no need to disconect
     MapDatabase.LoadMap(m_lobby);                   //go back to lobby
     Destroy(m_ddols);                               //destroy all ddols
 }
Пример #8
0
 //----------------------------------------------------------------------------
 void AddNewWildPokemon(int index)
 {
     MapDatabase.CreateNewWildPokemon(index);
 }
Пример #9
0
 public IEnumerator ReadArchive(ParseState state)
 {
     MapDatabase.LoadZIPDirectory();
     yield break;
 }
Пример #10
0
 /// <summary>
 /// Validate database
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="mapDatabase"></param>
 public override void Validate(MappingManager manager, MapDatabase mapDatabase)
 {
 }
Пример #11
0
        //Loaddata
        private void OpenFile(string _FilePath)
        {
            if (!File.Exists(_FilePath)) { Trace.WriteLine("file not exists " + _FilePath); return; }
            byte[] _Buffer = File.ReadAllBytes(_FilePath);
            MemoryStream _MemoryStream = new MemoryStream(_Buffer);
            _MapDatabase = (MapDatabase)_XmlSerializer.Deserialize(_MemoryStream);

            _InkCanvas.Strokes.Clear();

            InkCanvas.SetLeft(_CStartPos, _MapDatabase._CStartPos.X);
            InkCanvas.SetTop(_CStartPos, _MapDatabase._CStartPos.Y);
            InkCanvas.SetLeft(_TStartPos, _MapDatabase._TStartPos.X);
            InkCanvas.SetTop(_TStartPos, _MapDatabase._TStartPos.Y);
            for (int i = 0; i < _MapDatabase._Layers.Count; i++)
            {
                MapDatabase.Layer _Layer = _MapDatabase._Layers[i];
                InkCanvas _InkCanvas1 = (InkCanvas)_CanvasList.Children[i];
                foreach (MapDatabase.Image _DImage in _Layer._Images)
                {
                    Image _Image = new Image();
                    if (!File.Exists(_DImage.Path)) Debugger.Break();

                    BitmapImage _BitmapImage = new BitmapImage(new Uri(_DImage.Path, UriKind.Relative));
                    double a = _BitmapImage.Width;
                    _Image.Source = _BitmapImage;

                    _Image.Width = _DImage.Width;
                    _Image.Height = _DImage.Height;
                    InkCanvas.SetLeft(_Image, _DImage.X);
                    InkCanvas.SetTop(_Image, _DImage.Y);
                    _InkCanvas1.Children.Add(_Image);
                }
                foreach (MapDatabase.Polygon _Polygon in _Layer._Polygons)
                {
                    StylusPointCollection _StylusPointCollection = new StylusPointCollection();
                    foreach (Point _Point in _Polygon._Points)
                    {
                        StylusPoint _StylusPoint = new StylusPoint(_Point.X, _Point.Y);
                        _StylusPointCollection.Add(_StylusPoint);
                    }

                    CustomStroke _Stroke = new CustomStroke(_StylusPointCollection);
                    _Stroke.DrawingAttributes.Color = _Polygon._Color;
                    _InkCanvas1.Strokes.Add(_Stroke);
                }
            }
        }
Пример #12
0
 /// <summary>
 /// Validate database
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="mapDatabase"></param>
 public abstract void Validate(MappingManager manager, MapDatabase mapDatabase);
Пример #13
0
    //----------------------------------------------------------------------------
    protected override void OnInternalInspectorGUI()
    {
        MapDatabase.MapItem item = MapDatabase.GetMaByUniqueId(m_currentlySelected);

        if (item != null)
        {
            GUILayout.BeginVertical();
            {
                EditorGUILayout.LabelField("Map unique ID", item.m_uniqueId.ToString());
                item.m_levelIndex = EditorGUILayout.IntField("Map level index", item.m_levelIndex);

                item.m_name = EditorGUILayout.TextField("Map Name", item.m_name);

                item.m_mapPrefab = EditorGUILayout.ObjectField("Map prefab", item.m_mapPrefab, typeof(GameObject), false) as GameObject;

                // Attack list
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Encounterable wild Pokemons");
                    if (GUILayout.Button(m_listUnfolded ? "Hide" : "Show"))
                    {
                        m_listUnfolded = !m_listUnfolded;
                    }
                }
                GUILayout.EndHorizontal();

                if (m_listUnfolded)
                {
                    foreach (MapDatabase.MapWildPokemon element in item.m_wildPokemonList)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40));
                            element.m_pokemonId = EditorGUILayout.Popup(element.m_pokemonId, m_pokemonNames);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_minLvl = EditorGUILayout.IntField("Level min", element.m_minLvl);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_maxLvl = EditorGUILayout.IntField("Level max", element.m_maxLvl);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));
                            element.m_proba = EditorGUILayout.IntField("Encounter Proba", element.m_proba);
                            EditorGUILayout.LabelField(" ", GUILayout.Width(20));

                            if (GUILayout.Button("-"))
                            {
                                m_delete          = true;
                                m_elementToDelete = new KeyValuePair <int, MapDatabase.MapWildPokemon> (item.m_uniqueId, element);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.LabelField(" ", GUILayout.MaxWidth(40));
                        if (GUILayout.Button("+"))
                        {
                            AddNewWildPokemon(item.m_uniqueId);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();
        }

        // Delay deletion so we don't do it during the for each loop
        if (m_delete)
        {
            RemoveWildPokemon(m_elementToDelete.Key, m_elementToDelete.Value);
            m_delete = false;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Пример #14
0
 //----------------------------------------------------------------------------
 void RemoveWildPokemon(int index, MapDatabase.MapWildPokemon element)
 {
     MapDatabase.RemoveWildPokemon(index, element);
 }
Пример #15
0
        // BUG: Testing major changes. This will get seriously refactored soon.
        private async Task CheckRequest(RequestInfo requestInfo)
        {
            TwitchUser requestor = requestInfo.requestor;
            string     request   = requestInfo.request;

            string normalrequest = normalize.NormalizeBeatSaverString(requestInfo.request);

            var id = GetBeatSaverId(normalize.RemoveSymbols(ref request, normalize._SymbolsNoDash));

            if (id != "")
            {
                // Remap song id if entry present. This is one time, and not correct as a result. No recursion right now, could be confusing to the end user.
                if (songremap.ContainsKey(id) && !requestInfo.flags.HasFlag(CmdFlags.NoFilter))
                {
                    request = songremap[id];
                    QueueChatMessage($"Remapping request {requestInfo.request} to {request}");
                }

                string requestcheckmessage = IsRequestInQueue(normalize.RemoveSymbols(ref request, normalize._SymbolsNoDash));               // Check if requested ID is in Queue
                if (requestcheckmessage != "")
                {
                    QueueChatMessage(requestcheckmessage);
                    return;
                }

                if (RequestBotConfig.Instance.OfflineMode && RequestBotConfig.Instance.offlinepath != "" && !MapDatabase.MapLibrary.ContainsKey(id))
                {
                    foreach (string directory in Directory.GetDirectories(RequestBotConfig.Instance.offlinepath, id + "*"))
                    {
                        await MapDatabase.LoadCustomSongs(directory, id);

                        await Task.Run(async() =>
                        {
                            while (MapDatabase.DatabaseLoading)
                            {
                                await Task.Delay(25);
                            }
                        });

                        break;
                    }
                }
            }

            JSONNode result = null;

            string errorMessage = "";

            // Get song query results from beatsaver.com
            if (!RequestBotConfig.Instance.OfflineMode)
            {
                string requestUrl = (id != "") ? $"https://beatsaver.com/api/maps/detail/{normalize.RemoveSymbols(ref request, normalize._SymbolsNoDash)}" : $"https://beatsaver.com/api/search/text/0?q={normalrequest}";

                var resp = await Plugin.WebClient.GetAsync(requestUrl, System.Threading.CancellationToken.None);

                if (resp.IsSuccessStatusCode)
                {
                    result = resp.ConvertToJsonNode();
                }
                else
                {
                    errorMessage = $"Invalid BeatSaver ID \"{request}\" specified. {requestUrl}";
                }
            }

            SongFilter filter = SongFilter.All;

            if (requestInfo.flags.HasFlag(CmdFlags.NoFilter))
            {
                filter = SongFilter.Queue;
            }
            List <JSONObject> songs = GetSongListFromResults(result, request, ref errorMessage, filter, requestInfo.state.sort != "" ? requestInfo.state.sort : AddSortOrder.ToString());

            bool autopick = RequestBotConfig.Instance.AutopickFirstSong || requestInfo.flags.HasFlag(CmdFlags.Autopick);

            // Filter out too many or too few results
            if (songs.Count == 0)
            {
                if (errorMessage == "")
                {
                    errorMessage = $"No results found for request \"{request}\"";
                }
            }
            else if (!autopick && songs.Count >= 4)
            {
                errorMessage = $"Request for '{request}' produces {songs.Count} results, narrow your search by adding a mapper name, or use https://beatsaver.com to look it up.";
            }
            else if (!autopick && songs.Count > 1 && songs.Count < 4)
            {
                var msg = new QueueLongMessage(1, 5);
                msg.Header($"@{requestor.DisplayName}, please choose: ");
                foreach (var eachsong in songs)
                {
                    msg.Add(new DynamicText().AddSong(eachsong).Parse(BsrSongDetail), ", ");
                }
                msg.end("...", $"No matching songs for for {request}");
                return;
            }
            else
            {
                if (!requestInfo.flags.HasFlag(CmdFlags.NoFilter))
                {
                    errorMessage = SongSearchFilter(songs[0], false);
                }
            }

            // Display reason why chosen song was rejected, if filter is triggered. Do not add filtered songs
            if (errorMessage != "")
            {
                QueueChatMessage(errorMessage);
                return;
            }

            JSONObject song = songs[0];

            // Song requests should try to be current. If the song was local, we double check for a newer version

            //if ((song["downloadUrl"].Value == "") && !RequestBotConfig.Instance.OfflineMode )
            //{
            //    //QueueChatMessage($"song:  {song["id"].Value.ToString()} ,{song["songName"].Value}");

            //    yield return Utilities.Download($"https://beatsaver.com/api/maps/detail/{song["id"].Value.ToString()}", Utilities.DownloadType.Raw, null,
            //     // Download success
            //     (web) =>
            //     {
            //         result = JSON.Parse(web.downloadHandler.text);
            //         var newsong = result["song"].AsObject;

            //         if (result != null && newsong["version"].Value != "")
            //         {
            //             new SongMap(newsong);
            //             song = newsong;
            //         }
            //     },
            //     // Download failed,  song probably doesn't exist on beatsaver
            //     (web) =>
            //     {
            //         // Let player know that the song is not current on BeatSaver
            //         requestInfo.requestInfo += " *LOCAL ONLY*";
            //         ; //errorMessage = $"Invalid BeatSaver ID \"{request}\" specified. {requestUrl}";
            //     });

            //}

            RequestTracker[requestor.Id].numRequests++;
            listcollection.add(duplicatelist, song["id"].Value);
            if ((requestInfo.flags.HasFlag(CmdFlags.MoveToTop)))
            {
                RequestQueue.Songs.Insert(0, new SongRequest(song, requestor, requestInfo.requestTime, RequestStatus.Queued, requestInfo.requestInfo));
            }
            else
            {
                RequestQueue.Songs.Add(new SongRequest(song, requestor, requestInfo.requestTime, RequestStatus.Queued, requestInfo.requestInfo));
            }

            RequestQueue.Write();

            Writedeck(requestor, "savedqueue");     // This can be used as a backup if persistent Queue is turned off.

            if (!requestInfo.flags.HasFlag(CmdFlags.SilentResult))
            {
                new DynamicText().AddSong(ref song).QueueMessage(AddSongToQueueText.ToString());
            }

            Dispatcher.RunOnMainThread(() =>
            {
                UpdateRequestUI();
                _refreshQueue = true;
            });
        }
Пример #16
0
    public void Init(float sensitivity, float smoothing, float frustDist, float frustSegments, float circleRadius, int circleSegments)
    {
        // Constants
        this.sensitivity    = sensitivity;
        this.smoothing      = smoothing;
        this.frustDist      = frustDist;
        this.frustSegments  = frustSegments;
        this.circleRadius   = circleRadius;
        this.circleSegments = circleSegments;

        // Component variables variables
        character      = this.transform.parent.gameObject;
        charCamera     = this.GetComponentsInChildren <Camera>()[0];
        overviewCamera = this.GetComponentsInChildren <Camera>()[1];


        MapDatabaseScript = GameObject.FindObjectOfType(typeof(MapDatabase)) as MapDatabase;
        MasterGenScript   = GameObject.FindObjectOfType(typeof(MasterGen)) as MasterGen;
        blockSize         = MasterGenScript.block_VertexWidth;

        canTransformYView = true;

        // Sets up camera line renderers
        void SetupLine(GameObject line)
        {
            line.AddComponent <LineRenderer>();

            LineRenderer render = line.GetComponent <LineRenderer>();

            render.startWidth = lineWidth;
            render.endWidth   = lineWidth;
            render.enabled    = false;

            line.transform.parent = this.transform;
        }

        void SetupRadialLine(GameObject line)
        {
            line.AddComponent <LineRenderer>();

            LineRenderer render = line.GetComponent <LineRenderer>();

            render.positionCount = circleSegments + 1;
            render.useWorldSpace = false;
            render.startWidth    = lineWidth;
            render.endWidth      = lineWidth;
            render.enabled       = false;

            line.transform.parent = this.transform;
        }

        // Set up line variables
        lineWidth = overviewCamera.transform.position.y / 50f;

        // Create and setup camera lines
        leftLine   = new GameObject("Left Line");
        rightLine  = new GameObject("Right Line");
        centerLine = new GameObject("Center Line");
        radialLine = new GameObject("Radial Line");

        SetupLine(leftLine);
        SetupLine(rightLine);
        SetupLine(centerLine);
        SetupRadialLine(radialLine);
    }
Пример #17
0
        public IEnumerator RefreshSongs(ParseState state)
        {
            MapDatabase.LoadCustomSongs();

            yield break;
        }
Пример #18
0
        public HDMapReader(UTM utm, PointQ gpsCoordinate_previous)
        {
            //Reading HDMap.bin binary file from MapDatabase
            _mapDatabase = MapDatabase.LoadFromFile("HDMap.bin");

            //Extract Road Surfaces form MapDatabase
            System.Collections.ObjectModel.ReadOnlyCollection <RoadSurface> rsurf = new System.Collections.ObjectModel.ReadOnlyCollection <RoadSurface>(_mapDatabase.GetRoadSurfaces());

            //Initialize Pedestrian GPS coordinates of type PoinQ from Recorded Stream
            PointQ gpsCoordinates = new PointQ {
                X = utm.X, Y = utm.Y
            };

            Console.WriteLine();
            foreach (RoadSurface rs in rsurf)
            {
                //Initialize Polygon List
                List <PointQ> polygon = new List <PointQ>();

                //Initialize a list of type PointQ with all possible end points/coordinates
                List <PointQ> allEndPoints = new List <PointQ>();

                //Extract Accessors from Road Surfaces
                System.Collections.ObjectModel.ReadOnlyCollection <Accessor> accessors = new System.Collections.ObjectModel.ReadOnlyCollection <Accessor>(rs.GetAccessors());
                foreach (Accessor a in accessors)
                {
                    //Console.WriteLine("Id: " + a.Id.ToString());
                    // Console.WriteLine("LeftRoadSurface: " + a.LeftRoadSurface.ToString());
                    // Console.WriteLine("Line: " + a.Line.ToString());
                    // Console.WriteLine("Point A:" + a.Line.Begin.ToString());
                    // Console.WriteLine("Point B:" + a.Line.End.ToString());
                    // Console.WriteLine("RightRoadSurface: " + a.RightRoadSurface);
                    // Console.WriteLine("StartingConnections: " + a.StartingConnections.ToString());

                    //Creat Road surface points using Accessors as boundary points
                    PointQ strt = new PointQ();
                    strt.X = a.Line.Begin.X;
                    strt.Y = a.Line.Begin.Y;

                    PointQ finish = new PointQ();
                    finish.X = a.Line.End.X;
                    finish.Y = a.Line.End.Y;

                    polygon.Add(strt);
                    polygon.Add(finish);

                    //Extract Lanes Types
                    System.Collections.Generic.IList <Lane> lane = new List <Lane>(rs.GetLanes());
                    foreach (Lane l in lane)
                    {
                    }
                }
                //Extract Borders
                System.Collections.Generic.IList <Border>           border  = new List <Border>(rs.GetBorders());
                System.Collections.Generic.IList <IParametricCurve> outline = new List <IParametricCurve>(rs.GetOutline());
                //Extract Connections
                System.Collections.Generic.IList <TUC.Data.HDMap.Connection> connections = new List <TUC.Data.HDMap.Connection>(rs.GetConnections());

                foreach (Connection c in connections)
                {
                    //  Console.WriteLine("Connection 1 Begin Point: " + ((TUC.Data.HDMap.QuinticHermiteCurve)c.CenterCurve).Begin.ToString());
                    // Console.WriteLine("Connection 1 End Point: " + ((TUC.Data.HDMap.QuinticHermiteCurve)c.CenterCurve).End.ToString());

                    //Inialize Connection Points
                    PointQ begin = new PointQ();
                    begin.X = ((QuinticHermiteCurve)c.CenterCurve).Begin.X;
                    begin.Y = ((QuinticHermiteCurve)c.CenterCurve).Begin.Y;

                    PointQ end = new PointQ();
                    end.X = ((QuinticHermiteCurve)c.CenterCurve).End.X;
                    end.Y = ((QuinticHermiteCurve)c.CenterCurve).End.Y;

                    //List<PointQ> allBeginPoints = new List<PointQ>();

                    // List<PointQ> allEndPoints = new List<PointQ>();

                    allEndPoints.Add(begin);
                    allEndPoints.Add(end);

                    //  Console.WriteLine("All Points:" + allEndPoints.ToString());

                    //allEndPoints.Add(Connection.endpoint); // add all connection end points like this


                    //AlgorithProbabailty(gpsCoordinates, allPoints);
                    // allEndPoints.Add((TUC.Data.HDMap.QuinticHermiteCurve)c.CenterCurve).Begin;
                    // allEndPoints.Add((QuinticHermiteCurve)c.CenterCurve).Begin;
                    // allEndPoints.Add((TUC.Data.HDMap.QuinticHermiteCurve)c.CenterCurve).
                }
                //
                bool x = IsPointInPolygon(polygon, new PointQ {
                    X = utm.X, Y = utm.Y
                });
                if (x == true)
                {
                    Console.WriteLine("Pedestriian is Inside of Surface ID: " + rs.Id.ToString());
                    Console.ReadLine();
                    predictTrajectory(gpsCoordinates, allEndPoints, gpsCoordinate_previous);
                }
                else
                {
                    Console.WriteLine("Pedestrian is outside of surface ID: " + rs.Id.ToString());
                    Console.ReadLine();
                }

                // TrajectoryPredictor tp = new TrajectoryPredictor();

                //   tp.predictTrajectory(gpsCoordinates, allEndPoints);
                // tp.gpsCoordinate_previous = gpsCoordinates;
            }
        }
Пример #19
0
 public IEnumerator SaveSongDatabase(ParseState state)
 {
     MapDatabase.SaveDatabase();
     yield break;
 }
Пример #20
0
 //----------------------------------------------------------------------------
 protected override void AddToList(ReorderableList list)
 {
     MapDatabase.CreateNewMap();
     base.AddToList(list);
 }