예제 #1
0
    public static List <txUIButton> raycast(Ray ray, SortedDictionary <int, List <txUIButton> > buttonList, int maxCount = 0)
    {
        bool cast = true;
        List <txUIButton> retList = new List <txUIButton>();
        RaycastHit        hit     = new RaycastHit();

        foreach (var box in buttonList)
        {
            int count = box.Value.Count;
            for (int i = 0; i < count; ++i)
            {
                txUIButton button = box.Value[i];
                if (button.getHandleInput() && button.Raycast(ray, out hit, 10000.0f))
                {
                    retList.Add(button);
                    // 如果射线不能穿透当前按钮,或者已经达到最大数量,则不再继续
                    if (!button.getPassRay() || maxCount > 0 && retList.Count >= maxCount)
                    {
                        cast = false;
                        break;
                    }
                }
            }
            if (!cast)
            {
                break;
            }
        }
        return(retList);
    }
예제 #2
0
    public override void assignWindow()
    {
        mHuResultRoot    = newObject <txUIObject>("HuResultRoot");
        mHu              = newObject <txUIStaticSprite>(mHuResultRoot, "Hu", 1);
        mPingJu          = newObject <txUIStaticSprite>(mHuResultRoot, "PingJu", 1);
        mMoneyResultRoot = newObject <txUIObject>("MoneyResultRoot");
        int charCount = mEndingCharacterList.Count;

        for (int i = 0; i < charCount; ++i)
        {
            mEndingCharacterList[i].assignWindow(mMoneyResultRoot, "Character" + i);
        }
        mDetailRoot    = newObject <txUIObject>("DetailRoot");
        mMultipleTitle = newObject <txUIText>(mDetailRoot, "MultipleTitle");
        int multipleCount = mMultipleList.Count;

        for (int i = 0; i < multipleCount; ++i)
        {
            mMultipleList[i].assignWindow(mDetailRoot, "Multiple" + i);
        }
        mButtonRoot     = newObject <txUIObject>("ButtonRoot");
        mContinueButton = newObject <txUIButton>(mButtonRoot, "Continue");
        mMatchButton    = newObject <txUIButton>(mButtonRoot, "Match");
        mReturnButton   = newObject <txUIButton>(mButtonRoot, "Return");
    }
예제 #3
0
 public override void assignWindow()
 {
     mAdd           = newObject <txUIButton>("AddButton");
     mLeftReady     = newObject <txUIButton>("LeftReadyButton");
     mOppositeReady = newObject <txUIButton>("OppositeReadyButton");
     mRightReady    = newObject <txUIButton>("RightReadyButton");
     mMyselfReady   = newObject <txUIButton>("MyselfReadyButton");
 }
예제 #4
0
 // 注销碰撞器
 public void unregisterBoxCollider(txUIButton button)
 {
     if (mButtonCallbackList.ContainsKey(button))
     {
         mButtonCallbackList.Remove(button);
         mButtonOrderList[button.getDepth()].Remove(button);
     }
 }
예제 #5
0
 public override void assignWindow()
 {
     mBackground       = newObject <txUIStaticSprite>("Background");
     mCreateRoomButton = newObject <txUIButton>(mBackground, "CreateRoomButton");
     mCreateLabel      = newObject <txUIStaticSprite>(mCreateRoomButton, "CreateLabel");
     mJoinRoomButton   = newObject <txUIButton>(mBackground, "JoinRoomButton");
     mJoinLabel        = newObject <txUIStaticSprite>(mJoinRoomButton, "JoinLabel");
 }
예제 #6
0
 public override void assignWindow()
 {
     mRoomInfoRoot      = newObject <txUIObject>("RoomInfoRoot");
     mRoomIDLabel       = newObject <txUIText>(mRoomInfoRoot, "RoomID");
     mLeaveRoomButton   = newObject <txUIButton>("LeaveRoom");
     mReadyButton       = newObject <txUIButton>("Ready");
     mCancelReadyButton = newObject <txUIButton>("CancelReady");
     mInfo = newObject <txUIText>("Info");
 }
예제 #7
0
 public override void assignWindow()
 {
     mBackground     = newObject <txUIStaticSprite>("Background");
     mAccountEdit    = newObject <txUIEditbox>(mBackground, "AccountEdit");
     mPasswordEdit   = newObject <txUIEditbox>(mBackground, "PasswordEdit");
     mNameEdit       = newObject <txUIEditbox>(mBackground, "NameEdit");
     mRegisterButton = newObject <txUIButton>(mBackground, "RegisterButton");
     mCancelButton   = newObject <txUIButton>(mBackground, "CancelButton");
 }
예제 #8
0
 public void notifyButtonDepthChanged(txUIButton button, int lastDepth)
 {
     // 移除旧的按钮
     mButtonOrderList[lastDepth].Remove(button);
     // 添加新的按钮
     if (!mButtonOrderList.ContainsKey(button.getDepth()))
     {
         mButtonOrderList.Add(button.getDepth(), new List <txUIButton>());
     }
     mButtonOrderList[button.getDepth()].Add(button);
 }
