예제 #1
0
 private void ElelineFollow()
 {
     if (m_obj != null)
     {
         var lLeap = m_obj.m_HaveLeap;
         foreach (var item in lLeap)
         {
             if (item != null)
             {
                 NDCircuitLeap cl = item.GetComponent <NDCircuitLeap>();
                 if (cl)
                 {
                     var lLine = cl.GetLinkLine();
                     foreach (var item1 in lLine)
                     {
                         if (item1 != null)
                         {
                             item1.m_LineAction.SetLeapPos();
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
    /// <summary>
    /// 元器件有连入电路
    /// </summary>
    /// <returns></returns>
    public override bool CheckConnect()
    {
        //坏掉也不具有连通性
        //临时屏蔽
        if (State == LabObjectState.Broken)
        {
            return(false);
        }
        bool Isleadout = false;
        bool IsleadIn  = false;

        foreach (NDleapObject leap in m_HaveLeap)
        {
            if (leap != null && leap is NDCircuitLeap)
            {
                NDCircuitLeap l = leap as NDCircuitLeap;
                if (l.HaveLine == false)
                {
                    continue;
                }
                bool lineIn = CheckLineInConnect(leap);
                if (l.m_Type == ElementLeapType.leadOut)
                {
                    Isleadout = true && lineIn;
                }
                if (l.m_Type == ElementLeapType.leadIn)
                {
                    IsleadIn = true && lineIn;
                }
            }
        }
        return(Isleadout && IsleadIn);
    }
예제 #3
0
파일: EleLine.cs 프로젝트: 741645596/Lab
    /// <summary>
    /// 是否是有用的元器件
    /// </summary>
    /// <returns></returns>
    public override bool Useful()
    {
        NDCircuitLeap leap1 = StartLineLeap.Link;
        NDCircuitLeap leap2 = EndLineLeap.Link;

        if (leap1 == null)
        {
            return(false);
        }
        if (leap2 == null)
        {
            return(false);
        }

        if (leap1.m_Parent != leap2.m_Parent)
        {
            return(true);
        }
        else
        {
            if (leap1.m_Type == leap2.m_Type)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
    }
예제 #4
0
    /// <summary>
    /// 获取连接的另外一个端口。
    /// </summary>
    public int GetLinkOtherObjID()
    {
        if (Line == null)
        {
            return(-1);
        }
        NDCircuitLeap leap1 = Line.StartLineLeap.Link;
        NDCircuitLeap leap2 = Line.EndLineLeap.Link;

        //必须2端都连接的导线
        if (leap1 != null && leap2 != null)
        {
            if (leap1.m_Parent.LabObjID == leap2.m_Parent.LabObjID)
            {
                return(-1);
            }
            else
            {
                if (leap1.m_Parent.LabObjID == this.LabID && leap1.m_Type == this.Type)
                {
                    return(leap2.m_Parent.LabObjID);
                }
                else if (leap2.m_Parent.LabObjID == this.LabID && leap2.m_Type == this.Type)
                {
                    return(leap1.m_Parent.LabObjID);
                }
            }
        }
        return(-1);
    }
예제 #5
0
    /// <summary>
    /// 构建电路
    /// </summary>
    public void JionCircuit(ref Circuit sim)
    {
        if (sim == null)
        {
            return;
        }
        foreach (EleLine line in m_linkEleLine)
        {
            if (line == null || line.ConnectLink != true)
            {
                continue;
            }
            NDCircuitLeap other = line.GetOtherElementLeap(this);
            if (other == null || other.m_Parent == null)
            {
                continue;
            }

            CircuitElement myCircuit    = LabObjectDataFactory.GetCircuit(m_Parent.LabObjID);
            CircuitElement OtherCircuit = LabObjectDataFactory.GetCircuit(other.m_Parent.LabObjID);


            if (myCircuit == null || OtherCircuit == null)
            {
                return;
            }

            if (m_Type == ElementLeapType.leadOut)
            {
                if (other.m_Type == ElementLeapType.leadIn)
                {
                    sim.Connect(myCircuit.leadOut, OtherCircuit.leadIn);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadOut]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadIn]");
                }
                else
                {
                    sim.Connect(myCircuit.leadOut, OtherCircuit.leadOut);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadOut]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadOut]");
                }
            }
            else
            {
                if (other.m_Type == ElementLeapType.leadIn)
                {
                    sim.Connect(myCircuit.leadIn, OtherCircuit.leadIn);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadIn]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadIn]");
                }
                else
                {
                    sim.Connect(myCircuit.leadIn, OtherCircuit.leadOut);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadIn]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadOut]");
                }
            }
        }
    }
