Пример #1
0
        /// <summary>
        /// Loads the connected waypoints islands.
        /// </summary>
        /// <param name="waypoints">The waypoints.</param>
        /// <param name="connector">The connector.</param>
        public void LoadConnectedWaypointsIslands(String[] waypoints, IWaypointConnector connector)
        {
            if (waypoints == null || waypoints.Length == 0)
            {
                throw new Exception("MapName cannot be null");
            }
            else if (connector.ConnectorType != ConnectorType.BETWEEN_COLLECTIONS_CONNECTEC)
            {
                throw new Exception("Wrong Type of Connector");
            }
            int toadd = 0;

            foreach (var item in waypoints)
            {
                WaypointsCollection w = XmlContentLoader.LoadXmlContent(item, col.GetType()) as WaypointsCollection;
                foreach (Waypoint way in w.IdWaypoint.Values)
                {
                    way.Id = way.Id + toadd;
                    way.NeightBorWaypointsId = way.NeightBorWaypointsId.Select((p1, p2) => p1 + toadd).ToList <int>();
                }

                IDictionary <int, Waypoint> xx = w.IdWaypoint.ToDictionary(t => t.Key + toadd, u => u.Value);
                w.IdWaypoint = new SerializableDictionary <int, Waypoint>(xx);
                toadd       += w.IdWaypoint.Keys.Max();
                this.col.IdWaypoint.Concate(w.IdWaypoint);
            }

            this.col = connector.ConnectWaypoints(col);
        }
 public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
 {
     WaypointsCollection resp = new WaypointsCollection(col.MapName);
     foreach (Waypoint item in col.GetWaypointsList())
     {
         item.NeightBorWaypointsId = new List<int>();
         foreach (Waypoint item2 in col.GetWaypointsList())
         {
             if (item.Id != item2.Id)
             {
                 Vector3 dir = item2.WorldPos - item.WorldPos;
                 if (dir.Length() < maxDistance)
                 {
                     float dist = dir.Length() * 1.2f;
                     dir.Normalize();
                     Ray raio = new Ray(item.WorldPos + new Vector3(0, altura, 0), dir);
                     SegmentInterceptInfo ri = world.PhysicWorld.SegmentIntersect(raio, (a) => true, dist);
                     if (ri != null)
                     {
                         continue;
                     }
                     else
                     {
                         
                         item.NeightBorWaypointsId.Add(item2.Id);
                     }
                 }
             }
         }
     }
     resp.State = WaypointsState.Connected;
     resp.IdWaypoint = col.IdWaypoint;
     return resp;
 }
        public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
        {
            WaypointsCollection resp = new WaypointsCollection(col.MapName);

            foreach (Waypoint item in col.GetWaypointsList())
            {
                item.NeightBorWaypointsId = new List <int>();
                foreach (Waypoint item2 in col.GetWaypointsList())
                {
                    if (item.Id != item2.Id)
                    {
                        Vector3 dir = item2.WorldPos - item.WorldPos;
                        if (dir.Length() < maxDistance)
                        {
                            float dist = dir.Length() * 1.2f;
                            dir.Normalize();
                            Ray raio = new Ray(item.WorldPos + new Vector3(0, altura, 0), dir);
                            SegmentInterceptInfo ri = world.PhysicWorld.SegmentIntersect(raio, (a) => true, dist);
                            if (ri != null)
                            {
                                continue;
                            }
                            else
                            {
                                item.NeightBorWaypointsId.Add(item2.Id);
                            }
                        }
                    }
                }
            }
            resp.State      = WaypointsState.Connected;
            resp.IdWaypoint = col.IdWaypoint;
            return(resp);
        }
