// Update is called once per frame
    void Update()
    {
        if (activated && Input.GetMouseButton(0))
        {
            if (startpos == null)
            {
                startpos = tomove.position;
            }
            var mousePosition = MouseBehavior.MousePos();
            if (mousePosition.x < transform.position.x - 1.0f || mousePosition.x > transform.position.x + 1.0f)
            {
                return;
            }
            var y = mousePosition.y;
            if (y < yMin)
            {
                y = yMin;
            }
            else if (y > yMax)
            {
                y = yMax;
            }
            transform.position = new Vector3(transform.position.x, y, transform.position.z);
            Vector3 newposition;
            float   ratio = (y - yMin) / (yMax - yMin);
            float   ynew  = startpos.y + ((yMaxTM - yMinTM) * ratio);

            newposition     = new Vector3(tomove.position.x, ynew, tomove.position.z);
            tomove.position = newposition;
        }
    }
Exemple #2
0
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public MouseBehavior GetMouseBehavior()
    {
        MouseBehavior mitem = gameObject.GetComponentSecure <MouseBehavior>();

        mitem.outline = outline;
        mitem.hand    = hand;
        return(mitem);
    }
 public override bool?TryInteract(GameObject gameObject)
 {
     if (Input.GetMouseButton(0) && MouseBehavior.MouseOver(Input.mousePosition, gameObject))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public override bool?TryInteract(GameObject gameObject)
 {
     if ((MouseBehavior.MouseOver(Input.mousePosition, gameObject) || isDown) && Input.GetMouseButton(0))
     {
         return(HandleDown());
     }
     else
     {
         return(HandleUp());
     }
 }
Exemple #5
0
    public override bool?TryInteract(GameObject gameObject)
    {
        if (tijd == null || DateTime.UtcNow >= tijd)
        {
            //debug masks
            if (Input.GetKeyDown(KeyCode.U))
            {
                MouseBehavior.InstantiateDrawRect(gameObject);
            }

            var mouseDownNow = Input.GetMouseButton(0);
            if (mouseDownLast && !mouseDownNow)
            {
                mouseDownLast = mouseDownNow;
                if (clicked)
                {
                    clicked = false;
                    if (MouseBehavior.MouseOver(Input.mousePosition, gameObject))
                    {
                        Debug.LogWarning("Clicked: " + gameObject.name);
                        tijd = DateTime.UtcNow.AddMilliseconds(200);
                        return(true);
                    }
                }
                return(false);
            }
            else if (!mouseDownLast && mouseDownNow)
            {
                mouseDownLast = mouseDownNow;
                if (MouseBehavior.MouseOver(Input.mousePosition, gameObject))
                {
                    Debug.LogWarning("Released: " + gameObject.name);
                    clicked = true;
                }
                return(false);
            }
            mouseDownLast = mouseDownNow;
            if (!mouseDownLast)
            {
                clicked = false;
            }
            return(false);
        }
        else
        {
            return(false);
        }
    }
 public TestbedController(TestbedModel argModel, UpdateBehavior behavior,
     MouseBehavior mouseBehavior, TestbedErrorHandler errorHandler)
 {
     model = argModel;
     inputQueue = new LinkedList<QueueItem>();
     setFrameRate(DEFAULT_FPS);
     //animator = new Thread(s => run());
     updateBehavior = behavior;
     this.errorHandler = errorHandler;
     this.mouseBehavior = mouseBehavior;
     addListeners();
 }