示例#1
0
        public void PrintTree()
        {
            if (Value == '\0')
            {
                return;
            }
            else
            {
                Console.Write(this.Value);
            }

            if (LeftUp != null)
            {
                LeftUp.PrintTree();
            }
            if (RightUp != null)
            {
                RightUp.PrintTree();
            }
            if (LeftDown != null)
            {
                LeftDown.PrintTree();
            }
            if (RightDown != null)
            {
                RightDown.PrintTree();
            }
        }
示例#2
0
    void Start()
    {
        var down1 = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerDown
        };
        var down2 = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerDown
        };
        var up1 = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerUp
        };
        var up2 = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerUp
        };

        down1.callback.AddListener(x => LeftDown.Invoke());
        up1.callback.AddListener(x => LeftUp.Invoke());
        down2.callback.AddListener(x => RightDown.Invoke());
        up2.callback.AddListener(x => RightUp.Invoke());

        left.triggers.AddRange(new[] { down1, up1 });
        right.triggers.AddRange(new[] { down2, up2 });

        var drag = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.Drag
        };
        var up3 = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerUp
        };

        drag.callback.AddListener(x => OnAcceleratorDrag.Invoke(x as PointerEventData));
        up3.callback.AddListener(x => OnAcceleratorUp.Invoke(x as PointerEventData));

        accelerator.triggers.AddRange(new[] { drag, up3 });

        toMenuButton.onClick.AddListener(ToMenu.Invoke);
    }
示例#3
0
        public override int HookProcEvent(int nCode, Int32 wParam, IntPtr lParam)
        {
            //如果正常运行并且用户要监听鼠标的消息
            if (nCode >= 0)
            {
                MouseButtons    button            = MouseButtons.None;
                int             clickCount        = 0;
                int             delta             = 0;
                MouseHookStruct MyMouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct));
                MouseEventArgs  e;
                switch ((int)wParam)
                {
                case Const.WM_LBUTTONDOWN:
                    LastMouseDownTimeSpan = Environment.TickCount;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    LeftDown?.Invoke(this, e);
                    break;

                case Const.WM_LBUTTONUP:
                    LastMouseDownTimeSpan = Environment.TickCount;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    LeftUp?.Invoke(this, e);
                    break;

                case Const.WM_MBUTTONDOWN:
                    button     = MouseButtons.Middle;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    MiddleDown?.Invoke(this, e);
                    break;

                case Const.WM_MBUTTONUP:
                    button     = MouseButtons.Middle;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    MiddleUp?.Invoke(this, e);
                    break;

                case Const.WM_RBUTTONDOWN:
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    RightDown?.Invoke(this, e);
                    break;

                case Const.WM_RBUTTONUP:
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    RightUp?.Invoke(this, e);
                    break;

                case Const.WM_MOUSEWHEEL:
                    if (!mouseLeftDown)
                    {
                        button     = MouseButtons.Middle;
                        clickCount = 0;
                        delta      = MyMouseHookStruct.hWnd >> 16;
                        e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                        MouseWheel?.Invoke(this, e);
                    }
                    break;

                case Const.WM_MOUSEMOVE:
                    button     = MouseButtons.None;
                    clickCount = 0;
                    e          = new MouseEventArgs(button, clickCount, MyMouseHookStruct.pt.X, MyMouseHookStruct.pt.Y, delta);
                    MouseMove?.Invoke(this, e);
                    break;
                }
            }

            return(CallNextHookEx(hwndHook, nCode, wParam, lParam));
        }
示例#4
0
    /*  private void Update()
     * {
     *    Debug.Log("Stop active:" + stopSignActive);
     * }*/

    private void OnTriggerEnter(Collider other)
    {
        //Debug.Log(transform.name + " var: " + var.ToString());
        if (transform.name == "ColliderFirst")
        {
            var.x.flag1 = true;
            var.x.isWrongWay();
        }
        if (transform.name == "ColliderSecond")
        {
            var.x.flag2 = true;
            var.x.isWrongWay();
        }

        if (transform.name == "ColliderStop")
        {
            StopSign.stopSignActive = true;
            Debug.Log("Usao u stop");
            Instance.stop.CheckStop(transform);
            //Timer(3);
        }

        if (transform.name == "ColliderUp")
        {
            UP.isActive = true;
            Debug.Log("Usao u UP");
        }

        if (transform.name == "ColliderLeft&Up")
        {
            LeftUp.isActive = true;
            Debug.Log("Usao u Left&UP");
        }

        if (transform.name == "ColliderLeft")
        {
            LeftSign.isActive = true;
            Debug.Log("Left");
        }

        if (transform.name == "ColliderRight")
        {
            RightSign.isActive = true;
            Debug.Log("Right");
        }

        if (transform.name == "ColliderRight&Up")
        {
            RightUp.isActive = true;
            Debug.Log("RightUP");
        }

        if (transform.name == "ColliderBoth")
        {
            LeftRight.isActive = true;
            Debug.Log("Left & Right");
        }

        if (transform.name == "ColliderWrongWay")
        {
            Debug.Log("Krivi smjer!");
        }

        if (transform.GetComponentInParent <IntersectionWrongWay>() != null)
        {
            // intersection = transform.GetComponentInParent<IntersectionWrongWay>();
            if (UP.isActive)
            {
                UP.check(transform);
            }
            else if (LeftUp.isActive)
            {
                LeftUp.isWrongWay(transform);
            }
            else if (LeftSign.isActive)
            {
                LeftSign.isWrongWay(transform);
            }
            else if (RightSign.isActive)
            {
                RightSign.checkIsRight(transform);
            }
            else if (RightUp.isActive)
            {
                RightUp.checkIsRight(transform);
            }
            else if (LeftRight.isActive)
            {
                LeftRight.isWrongWay(transform);
            }
            else
            {
                //Debug.Log("nop");
                IntersectionRules.isWrongWay(transform);
            }
        }
    }