示例#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);
        }
示例#2
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>
        /// 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>
        /// 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);

        }