예제 #1
0
        static void Main(string[] args)
        {
            Buttons     button1     = new Buttons("button1", 10, 20, 30, "clickable");
            EditBoxes   editBox1    = new EditBoxes("editBox1", 15, 25, 35, "clickable");
            Links       link1       = new Links("link1", 30, 50, 5, "clickable");
            Menus       menu1       = new Menus("menu1", 0, 5, 5, "clickable");
            Pics        pic1        = new Pics("pic1", 50, 70, 30, "ColorChangeable");
            Selectors   selector1   = new Selectors("selector1", 55, 20, 15, "selectable");
            Text        text1       = new Text("text1", 20, 15, 45, "SomeOption");
            Selectors   selector2   = new Selectors("selector2", 05, 25, 30, "selectable");
            Selectors   selector3   = new Selectors("selector3", 50, 10, 10, "selectable");
            Menus       menu2       = new Menus("menu2", 90, 55, 5, "clickable");
            Text        text2       = new Text("text2", 20, 15, 45, "SomeOption");
            Pics        pic2        = new Pics("pic2", 50, 70, 30, "ColorChangeable");
            Links       link2       = new Links("link2", 30, 50, 5, "clickable");
            RadioButton radioButton = new RadioButton("radioButton", 35, 40, 80, "selectable");

            WebElements[] webElements = { button1,
                                          editBox1,
                                          link1,
                                          menu1,
                                          pic1,
                                          selector1,
                                          text1,
                                          selector2,
                                          selector3,
                                          menu2,
                                          text2,
                                          pic2,
                                          link2,
                                          radioButton };

            foreach (WebElements element in webElements)
            {
                Console.WriteLine(element.GetInfo());
            }

            Console.WriteLine(" ");

            foreach (WebElements element in webElements)
            {
                if (element is IClickable)
                {
                    IClickable elementClickable = (IClickable)element;
                    elementClickable.Click();
                    Console.WriteLine(elementClickable.Click());
                }
            }
            foreach (WebElements element in webElements)
            {
                if (element is ISelectable)
                {
                    ISelectable elementSelectable = (ISelectable)element;
                    elementSelectable.Select();
                    Console.WriteLine(elementSelectable.Select());
                }
            }
            Console.ReadKey();
        }
 void RaiseClick()
 {
     if (clicked != null)
     {
         clicked.Click(left);
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // Cast a ray straight down.
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.forward);

            // If it hits something...
            if (hit.collider != null)
            {
                Debug.Log(hit.collider.gameObject.name);
                IClickable clickable = hit.collider.gameObject.GetComponent <IClickable>();
                if (clickable != null)
                {
                    clickable.Click();
                }
            }
            else
            {
                if (OnClickMiss != null)
                {
                    OnClickMiss();
                }
            }
        }
    }
예제 #4
0
        public override void Update(GameTime gameTime)
        {
            bool       atBlankSpace = true;
            MouseState mouse        = Mouse.GetState();

            for (int i = 0; i < clickables.Count; i++)
            {
                IClickable clickable = clickables[i];
                if (Toolbox.IsPointInsideSquare(new Point(mouse.X, mouse.Y), clickable.GetBoundary()))
                {
                    atBlankSpace = false;
                    clickable.MouseEnter();
                    if (mouse.LeftButton == ButtonState.Pressed)
                    {
                        clickable.Click();
                    }
                    else
                    {
                        clickable.Release();
                    }
                }
                else
                {
                    clickable.MouseLeave();
                }
            }
            if (atBlankSpace && mouse.LeftButton == ButtonState.Pressed)
            {
                heroDetail?.Deactivate();
            }

            base.Update(gameTime);
        }
예제 #5
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            pointerData.position = Input.mousePosition;

            List <RaycastResult> results = new List <RaycastResult>();

            graphicRayCaster.Raycast(pointerData, results);


            if (results.Count > 0)
            {
                return;
            }



            Vector2      mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit      = Physics2D.Raycast(mousePos, Vector2.zero);

            if (hit)
            {
                IClickable clickable = hit.collider.GetComponent <IClickable>();
                clickable?.Click();
            }
            else
            {
                CloseAllPanels();
            }
        }
    }
예제 #6
0
        private void SetMarkerPosition()
        {
            lastMouseDownPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            lastMouseDownPosition.z = 0;

            _clickResponse.Click(lastMouseDownPosition);
        }
예제 #7
0
        public static void OnClickSelect(Transform clickSelection)
        {
            if (clickSelection == null)
            {
                return;
            }

            IClickable currentClickSelection = clickSelection.GetComponent <IClickable>();

            if (currentClickSelection != null)
            {
                currentClickSelection.Click();
            }
        }
예제 #8
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         RaycastHit2D hit;
         hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
         if (hit.collider != null)
         {
             IClickable clickTarget = hit.collider.GetComponent <IClickable>();
             if (clickTarget != null)
             {
                 clickTarget.Click(hit.point);
             }
         }
     }
 }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        Debug.DrawRay(transform.position, transform.forward);

        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
        {
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                IClickable clickable = hit.collider.GetComponent(typeof(IClickable)) as IClickable;
                if (clickable != null)
                {
                    clickable.Click(this);
                }
            }
        }
    }
