コード例 #1
0
    public void removeWindow(IMouseEventCollect window)
    {
        UIDepth depth = window.getUIDepth();

        mWindowOrderList[depth].Remove(window);
        if (mWindowOrderList[depth].Count == 0)
        {
            mWindowOrderList.Remove(depth);
        }
    }
コード例 #2
0
    public void windowDepthChanged(UIDepth lastDepth, IMouseEventCollect window)
    {
        // 移除旧的按钮深度
        mWindowOrderList[lastDepth].Remove(window);
        // 添加新的按钮深度
        UIDepth newDepth = window.getUIDepth();

        if (!mWindowOrderList.ContainsKey(newDepth))
        {
            mWindowOrderList.Add(newDepth, new List <IMouseEventCollect>());
        }
        mWindowOrderList[newDepth].Add(window);
    }
コード例 #3
0
    public void notifyWindowDepthChanged(IMouseEventCollect button)
    {
        // 只判断UI的深度变化
        if (!(button is txUIObject))
        {
            return;
        }
        // 如果之前没有记录过,则不做判断
        if (!mAllButtonSet.Contains(button))
        {
            return;
        }
        UIDepth lastDepth = mButtonDepthList[button];

        foreach (var item in mMouseCastWindowList)
        {
            if (item.hasWindow(lastDepth, button))
            {
                item.windowDepthChanged(lastDepth, button);
                break;
            }
        }
        mButtonDepthList[button] = button.getUIDepth();
    }
コード例 #4
0
 // 注销碰撞器
 public void unregisteBoxCollider(IMouseEventCollect obj)
 {
     if (!mAllButtonSet.Contains(obj))
     {
         return;
     }
     if (mHoverWindow == obj)
     {
         mHoverWindow = null;
     }
     if (obj is txUIObject)
     {
         // 从深度列表中移除
         UIDepth depth = mButtonDepthList[obj];
         mButtonDepthList.Remove(obj);
         UIDepth curDepth = obj.getUIDepth();
         if (depth.mPanelDepth != curDepth.mPanelDepth || !isFloatEqual(depth.mWindowDepth, curDepth.mWindowDepth))
         {
             logError("depth error");
         }
         foreach (var item in mMouseCastWindowList)
         {
             if (item.hasWindow(depth, obj))
             {
                 item.removeWindow(obj);
                 if (item.isEmpty())
                 {
                     mMouseCastWindowList.Remove(item);
                 }
                 break;
             }
         }
         if (WidgetUtility.isNGUI((obj as txUIObject).getObject()))
         {
             --mNGUICount;
         }
         else
         {
             --mUGUICount;
         }
     }
     else if (obj is MovableObject)
     {
         foreach (var item in mMouseCastObjectList)
         {
             if (item.hasObject(obj))
             {
                 item.removeObject(obj);
                 if (item.isEmpty())
                 {
                     mMouseCastObjectList.Remove(item);
                 }
                 break;
             }
         }
         mMovableObjectList.Remove(obj);
     }
     mAllButtonList.Remove(obj);
     mAllButtonSet.Remove(obj);
     mMouseDownWindowList.Remove(obj);
     mMultiTouchWindowList.Remove(obj);
 }
コード例 #5
0
 // 注册碰撞器,只有注册了的碰撞器才会进行检测
 public void registeBoxCollider(IMouseEventCollect button,
                                ObjectClickCallback clickCallback = null,
                                ObjectPressCallback pressCallback = null,
                                ObjectHoverCallback hoverCallback = null,
                                GameCamera camera = null)
 {
     if (!mUseGlobalTouch)
     {
         logError("Not Active Global Touch!");
         return;
     }
     if (button.getCollider() == null)
     {
         logError("window must has collider that can registeBoxCollider! " + button.getName());
         return;
     }
     button.setClickCallback(clickCallback);
     button.setPressCallback(pressCallback);
     button.setHoverCallback(hoverCallback);
     if (!mAllButtonSet.Contains(button))
     {
         if (button is txUIObject)
         {
             // 寻找窗口对应的摄像机
             if (WidgetUtility.isNGUI((button as txUIObject).getObject()))
             {
                 ++mNGUICount;
                 if (camera == null)
                 {
                     camera = mCameraManager.getUICamera(true);
                 }
             }
             else
             {
                 ++mUGUICount;
                 if (camera == null)
                 {
                     camera = mCameraManager.getUICamera(false);
                 }
             }
             if (camera == null)
             {
                 logError("can not find ui camera for raycast!");
             }
             // 将窗口加入到鼠标射线检测列表中
             UIDepth            depth        = button.getUIDepth();
             MouseCastWindowSet mouseCastSet = null;
             foreach (var item in mMouseCastWindowList)
             {
                 if (item.mCamera == camera)
                 {
                     mouseCastSet = item;
                     break;
                 }
             }
             if (mouseCastSet == null)
             {
                 mouseCastSet = new MouseCastWindowSet(camera);
                 mMouseCastWindowList.Add(mouseCastSet);
             }
             mouseCastSet.addWindow(depth, button);
             mButtonDepthList.Add(button, depth);
         }
         else if (button is MovableObject)
         {
             MouseCastObjectSet mouseCastSet = null;
             foreach (var item in mMouseCastObjectList)
             {
                 if (item.mCamera == camera)
                 {
                     mouseCastSet = item;
                     break;
                 }
             }
             if (mouseCastSet == null)
             {
                 mouseCastSet = new MouseCastObjectSet(camera);
                 mMouseCastObjectList.Add(mouseCastSet);
             }
             mouseCastSet.addObject(button);
             mMovableObjectList.Add(button);
         }
         mAllButtonList.Add(button);
         mAllButtonSet.Add(button);
     }
 }