Пример #1
0
    public void OnDrag(PointerEventData eventData)
    {
        Vector3       globalMousePos;
        RectTransform m_DraggingPlane = LabEnv.NodeLab.transform as RectTransform;

        if (m_labCamera != null && m_labCamera.ScreenPointToWorldPointInRectangle(m_DraggingPlane, eventData.position, out globalMousePos))
        {
            if (PickupPos != globalMousePos)
            {
                Vector3 offset = globalMousePos - PickupPos;
                PickupPos = globalMousePos;

                bool result = CheckPositionInCamera(offset + transform.position);
                if (result)
                {
                    List <NDlabObject> l    = LabEnv.GetHighLightCircuitObject();
                    List <NDlabObject> list = new List <NDlabObject>();
                    list.AddRange(l);
                    if (list.Count < 1)
                    {
                        list.Add(m_labObject);
                    }
                    LabObjectOperateCenter.NoticeObjToMove(list, offset);
                }
            }
        }
    }
Пример #2
0
    private void SetDraggedPosition(PointerEventData data)
    {
        Vector3 globalMousePos;

        CameraType type = m_labObject != null && m_labObject is EleLine ? CameraType.WireCamera : CameraType.LabCamera;

        LabCamera carme = LabEnv.GetCameraByType(type);

        if (carme != null && carme.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, out globalMousePos))
        {
            Vector3 org = m_DraggingItem.transform.position;
            globalMousePos = U3DUtil.SetZ(globalMousePos, m_DraggingItem.transform.position.z);

            m_DraggingItem.transform.position = globalMousePos;
            if (m_labObject != null && m_labObject is EleLine)
            {
                bool startOut = carme.CheckPositionInCamera((m_labObject as EleLine).m_LineAction.m_StartCtrl.transform.position);
                bool EndOut   = carme.CheckPositionInCamera((m_labObject as EleLine).m_LineAction.m_EndCtrl.transform.position);
                if (!startOut || !EndOut)
                {
                    m_DraggingItem.transform.position = org;
                }
            }
            else if (!carme.CheckPositionInCamera(globalMousePos))
            {
                m_DraggingItem.transform.position = org;
            }
        }
    }
Пример #3
0
    /// <summary>
    /// create lab object by click | drag way.
    /// </summary>
    /// <param name="createWay">0:Click 1:Drag</param>
    private GameObject CreateLabObj(int createWay)
    {
        if (m_PerfabName == "")
        {
            return(null);
        }

        GameObject obj = NDLoad.LoadPrefab(m_PerfabName, LabEnv.NodeLab.transform);

        if (obj == null)
        {
            return(null);
        }

        if (createWay == 0)
        {
            SetPosOffset(obj);
            SetPreCreateObjData();
        }
        else
        {
            LabEnv.ResetPreCreateLabObj();
        }

        NDCircuitObject o = obj.GetComponent <NDCircuitObject>();

        if (o != null)
        {
            o.SetDefaultData();
            o.SetGameobjectName();
        }
        m_labObject = o;
        return(obj);
    }
Пример #4
0
    void BtnDelClick()
    {
        if (m_curCirObj != null)
        {
            LabEnv.ClearAllHighlightLabObj();

            m_curCirObj.DestroyLabObject();
        }
        WndManager.DestoryWnd <ClickMenuWnd>();
        NDCircuitObject.CreateCirCuit();
    }
Пример #5
0
    public static void DeleteSelecetEle()
    {
        List <NDlabObject> l = LabEnv.GetHighLightCircuitObject();

        foreach (NDlabObject obj in l)
        {
            if (obj.PlayerState == false)
            {
                obj.DestroyLabObject();
            }
        }
        LabEnv.ClearAllHighlightLabObj();
    }
Пример #6
0
 private void SetPreCreateObjData()
 {
     if (m_PerfabName != "")
     {
         if (LabEnv.PreCreateLabObjName != "")
         {
             if (LabEnv.PreCreateLabObjName != m_PerfabName)
             {
                 LabEnv.ResetPreCreateLabObj();
             }
         }
         LabEnv.PreCreateLabObjName = m_PerfabName;
     }
 }
Пример #7
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);
            }
        }
    }
Пример #8
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);
            }
        }
    }
Пример #9
0
 void OnDestroy()
 {
     LabEnv.Reset();
 }
Пример #10
0
 void OnEnable()
 {
     LabEnv.SetLabNode(this);
 }
Пример #11
0
 void Awake()
 {
     m_camera = LabEnv.GetCameraByType(CameraType.WireCamera);
 }
Пример #12
0
 // Use this for initialization
 void Start()
 {
     LabEnv.RegisterCamera(this);
 }
Пример #13
0
 void OnDestroy()
 {
     LabEnv.UnRegisterCamera(this);
 }
Пример #14
0
 void Start()
 {
     InitCtrlLine();
     wireCamera = LabEnv.GetCameraByType(CameraType.WireCamera);
 }