Пример #4
0
        public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
        {
            int maxid = int.MinValue;
            int minid = int.MaxValue;

            foreach (int item in  col.IdWaypoint.Keys)
            {
                if (item < minid)
                {
                    minid = item;
                }
                if (item > maxid)
                {
                    maxid = item;
                }
            }

            WaypointsCollection resp = new WaypointsCollection(col.MapName);

            foreach (Waypoint item in col.GetWaypointsList())
            {
                item.NeightBorWaypointsId = new List <int>();
                if (item.Id == maxid)
                {
                    item.NeightBorWaypointsId.Add(minid);
                }
                else
                {
                    item.NeightBorWaypointsId.Add(item.Id + 1);
                }
                resp.IdWaypoint.Add(item.Id, item);
            }
            return(resp);
        }
        public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
        {
            int maxid = int.MinValue;
            int minid=int.MaxValue;
            foreach (int item in  col.IdWaypoint.Keys)
	        {
        		 if(item < minid)
                     minid = item;
                if(item>maxid)
                    maxid = item;
	        }

            WaypointsCollection resp = new WaypointsCollection(col.MapName);
            foreach (Waypoint item in col.GetWaypointsList())
            {
                item.NeightBorWaypointsId = new List<int>();
                if (item.Id == maxid)
                {
                    item.NeightBorWaypointsId.Add(minid);
                }
                else
                {                    
                    item.NeightBorWaypointsId.Add(item.Id + 1);
                }
                resp.IdWaypoint.Add(item.Id, item);
            }
            return resp;
        }
Пример #6
0
 /// <summary>
 /// Loads the unconnected waypoints.
 /// If it is connected, it will be unconnected
 /// </summary>
 /// <param name="FileName">Name of the file.</param>
 public void LoadUnconnectedWaypoints(String FileName)
 {
     if (FileName == null)
     {
         throw new Exception("MapName cannot be null");
     }
     this.col = XmlContentLoader.LoadXmlContent(FileName, col.GetType()) as WaypointsCollection;
     if (col.State == WaypointsState.Connected)
     {
         Unconnect();
     }
 }
Пример #7
0
        /// <summary>
        /// Loads the connected waypoints  from a file
        /// </summary>
        /// <param name="FileName">Name of the file.</param>
        public void LoadConnectedWaypoints(String FileName)
        {
            if (FileName == null)
            {
                throw new Exception("MapName cannot be null");
            }

            this.col = XmlContentLoader.LoadXmlContent(FileName, col.GetType()) as WaypointsCollection;
            foreach (Waypoint item in col.GetWaypointsList())
            {
                if (item.Id > id)
                {
                    id = item.Id + 1;
                }
            }
            col.State = WaypointsState.Connected;
        }