예제 #10
0
 /// <summary>
 /// Called when a mouse button was released.
 /// </summary>
 public virtual void OnMouseUp(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Middle)
     {
         camMouseDown = false;
     }
     else if (e.Button == MouseButtons.Left)
     {
         if (clickable != null && MouseMovedTooFar(e) == false)
         {
             clickable.Click();
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         clickable.SecondaryClick();
     }
 }
예제 #11
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector2        mousePosition = _myCamera.ScreenToWorldPoint(Input.mousePosition);
         RaycastHit2D[] hits          = Physics2D.RaycastAll(mousePosition, new Vector2(0, 0), 0.01f);
         SpriteRenderer topRenderer   = null;
         foreach (RaycastHit2D hit in hits)
         {
             if (topRenderer == null)
             {
                 topRenderer = hit.collider.gameObject.GetComponent <SpriteRenderer>();
                 continue;
             }
             SpriteRenderer currentRenderer = hit.collider.gameObject.GetComponent <SpriteRenderer>();
             if (currentRenderer.sortingLayerID > topRenderer.sortingLayerID)
             {
                 topRenderer = currentRenderer;
             }
             else if (currentRenderer.sortingLayerID == topRenderer.sortingLayerID)
             {
                 if (currentRenderer.sortingOrder > topRenderer.sortingOrder)
                 {
                     topRenderer = currentRenderer;
                 }
             }
         }
         if (topRenderer != null)
         {
             IClickable clickedObject = null;
             clickedObject = topRenderer.gameObject.GetComponent <IClickable>();
             if (clickedObject != null)
             {
                 clickedObject.Click();
             }
         }
     }
 }
예제 #12
0
 public void Click(float x, float y)
 {
     Clickable.Click(x, y);
 }
예제 #13
0
        public PageFluentActions <TCurrentPageObject> Click(IClickable clickablePageElement)
        {
            clickablePageElement.Click();

            return(this);
        }
예제 #14
0
 public void Click()
 {
     WaitFor(_elementsBeforeClick, When.Before);
     ClickBehaviour.Click(_waitBeforeClick, _waitAfterClick);
     WaitFor(_elementsAfterClick, When.After);
 }
예제 #15
0
 public void Submit(User user)
 {
     profile.Click();
     base.Submit(user);
 }
예제 #16
0
        void Update()
        {
            if (Input.GetMouseButton(0))
            {
                touching = true;
            }


            Vector2 pos;
            Touch   touch = new Touch();

            if (Input.touchCount > 0)
            {
                touch    = Input.GetTouch(0);
                pos      = touch.position;
                touching = true;
            }
            pos = Input.mousePosition;

            TouchedScreenPosMoved = (touch.phase != TouchPhase.Began || !Input.GetMouseButtonDown(0)) ? (lastTouchedScreenPos - pos) : Vector2.zero;
            lastTouchedScreenPos  = pos;
            Vector3 touchedPos = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, 100000));


            if ((Input.touchCount > 0 && touch.phase == TouchPhase.Began) || Input.GetMouseButtonDown(0))
            {
                if (startTouch != null)
                {
                    startTouch.Invoke(pos);
                }

                Ray          touchRay = new Ray(Vector3.forward, touchedPos);
                RaycastHit2D hit      = Physics2D.Raycast(touchedPos, Vector2.zero, Mathf.Infinity, tappableMask);

                if (hit)
                {
                    Transform  checking  = hit.transform;
                    IClickable clickable = checking.GetComponent <IClickable>();;
                    while (clickable == null && checking.parent != null)
                    {
                        checking  = checking.parent;
                        clickable = checking.GetComponent <IClickable>();
                    }


                    if (clickable != null)
                    {
                        clickable.Click();
                    }
                }

                if (dragging && draggingObject == null)
                {
                    hit = Physics2D.Raycast(touchedPos, Vector2.zero, 10, draggableMask);
                    if (hit)
                    {
                        IDraggable draggable = hit.collider.GetComponent <IDraggable>();
                        if (draggable != null)
                        {
                            draggingObject = draggable;
                            draggingObject.Pick();
                        }
                    }
                }
            }


            if ((Input.touchCount > 0 && touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) || Input.GetMouseButtonUp(0))
            {
                touching = false;
                if (dragging && draggingObject != null)
                {
                    draggingObject.Drop();
                    draggingObject = null;
                }
            }

            if (dragging && draggingObject != null)
            {
                draggingObject.UpdatePos(touchedPos);
            }

            if (Input.touchCount > 0 && (int)Input.GetTouch(0).phase > 2 && (int)Input.GetTouch(1).phase > 2)
            {
                Debug.Log("bep");
                if ((Input.GetTouch(0).position - Input.GetTouch(1).position).magnitude / Screen.width > MinInversePinchDist)
                {
                    Debug.Log("bop");
                    inversePinch.Invoke();
                }
            }
        }