예제 #9
0
    public void update(float elapsedTime)
    {
        if (!mUseHover)
        {
            return;
        }
        // 鼠标移动检测
        Vector3 curMousePosition = getCurMousePosition();

        if (mLastMousePosition != curMousePosition)
        {
            // 计算鼠标当前所在最前端的窗口
            txUIButton newWindow = getHoverButton(curMousePosition);
            // 判断鼠标是否还在当前窗口内
            if (mHoverButton != null)
            {
                // 鼠标已经移动到了其他窗口中,发送鼠标离开的事件
                if (newWindow != mHoverButton)
                {
                    // 不过也许此时悬停窗口已经不接收输入事件了或者碰撞盒子被禁用了,需要判断一下
                    if (mHoverButton.getHandleInput() && mHoverButton.getBoxCollider().enabled)
                    {
                        if (mButtonCallbackList[mHoverButton].mHoverCallback != null)
                        {
                            mButtonCallbackList[mHoverButton].mHoverCallback(mHoverButton, false);
                        }
                    }
                    // 找到鼠标所在的新的窗口,给该窗口发送鼠标进入的事件
                    if (newWindow != null)
                    {
                        if (mButtonCallbackList[newWindow].mHoverCallback != null)
                        {
                            mButtonCallbackList[newWindow].mHoverCallback(newWindow, true);
                        }
                    }
                }
            }
            // 如果上一帧鼠标没有在任何窗口内,则计算这一帧鼠标所在的窗口
            else
            {
                // 发送鼠标进入的事件
                if (newWindow != null)
                {
                    if (mButtonCallbackList[newWindow].mHoverCallback != null)
                    {
                        mButtonCallbackList[newWindow].mHoverCallback(newWindow, true);
                    }
                }
            }
            mHoverButton       = newWindow;
            mLastMousePosition = curMousePosition;
        }
    }
예제 #10
0
 public override void assignWindow()
 {
     mBackground        = newObject <txUIStaticSprite>("Background");
     mBottomButtonRoot  = newObject <txUIObject>(mBackground, "BottomButtonRoot");
     mLeftTopButtonRoot = newObject <txUIObject>(mBackground, "LeftTopButtonRoot");
     mFrameTitle        = newObject <txUIStaticSprite>(mBackground, "FrameTitle");
     mMailButton        = newObject <txUIButton>(mBottomButtonRoot, "MailButton");
     mCompetitionButton = newObject <txUIButton>(mBottomButtonRoot, "CompetitionButton");
     mShareButton       = newObject <txUIButton>(mBottomButtonRoot, "ShareButton");
     mStandingButton    = newObject <txUIButton>(mBottomButtonRoot, "StandingButton");
     mRuleButton        = newObject <txUIButton>(mBottomButtonRoot, "RuleButton");
     mContactButton     = newObject <txUIButton>(mBottomButtonRoot, "ContactButton");
     mRechargeButton    = newObject <txUIButton>(mLeftTopButtonRoot, "RechargeButton");
     mSettingButton     = newObject <txUIButton>(mLeftTopButtonRoot, "SettingButton");
     mQuitButton        = newObject <txUIButton>(mLeftTopButtonRoot, "QuitButton");
 }
예제 #11
0
    public txUIButton getHoverButton(Vector3 pos)
    {
        // 返回Layout深度最大的,也就是最靠前的窗口
        List <txUIButton> boxList       = globalRaycast(pos);
        txUIButton        forwardButton = null;

        foreach (var button in boxList)
        {
            GameLayout layout = button.mLayout;
            if (forwardButton == null || layout.getRenderOrder() > forwardButton.mLayout.getRenderOrder())
            {
                forwardButton = button;
            }
        }
        return(forwardButton);
    }
예제 #12
0
    public txUIButton getHoverButton(Vector3 pos)
    {
        // 返回Layout深度最大的,也就是最靠前的窗口
        List <BoxCollider> boxList       = globalRaycast(pos);
        txUIButton         forwardButton = null;

        foreach (var box in boxList)
        {
            txUIButton button = mBoxColliderCallbackList[box].mButton;
            GameLayout layout = button.mLayout;
            if (forwardButton == null || (button.getHandleInput() && layout.getRenderOrder() > forwardButton.mLayout.getRenderOrder()))
            {
                forwardButton = button;
            }
        }
        return(forwardButton);
    }
예제 #13
0
 // 注册碰撞器,只有注册了的碰撞器才会进行检测
 public void registerBoxCollider(txUIButton button, BoxColliderClickCallback clickCallback,
                                 BoxColliderHoverCallback hoverCallback = null, BoxColliderPressCallback pressCallback = null)
 {
     if (!mButtonCallbackList.ContainsKey(button))
     {
         ColliderCallBack colliderCallback = new ColliderCallBack();
         colliderCallback.mButton        = button;
         colliderCallback.mClickCallback = clickCallback;
         colliderCallback.mHoverCallback = hoverCallback;
         colliderCallback.mPressCallback = pressCallback;
         mButtonCallbackList.Add(button, colliderCallback);
         if (!mButtonOrderList.ContainsKey(button.getDepth()))
         {
             mButtonOrderList.Add(button.getDepth(), new List <txUIButton>());
         }
         mButtonOrderList[button.getDepth()].Add(button);
     }
 }
예제 #14
0
 public override void assignWindow()
 {
     mRoomIDEditbox = newObject <txUIEditbox>("RoomIDEditbox");
     mJoinButton    = newObject <txUIButton>("JoinButton");
     mCancelButton  = newObject <txUIButton>("CancelButton");
 }
예제 #15
0
 public override void assignWindow()
 {
     mGlobalTouch = newObject <txUIButton>("GlobalTouch", -1);
 }