Exemplo n.º 1
0
        /// <summary>
        /// Metoda pro vytvoreni elementu z koncoveho bodu cervi diry
        /// </summary>
        /// <param name="endpoint">Cervi dira ke zpracovani</param>
        /// <returns>Zpracovany element</returns>
        private static XElement EndpointToElement(WormholeEndpoint endpoint)
        {
            XElement wheElement = new XElement("wormholeEndpoint");

            wheElement.Add(new XAttribute("id", endpoint.Id));
            wheElement.Add(TrajectoryToElement(endpoint.Trajectory));

            return(wheElement);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Prida cervi diru do systemu
 /// </summary>
 /// <param name="newWormhole">Nova cervi dira</param>
 public void AddWormhole(WormholeEndpoint newWormhole)
 {
     if (newWormhole.StarSystem != null)
     {
         throw new ArgumentException("Zadana wormhole j*z ma definovany starsystem");
     }
     TryToSet();
     ((StarSystem)LoadedObject).WormholeEndpoints.Add(newWormhole);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Metoda ktera nastavi nove spojeni s jinou wormhole (nastavi se oboustrane)
 /// </summary>
 /// <param name="newEndpoint">Cilovy WormholeEndpoint</param>
 public void SetConnection(WormholeEndpoint newEndpoint)
 {
     TryToSet();
     if (!((WormholeEndpoint)LoadedObject).IsConnected)
     {
         Editor.Log("Prepisuji koncovou cervi diru!");
     }
     if (newEndpoint.Destination != null && newEndpoint.Destination != ((WormholeEndpoint)LoadedObject))
     {
         throw new ArgumentException("Cilova cervi dira je j*z pripojena k jine cervi dire, nejprve odstrante spojeni");
     }
     newEndpoint.Destination = ((WormholeEndpoint)LoadedObject);
     ((WormholeEndpoint)LoadedObject).Destination = newEndpoint;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Connects the wormhole in given map according to connection defined in this instance.
        /// </summary>
        /// <param name="map">The map on which this connection will be realised.</param>
        public void ConnectWormhole(GalaxyMap map)
        {
            WormholeEndpoint endpoint1 = GetConnectionEndpoint(map, this[0]);
            WormholeEndpoint endpoint2 = GetConnectionEndpoint(map, this[1]);

            if (endpoint1.IsConnected)
            {
                throw new GalaxyMapBuildingException(
                          String.Format("Endpoint already connected: {0} to {1}. Connection {2} cannot be set.",
                                        endpoint1, endpoint1.Destination, this)
                          );
            }

            if (endpoint2.IsConnected)
            {
                throw new GalaxyMapBuildingException(
                          String.Format("Endpoint already connected: {0} to {1}. Connection {2} cannot be set.",
                                        endpoint2, endpoint2.Destination, this)
                          );
            }

            endpoint1.ConnectTo(endpoint2);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the connection endpoint.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <param name="end">The end.</param>
        /// <returns></returns>
        /// <exception cref="GalaxyMapBuildingException">If endpoint cannot be found.</exception>
        private WormholeEndpoint GetConnectionEndpoint(GalaxyMap map, GalaxyMapConnectionEnd end)
        {
            StarSystem starSystem = map[end.StarSystemName];

            if (starSystem == null)
            {
                throw new GalaxyMapBuildingException(
                          String.Format("Invalid connection: {0}, star system '{1}' not found.",
                                        this, end.StarSystemName)
                          );
            }

            WormholeEndpoint endpoint = starSystem.WormholeEndpoints[end.WormholeEndpointId];

            if (endpoint == null)
            {
                throw new GalaxyMapBuildingException(
                          String.Format("Invalid connection: {0}, wormhole endpoint '{1}' not found in star system '{2}'.",
                                        this, end.WormholeEndpointId, end.StarSystemName)
                          );
            }

            return(endpoint);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Konstuktor zobrazovace
 /// </summary>
 /// <param name="endpoint"></param>
 public EndpointView(WormholeEndpoint endpoint)
 {
     this.WormholeEndpoint = endpoint;
 }