public static void UnRegeditMove(LabObjectDragMove move, NDlabObject obj)
 {
     if (m_lMove.ContainsKey(obj))
     {
         m_lMove.Remove(obj);
     }
 }
 public static void RegeditMove(LabObjectDragMove move, NDlabObject obj)
 {
     if (!m_lMove.ContainsKey(obj))
     {
         m_lMove.Add(obj, move);
     }
 }
Exemple #3
0
    private void SetLinkInfo(CircuitObject Info)
    {
        m_LineAction.SetCtrlPositionInfo(Info.GetCtrlInfo());

        foreach (NDleapObject leap in m_HaveLeap)
        {
            if (leap == null)
            {
                continue;
            }
            LeapObject obj = Info.GetLinkInfo(leap.LeapIndex);
            if (obj != null)
            {
                //link
                NDlabObject lab = NDlabObject.FindLabObject(obj.linkCircuitObjectID);
                if (lab != null && lab is NDCircuitObject)
                {
                    NDleapObject leapobj = (lab as NDCircuitObject).FindLeap(obj.linkCircuitLeapIndex);
                    if (leapobj != null && leapobj is NDCircuitLeap)
                    {
                        (leap as NDLineLeap).Link = (leapobj as NDCircuitLeap);
                        (leapobj as NDCircuitLeap).AddLinkLine(this);
                    }
                }
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// 获取连接的导线,
    /// </summary>
    public List <CircuitNodeLine> GetLinkLineNode()
    {
        List <CircuitNodeLine> lLineNode = new List <CircuitNodeLine>();

        NDlabObject obj = NDlabObject.FindLabObject(this.LabID);

        if (obj == null || (obj is NDCircuitObject) == false)
        {
            return(lLineNode);
        }

        NDCircuitObject cirobj = (obj as NDCircuitObject);
        List <EleLine>  l      = cirobj.GetLeapLinkLine(this.Type);

        foreach (EleLine v in l)
        {
            if (v == null)
            {
                continue;
            }

            lLineNode.Add(new CircuitNodeLine(this, v));
        }
        return(lLineNode);
    }
Exemple #5
0
    /// <summary>
    /// Add highlight obj(exclude others)
    /// </summary>
    public static void AddHighlightLabObj(NDlabObject obj, bool multiSelect = false)
    {
        if (obj is EleLine)//exclude Eleline
        {
            return;
        }
        bool bContain = m_lHighlightLabObj.Contains(obj);
        int  count    = m_lHighlightLabObj.Count;

        if (multiSelect == false)
        {
            ClearAllHighlightLabObj();
        }

        if (bContain && multiSelect == true)
        {
            m_lHighlightLabObj.Remove(obj);
        }
        else if (bContain && multiSelect == false)
        {
            if (count > 1)
            {
                m_lHighlightLabObj.Add(obj);
            }
        }
        else if (!bContain)
        {
            m_lHighlightLabObj.Add(obj);
        }
    }
Exemple #6
0
 protected void JoinLabObject()
 {
     NDlabObject.AddLabObj(ID, this);
     LabObjectDataFactory.AddCircuit(ID, GetLabObjType());
     if (!(this is EleLine))//导线不加入元器件层级管理
     {
         SetInitDepth();
     }
 }
Exemple #7
0
 /// <summary>
 /// 获取某个元件类型的创建总量
 /// </summary>
 public static int GetNumberNameTotalCount(NDlabObject obj)
 {
     foreach (var item in g_lNumberNameData)
     {
         if (item.LabObjectType == obj.LabObjectType)
         {
             return(item.TotalCount);
         }
     }
     return(0);
 }
Exemple #8
0
 public static void RemoveHighlightLabObj(NDlabObject obj)
 {
     if (obj is EleLine)//exclude Eleline
     {
         return;
     }
     if (m_lHighlightLabObj.Contains(obj))
     {
         m_lHighlightLabObj.Remove(obj);
     }
 }
Exemple #9
0
    /// <summary>
    /// load circuti data from path
    /// </summary>
    public override NDlabObject LoadPerfab(Transform parent)
    {
        NDlabObject n = LabObjectFactory.LoadObjType(this.ObjType, parent);

        if (n == null)
        {
            return(null);
        }
        if (n is NDCircuitObject)
        {
            (n as NDCircuitObject).SetData(this);
        }
        return(n);
    }
Exemple #10
0
 protected static void AddLabObj(int ID, NDlabObject obj)
 {
     if (obj == null)
     {
         return;
     }
     if (g_AllLabObject.ContainsKey(ID) == true)
     {
         Debug.Log("已经存在");
         return;
     }
     g_AllLabObject.Add(ID, obj);
     CalcNumberNameData(obj);
 }
Exemple #11
0
    private void DoTopMost()
    {
        NDlabObject obj = GetComponent <NDlabObject>();

        if (obj is EleLine)
        {
            return;
        }

        if (obj != null)
        {
            obj.SetTopDepth();
        }
    }
Exemple #12
0
    /// <summary>
    /// 电路是否是闭合的。
    /// </summary>
    /// <returns></returns>
    public static bool CheckCircuitLoop()
    {
        //获取联通的电源
        List <NDlabObject> l = NDlabObject.SearchLabObject(SearchCicuitType.Power, true);

        foreach (NDlabObject Lab in l)
        {
            if (Lab == null)
            {
                continue;
            }
            if ((Lab as CurrentSourceElement).CheckConnectLoop() == true)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #13
0
    private static bool CheckSameType(NDlabObject obj, SearchCicuitType type, bool IsConnect)
    {
        if (obj == null)
        {
            return(false);
        }

        if (IsConnect == true)
        {
            if (obj.CheckConnect() == false)
            {
                return(false);
            }
        }

        //类型需匹配
        if (type == SearchCicuitType.All)
        {
            return(true);
        }
        else if (type == SearchCicuitType.ELELINE)
        {
            if (obj is EleLine)
            {
                return(true);
            }
        }
        else if (type == SearchCicuitType.NormalCircuit)
        {
            bool b = (obj is EleLine);
            if (b == false)
            {
                return(true);
            }
        }
        else if (type == SearchCicuitType.Power)
        {
            if (obj is CurrentSourceElement)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #14
0
    /// <summary>
    /// 记录创建同类型元件的总量
    /// </summary>
    protected static void CalcNumberNameData(NDlabObject obj)
    {
        bool exist = false;

        for (int i = 0; i < g_lNumberNameData.Count; i++)
        {
            if (g_lNumberNameData[i].LabObjectType == obj.LabObjectType)
            {
                NumberNameData data = new NumberNameData(obj.LabObjectType, g_lNumberNameData[i].TotalCount + 1);
                g_lNumberNameData[i] = data;
                exist = true;
            }
        }
        if (!exist)
        {
            NumberNameData data = new NumberNameData(obj.LabObjectType, 1);
            g_lNumberNameData.Add(data);
        }
    }
Exemple #15
0
    void Start()
    {
        if (m_labObject == null)
        {
            m_labObject = GetComponent <NDlabObject>();
        }

        if (m_labObject != null)
        {
            LabObjectOperateCenter.RegeditMove(this, m_labObject);
            if (m_labObject is EleLine)
            {
                m_labCamera = LabEnv.GetCameraByType(CameraType.WireCamera);
            }
            else
            {
                m_labCamera = LabEnv.GetCameraByType(CameraType.LabCamera);
            }
        }
    }
Exemple #16
0
    /// <summary>
    /// 设置元器件新的深度值,这常常是点选元器件后需要将其置顶
    /// </summary>
    public void SetTopDepth()
    {
        //如果当前没有两个及其以上对象,则不需要设置深度
        if (g_Depth.Count < 2)
        {
            return;
        }
        //如果是最高那个,则不需要设置深度
        int topMostDepth = FindTopMostDepth();

        if (topMostDepth >= m_iDepth)
        {
            return;
        }
        int index = FindIndex(ID);

        if (index == -1)//如果未找到当前组件,则报出异常
        {
            return;
        }
        int startIndex = MinDepth;

        for (int i = 0; i < g_Depth.Count; i++)//设置其他元器件深度
        {
            DepthData item = g_Depth[i];
            if (item.ID == ID)
            {
                startIndex++;
                continue;
            }
            NDlabObject obj = FindLabObject(item.ID);
            if (obj != null)
            {
                obj.SetDepth(startIndex - i);
            }
        }
        SetDepth(topMostDepth);//设置自身置顶深度
    }
Exemple #17
0
    public static void JionCircuit()
    {
        List <NDlabObject> lineList = NDlabObject.SearchLabObject(SearchCicuitType.ELELINE, false);

        foreach (NDlabObject obj in lineList)
        {
            if (obj != null && obj is EleLine)
            {
                EleLine eleLine = obj as EleLine;
                if (eleLine.ConnectLink == true)
                {
                    NDlabObject    start        = eleLine.StartLineLeap.Link.m_Parent;
                    NDlabObject    end          = eleLine.EndLineLeap.Link.m_Parent;
                    CircuitElement myCircuit    = LabObjectDataFactory.GetCircuit(start.LabObjID);
                    CircuitElement OtherCircuit = LabObjectDataFactory.GetCircuit(end.LabObjID);

                    Circuit.Lead startLead = eleLine.StartLineLeap.Link.m_Type == ElementLeapType.leadIn?myCircuit.leadIn:myCircuit.leadOut;
                    Circuit.Lead endLead   = eleLine.EndLineLeap.Link.m_Type == ElementLeapType.leadIn ? OtherCircuit.leadIn : OtherCircuit.leadOut;
                    g_sim.Connect(startLead, endLead);
                }
            }
        }
    }
Exemple #18
0
    /// <summary>
    /// Get circuti data
    /// </summary>
    public bool GetCircuitData()
    {
        m_Circuitobj.Clear();

        List <NDlabObject> l = NDlabObject.SearchLabObject(SearchCicuitType.NormalCircuit);

        foreach (NDlabObject Obj in l)
        {
            if (Obj == null)
            {
                continue;
            }
            CircuitObject o = (Obj as NDCircuitObject).GetCircuitData() as CircuitObject;
            if (o == null)
            {
                continue;
            }
            m_Circuitobj.Add(o);
        }
        List <NDlabObject> l2 = NDlabObject.SearchLabObject(SearchCicuitType.ELELINE);

        foreach (NDlabObject Obj in l2)
        {
            if (Obj == null)
            {
                continue;
            }
            CircuitObject o = (Obj as NDCircuitObject).GetCircuitData() as CircuitObject;
            if (o == null)
            {
                continue;
            }
            m_Circuitobj.Add(o);
        }
        return(true);
    }
Exemple #19
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Right)
        {
            return;
        }
        NDlabObject obj = GetComponent <NDlabObject>();

        if (obj != null)
        {
            if (obj is EleLine)
            {
                LineAction action = obj.gameObject.GetComponent <LineAction>();
                if (action)
                {
                    action.SetControling();
                }
            }
            if (eventData.clickCount == 2)//show the Menu UI
            {
                if (obj != null && obj.PlayerState == false)
                {
                    ClickMenuWnd wnd = WndManager.GetWnd <ClickMenuWnd>();
                    if (wnd != null)
                    {
                        wnd.SetCurCircuitObject(obj as NDCircuitObject);
                        wnd.BtnDel.transform.position = new Vector3(eventData.position.x, eventData.position.y, 0);
                    }
                }
            }
            else if (eventData.clickCount == 1 && eventData.dragging == false && eventData.delta.x < 0.1f && eventData.delta.y < 0.1f)
            {
                LabEnv.AddHighlightLabObj(obj, ControlButtonDown);
            }
        }
    }
Exemple #20
0
    /// <summary>
    /// 构建电路
    /// </summary>
    public static bool CreateCircuit()
    {
        ClearCircuit();
        //
        if (CheckCircuitLoop() == false)
        {
            Debug.Log("电路不连通");
            g_IsCreateCircuit = false;
            return(false);
        }
        else
        {
            Debug.Log("电路连通");
        }
        //
        List <NDlabObject> l = NDlabObject.SearchLabObject(SearchCicuitType.NormalCircuit, false);

        //先加入元气件
        foreach (NDlabObject Lab in l)
        {
            if (Lab == null)
            {
                continue;
            }
            else
            {
                CircuitElement e = LabObjectDataFactory.GetCircuit(Lab.LabObjID);
                if (e != null)
                {
                    g_sim.AddElement(e);
                }
            }
        }
        //元气件进行连接
        foreach (NDlabObject Lab in l)
        {
            if (Lab == null)
            {
                continue;
            }
            else
            {
                (Lab as NDCircuitObject).JionCircuit(ref g_sim);
            }
        }
        //JionCircuit();
        try

        {
            //g_sim.needAnalyze();
            if (g_sim.doTick() == false)
            {
                //g_IsCreateCircuit = false;
                Debug.Log("CreateCircuit is false");
                return(false);
            }
            else
            {
                Debug.Log("CreateCircuit is true");
                g_IsCreateCircuit = true;
            }
        }
        catch (SharpCircuit.Circuit.CircuitException e)
        {
            Debug.Log(e.ToString());
            return(false);
        }
        return(true);
    }