Beispiel #1
0
        private static void AddPathToNetwork(TunnelNetwork.IPath _path)
        {
            //Get all nets that this path crosses/touches
            var crossedNets = new HashSet <TunnelNetwork>();

            foreach (var tNet in m_Tilemap.m_Tunnels)
            {
                if (tNet.Intersects(_path))
                {
                    crossedNets.Add(tNet);
                }
            }

            //If path doesn't cross any existing nets then add it to a new one.
            if (crossedNets.Count == 0)
            {
                m_Tilemap.m_Tunnels.Add(new TunnelNetwork(_path));
                return;
            }

            //Remove crossed nets from map and Create new net with them + this path
            var newNet = new TunnelNetwork(crossedNets, _path);

            foreach (var tNet in crossedNets)
            {
                m_Tilemap.m_Tunnels.Remove(tNet);
            }

            m_Tilemap.m_Tunnels.Add(newNet);
        }
Beispiel #2
0
 public bool Intersects(TunnelNetwork _tunnel)
 {
     foreach (ISegment segment in Segments)
     {
         foreach (ISegment newSegment in _tunnel.Segments)
         {
             if (segment.Intersects(newSegment))
             {
                 return(true);
             }
         }
     }
     return(false);
 }