Пример #8
0
        /// <summary>
        /// Connects the waypoints in this handler
        /// </summary>
        /// <param name="connector">The connector.</param>
        public void ConnectWaypoints(IWaypointConnector connector)
        {
            if (connector == null)
            {
                throw new NullReferenceException("connector cannot be null");
            }

            if (connector.ConnectorType != ConnectorType.BETWEEN_WAYPOINTS_UNCONNECTED)
            {
                throw new Exception("Wrong Type of Connector");
            }

            if (col.State == WaypointsState.UnConnected)
            {
                col       = connector.ConnectWaypoints(col);
                col.State = WaypointsState.Connected;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WaypointHandler"/> class.
 /// </summary>
 /// <param name="mapName">Name of the map.</param>
 public WaypointHandler(String mapName = null)
 {
     col = new WaypointsCollection();
     col.MapName = mapName;
 }        
        /// <summary>
        /// Connects the waypoints in this handler
        /// </summary>
        /// <param name="connector">The connector.</param>
        public void ConnectWaypoints(IWaypointConnector connector)
        {
            if (connector == null)
                throw new NullReferenceException("connector cannot be null");

            if (connector.ConnectorType != ConnectorType.BETWEEN_WAYPOINTS_UNCONNECTED)
            {
                throw new Exception("Wrong Type of Connector");
            }

            if (col.State == WaypointsState.UnConnected)
            {
                col = connector.ConnectWaypoints(col);
                col.State = WaypointsState.Connected;
            }            
        }
 /// <summary>
 ///Restart the handler
 /// </summary>
 public void Clear()
 {
     col = new WaypointsCollection();        
 }
        /// <summary>
        /// Loads the unconnected waypoints.
        /// If it is connected, it will be unconnected
        /// </summary>
        /// <param name="FileName">Name of the file.</param>
        public void LoadUnconnectedWaypoints(String FileName)
        {
            if (FileName == null)
            {
                throw new Exception("MapName cannot be null");
            }            
            this.col =  XmlContentLoader.LoadXmlContent(FileName,col.GetType()) as WaypointsCollection;
            if(col.State == WaypointsState.Connected)
            Unconnect();

        }
        /// <summary>
        /// Loads the connected waypoints islands.
        /// </summary>
        /// <param name="waypoints">The waypoints.</param>
        /// <param name="connector">The connector.</param>
        public void LoadConnectedWaypointsIslands(String[] waypoints , IWaypointConnector connector)
        {
            if (waypoints==null || waypoints.Length == 0 )
            {
                throw new Exception("MapName cannot be null");
            }
            else if (connector.ConnectorType != ConnectorType.BETWEEN_COLLECTIONS_CONNECTEC)
            {
                throw new Exception("Wrong Type of Connector");
            }
            int toadd = 0;
            foreach (var item in waypoints)
            {
                WaypointsCollection w = XmlContentLoader.LoadXmlContent(item, col.GetType()) as WaypointsCollection;
                foreach (Waypoint way in w.IdWaypoint.Values)
                {
                    way.Id = way.Id + toadd;
                    way.NeightBorWaypointsId =  way.NeightBorWaypointsId.Select( (p1 , p2) => p1 + toadd).ToList<int>();                                                            
                }

                IDictionary<int,Waypoint> xx = w.IdWaypoint.ToDictionary(t => t.Key + toadd, u => u.Value);
                w.IdWaypoint = new SerializableDictionary<int, Waypoint>(xx);                   
                toadd+= w.IdWaypoint.Keys.Max();
                this.col.IdWaypoint.Concate(w.IdWaypoint);
            }

            this.col = connector.ConnectWaypoints(col);

        }
        /// <summary>
        /// Loads the connected waypoints  from a file
        /// </summary>
        /// <param name="FileName">Name of the file.</param>
        public void LoadConnectedWaypoints(String FileName)        
        {
            if (FileName == null)
            {
                throw new Exception("MapName cannot be null");
            }            
            
            this.col = XmlContentLoader.LoadXmlContent(FileName, col.GetType()) as WaypointsCollection;
            foreach (Waypoint item in col.GetWaypointsList())
            {             
                if (item.Id > id)
                {
                    id = item.Id + 1;
                }
            }
            col.State = WaypointsState.Connected;

        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WaypointHandler"/> class.
 /// </summary>
 /// <param name="mapName">Name of the map.</param>
 public WaypointHandler(String mapName = null)
 {
     col         = new WaypointsCollection();
     col.MapName = mapName;
 }
Пример #16
0
 public SimpleMap(WaypointsCollection col)
 {          
     this.ways = col;
 }
Пример #17
0
 public SimpleMap(WaypointsCollection col)
 {
     this.ways = col;
 }
Пример #18
0
        public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
        {
            WaypointsCollection resp = new WaypointsCollection(col.MapName);

            foreach (Waypoint item in col.GetWaypointsList())
            {
                item.NeightBorWaypointsId = new List <int>();
            }

            foreach (Waypoint item in col.GetWaypointsList())
            {
                float    dist       = float.MaxValue;
                float    dist2      = float.MaxValue;
                Waypoint candidate  = null;
                Waypoint candidate2 = null;
                foreach (Waypoint item2 in col.GetWaypointsList())
                {
                    Vector3 dir = item2.WorldPos - item.WorldPos;
                    dir.Normalize();
                    Ray raio = new Ray(item.WorldPos + new Vector3(0, altura, 0), dir);
                    SegmentInterceptInfo ri = world.PhysicWorld.SegmentIntersect(raio, (a) => true, maxDistance);
                    if (ri != null)
                    {
                        continue;
                    }
                    else
                    {
                        float distance = Vector3.Distance(item.WorldPos, item2.WorldPos);
                        if (distance < dist && item.Id != item2.Id)
                        {
                            if (item2.NeightBorWaypointsId.Count > 0)
                            {
                                if (item2.NeightBorWaypointsId[0] != item.Id)
                                {
                                    dist      = distance;
                                    candidate = item2;
                                }
                            }
                            else
                            {
                                dist      = distance;
                                candidate = item2;
                            }
                        }
                        else if (distance < dist2 && dist2 > dist && item.Id != item2.Id)
                        {
                            if (item2.NeightBorWaypointsId.Count > 0)
                            {
                                if (item2.NeightBorWaypointsId[0] != item.Id)
                                {
                                    dist2      = distance;
                                    candidate2 = item2;
                                }
                            }
                            else
                            {
                                dist2      = distance;
                                candidate2 = item2;
                            }
                        }
                    }
                }
                if (candidate != null)
                {
                    item.NeightBorWaypointsId.Add(candidate.Id);
                }
                else
                {
                }
            }

            resp.State      = WaypointsState.Connected;
            resp.IdWaypoint = col.IdWaypoint;
            return(resp);
        }
Пример #19
0
 /// <summary>
 ///Restart the handler
 /// </summary>
 public void Clear()
 {
     col = new WaypointsCollection();
 }
        public WaypointsCollection ConnectWaypoints(WaypointsCollection col)
        {
            WaypointsCollection resp = new WaypointsCollection(col.MapName);

            foreach (Waypoint item in col.GetWaypointsList())
            {
                item.NeightBorWaypointsId = new List<int>();
            }

            foreach (Waypoint item in col.GetWaypointsList())
            {             
                float dist = float.MaxValue;
                float dist2 = float.MaxValue;
                Waypoint candidate = null;
                Waypoint candidate2 = null;
                foreach (Waypoint item2 in col.GetWaypointsList())
                {
                    Vector3 dir = item2.WorldPos - item.WorldPos;
                    dir.Normalize();
                    Ray raio = new Ray(item.WorldPos + new Vector3(0, altura, 0), dir);
                    SegmentInterceptInfo ri = world.PhysicWorld.SegmentIntersect(raio, (a) => true, maxDistance);
                    if (ri != null)
                    {
                        continue;
                    }
                    else
                    {
                        float distance = Vector3.Distance(item.WorldPos, item2.WorldPos);
                        if (distance < dist && item.Id!= item2.Id )
                        {
                            if (item2.NeightBorWaypointsId.Count > 0)
                            {
                                if (item2.NeightBorWaypointsId[0] != item.Id)
                                {
                                    dist = distance;
                                    candidate = item2;
                                }
                            }
                            else
                            {
                                dist = distance;
                                candidate = item2;
                            }
                        }
                        else if (distance < dist2 && dist2 > dist && item.Id != item2.Id )
                        {
                            if (item2.NeightBorWaypointsId.Count > 0)
                            {
                                if (item2.NeightBorWaypointsId[0] != item.Id)
                                {
                                    dist2 = distance;
                                    candidate2 = item2;
                                }
                            }
                            else
                            {
                                dist2 = distance;
                                candidate2 = item2;
                            }
                            
                        }
                    }
                }
                if (candidate != null)
                {
                    item.NeightBorWaypointsId.Add(candidate.Id);
                }
                else
                {
                }
            }

            resp.State = WaypointsState.Connected;
            resp.IdWaypoint = col.IdWaypoint;
            return resp;
        }