예제 #6
0
파일: EleLine.cs 프로젝트: 741645596/Lab
 public void RemoveLinkLeap(NDCircuitLeap leap)
 {
     if (StartLineLeap.Link != null && StartLineLeap.Link == leap)
     {
         StartLineLeap.Link = null;
     }
     else if (EndLineLeap.Link != null && EndLineLeap.Link == leap)
     {
         EndLineLeap.Link = null;
     }
 }
예제 #7
0
파일: NDLineLeap.cs 프로젝트: 741645596/Lab
    /// <summary>
    /// 检测线是否连接的是接线柱
    /// </summary>
    public void ShowCanLinkLeap()
    {
        NDCircuitLeap leap = null;

        if (Link == null)
        {
            leap = FindNearLeap();
        }
        if (leap != null)
        {
            leap.ShowCylinder(true);
        }
    }
예제 #8
0
 public static void RemoveElementLeap(NDCircuitLeap Leap)
 {
     if (Leap == null)
     {
         return;
     }
     if (g_leap == null)
     {
         return;
     }
     if (g_leap.Contains(Leap) == true)
     {
         g_leap.Remove(Leap);
     }
 }
예제 #9
0
 /// <summary>
 /// 添加接入点
 /// </summary>
 public static void AddElementLeap(NDCircuitLeap Leap)
 {
     if (Leap == null)
     {
         return;
     }
     if (g_leap == null)
     {
         return;
     }
     if (g_leap.Contains(Leap) == false)
     {
         g_leap.Add(Leap);
     }
 }
예제 #10
0
파일: EleLine.cs 프로젝트: 741645596/Lab
 public void BeakLinkLeap(NDCircuitLeap leap)
 {
     if (leap != null)
     {
         NDLineLeap l = null;
         if (leap == StartLineLeap.Link)
         {
             StartLineLeap.SetBreakPos(leap.transform);
             StartLineLeap.Link = null;
         }
         else if (leap == EndLineLeap.Link)
         {
             EndLineLeap.SetBreakPos(leap.transform);
             EndLineLeap.Link = null;
         }
         leap.RemoveLinkLine(this);
         m_LineAction.SetControling();
     }
 }
예제 #11
0
파일: EleLine.cs 프로젝트: 741645596/Lab
 /// <summary>
 /// 获取导线的另一端接头
 /// </summary>
 public NDCircuitLeap GetOtherElementLeap(NDCircuitLeap leap)
 {
     if (leap == null)
     {
         return(null);
     }
     if (leap == StartLineLeap.Link)
     {
         return(EndLineLeap.Link);
     }
     else if (leap == EndLineLeap.Link)
     {
         return(StartLineLeap.Link);
     }
     else
     {
         return(null);
     }
 }
예제 #12
0
    public bool CheckLineInConnect(NDleapObject leap)
    {
        if (leap != null && leap is NDCircuitLeap)
        {
            NDCircuitLeap l = leap as NDCircuitLeap;
            if (l.HaveLine == false)
            {
                return(false);
            }
            foreach (EleLine line in l.LinkLine)
            {
                if (line.ConnectLink)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
예제 #13
0
    public static NDCircuitLeap FindNearLeap()
    {
        float                distance = ConstantData.m_fHighlightDistance;
        NDCircuitLeap        near     = null;
        List <NDCircuitLeap> l        = GetAllLeap();

        foreach (NDCircuitLeap v in l)
        {
            if (v == null)
            {
                continue;
            }
            float d = v.ScreenDistance;
            if (d <= distance)
            {
                near     = v;
                distance = d;
            }
        }
        return(near);
    }
예제 #14
0
파일: NDLineLeap.cs 프로젝트: 741645596/Lab
    /// <summary>
    /// 查找附近的导线接线头
    /// </summary>
    public NDCircuitLeap FindNearLeap()
    {
        float distance            = ConstantData.m_fHighlightDistance;
        List <NDCircuitLeap> l    = GetAllLeap();
        NDCircuitLeap        near = null;

        foreach (NDCircuitLeap v in l)
        {
            if (v == null)
            {
                continue;
            }
            //forbidden the two LineLeap of line link to one circutLeap.  link to one eleMent by identical type of CircuitLeapType is also not allowed.
            EleLine line = m_Parent as EleLine;
            if (line.StartLineLeap.Link != null)
            {
                if (v.m_Parent == line.StartLineLeap.Link.m_Parent && v.m_Type == line.StartLineLeap.Link.m_Type)
                {
                    continue;
                }
            }
            else if (line.EndLineLeap.Link != null)
            {
                if (v.m_Parent == line.EndLineLeap.Link.m_Parent && v.m_Type == line.EndLineLeap.Link.m_Type)
                {
                    continue;
                }
            }

            float d = CalcDistance(v, this);
            if (d <= distance)
            {
                near     = v;
                distance = d;
            }
        }
        return(near);
    }