示例#1
0
        //--------------------------------------------------------------------------------------------------

        void OnMouseHorizontalWheel(object sender, MouseHorizontalWheelEventArgs e)
        {
            var pos      = e.GetPosition(this);
            var dpiScale = VisualTreeHelper.GetDpi(this);

            MouseControl?.MouseWheel(new Point(pos.X * dpiScale.DpiScaleX, pos.Y * dpiScale.DpiScaleY), Panels.MouseWheel.Horizontal, e.Delta, e.MouseDevice);
        }
 void Awake()
 {
     //m_dampening = (Screen.dpi / 96) * 10 * 0.5f;
     m_dampening     = 1f;
     m_raycastCamera = GameObject.Find("Main Camera").GetComponent <Camera>();
     mouseControl    = GameObject.Find("MouseControl").GetComponent <MouseControl>();
 }
示例#3
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (sceeneChangeCooldown > 0)
        {
            sceeneChangeCooldown -= Time.fixedDeltaTime;
            return;
        }
        lastPositions[counter] = Input.mousePosition;
        counter = (counter + 1) % lastPositions.Length;

        Vector3 average = Vector3.zero;

        foreach (Vector3 item in lastPositions)
        {
            average += item;
        }
        average /= lastPositions.Length;
        bool allTogether = true;

        foreach (Vector3 item in lastPositions)
        {
            if ((item - average).magnitude > maxDistance)
            {
                allTogether = false;
                break;
            }
        }

        if (allTogether)
        {
            MouseControl.MouseClick();
            randomize();
        }
    }
示例#4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            //Update camera
            Camera.Update();
            //Update Input
            MouseControl.Update();
            KeyboardInput.InputUpdate(gameTime);

            //Update dialog
            Dialog.UpdateModel();

            //Update model

            if (Collection.Models.Count != 0)
            {
                Collection.Models[Program.CurrentModelID].Update(gameTime);
            }


            //Update input handlers

            //Update model rotation

            //Update physics

            base.Update(gameTime);
        }
示例#5
0
    void Start()
    {
        ldatabase = GameObject.FindGameObjectWithTag("Level Database").GetComponent <LevelDatabase>();
        gameMaker = GameObject.FindGameObjectWithTag("Game Creator").GetComponent <GameCreator03>();
        MC        = GameObject.Find("MouseControl").GetComponent <MouseControl>();

        GamesUIPanel   = this.transform.FindChild("Game UI Panel").gameObject;
        RulesPanel     = this.transform.FindChild("Rules Panel").gameObject;
        TimerPanel     = this.transform.FindChild("Timer Panel").gameObject;
        DefeatPanel    = this.transform.FindChild("Defeat Panel").gameObject;
        HighScorePanel = this.transform.FindChild("High Score Notification").gameObject;


        KUM = GamesUIPanel.transform.FindChild("Key Side Panel").GetComponent <KeyUIManager>();

        SetUpGamesPanel(); // FInished

        InstallGadgets();

        Text StartShowButtonText = RulesPanel.transform.FindChild("Start_Show Game Button/Text").GetComponent <Text>();

        StartShowButtonText.text = "Start Game";
        // Set up the Timer	if needed

        //NOTE: Once the GameCreator has finished GameScript should
        // Run
        // Run "FillInRulesDisplay()"
        // Run "OpenDoorTrigger"

        ruleTotal = 0;
    }
示例#6
0
        private void MouseRightClick(HandState handRightState, IJoint rightHand, IJoint spineMid)
        {
            var zRightHandBodyDistance = spineMid.Position.Z - rightHand.Position.Z;

            if (zRightHandBodyDistance > 0.5f) // Right Hand Moving Cursor
            {
                if (handRightState == HandState.Open && startRightHandClickGestureState == null)
                {
                    startRightHandClickGestureState = new MouseGestureState(PHelper.CurrentTimeMillis());
                    startRightHandClickGestureState.oldCursorPosition = Cursor.Position;
                }
                else if (handRightState == HandState.Open && startRightHandClickGestureState != null)
                {
                    var cursorMoveDistance = PointDistance(Cursor.Position, startRightHandClickGestureState.oldCursorPosition);
                    if (cursorMoveDistance < 8)
                    {
                        var timeDiff = PHelper.CurrentTimeMillis() - startRightHandClickGestureState.TimeStamp;
                        if (timeDiff > 2000)
                        {
                            MouseControl.DoMouseRightClick();
                            startRightHandClickGestureState = null;
                        }
                    }
                    else
                    {
                        startRightHandClickGestureState = null;
                    }
                }
            }
        }
示例#7
0
 // Start is called before the first frame update
 void Start()
 {
     MouseControl.MouseMove(new Vector3(0.5f, 0.5f, 0), null);
     //MouseControl.MouseClick();
     lastPositions = new Vector3[(int)(timeStay * 30)];
     randomize();
 }
        //--------------------------------------------------------------------------------------------------

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (ContextMenu != null && ContextMenu.IsOpen)
            {
                return;
            }

            var pos = e.GetPosition(this);

            // Supress context menu if mouse was moved significantly
            if (e.RightButton == MouseButtonState.Pressed && (_MouseDownPosition - pos).LengthSquared > 9)
            {
                _SuppressContextMenu = true;
            }

            var dpiScale = VisualTreeHelper.GetDpi(this);

            MouseControl?.MouseMove(new Point(pos.X * dpiScale.DpiScaleX, pos.Y * dpiScale.DpiScaleY), e.MouseDevice);

            // Update HUD Container
            double left = ((ActualWidth - HudContainer.ActualWidth - pos.X) > 0) ? pos.X : pos.X - HudContainer.ActualWidth;
            double top  = ((pos.Y - HudContainer.ActualHeight) > 0) ? pos.Y - HudContainer.ActualHeight : pos.Y;

            HudContainer.Margin = new Thickness(left, top, 0, 0);
        }
        //--------------------------------------------------------------------------------------------------

        protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            HudContainer.Visibility = Visibility.Hidden;
            MouseControl?.Cancel();
        }
示例#10
0
        private void MoveMouseTo(int x, int y)
        {
            var screenBounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            var outputX      = x * 65535 / screenBounds.Width;
            var outputY      = y * 65535 / screenBounds.Height;

            MouseControl.MoveTo(outputX, outputY);
        }
示例#11
0
    private void Awake()
    {
        Debug.Log("awake");
        tiles = new Dirt[mapWide * mapHeight];
        GenerateTileContent(mapWide, mapHeight);

        finger = GameObject.Find("Finger").GetComponent <MouseControl>();
    }
示例#12
0
        public void DragTo(IElement dropElement)
        {
            MouseControl.SetPosition(this.Position);
            MouseControl.MouseEvent(MouseControl.MouseEvent_LeftButtonDown, this.Position.X, this.Position.Y, 0, 0);

            MouseControl.SetPosition(dropElement.Position);
            MouseControl.MouseEvent(MouseControl.MouseEvent_LeftButtonUp, dropElement.Position.X, dropElement.Position.Y, 0, 0);
        }
示例#13
0
 protected virtual void Dehighlight()
 {
     if (MouseControl == this)
     {
         MouseControl.OnMouseLeave();
         MouseControl = null;
     }
 }
示例#14
0
    protected void Start()
    {
        kc = GetComponent<KeyboardControl>();
        mc = GetComponent<MouseControl>();

        kc.enabled = !startWithMouseControls;
        mc.enabled = startWithMouseControls;
    }
示例#15
0
    protected void Start()
    {
        kc = GetComponent <KeyboardControl>();
        mc = GetComponent <MouseControl>();

        kc.enabled = !startWithMouseControls;
        mc.enabled = startWithMouseControls;
    }
        //--------------------------------------------------------------------------------------------------

        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            var pos      = e.GetPosition(this);
            var dpiScale = VisualTreeHelper.GetDpi(this);

            MouseControl?.MouseWheel(new Point(pos.X * dpiScale.DpiScaleX, pos.Y * dpiScale.DpiScaleY), e.Delta, e.MouseDevice);
        }
    void Awake()
    {
        m_dampening        = (Screen.dpi / 96) * 100;
        m_raycastCamera    = GameObject.Find("Main Camera").GetComponent <Camera>();
        mouseControl       = GameObject.Find("MouseControl").GetComponent <MouseControl>();
        startColorLockIcon = lockIcon.GetComponent <Renderer> ().material.color;

        layerMask = ~(1 << 8);
    }
 public void ClickIfStillHighlighted()
 {
     //if (guestButtonHighlighted) {
     loadingCircle.Click();
     LeanTween.scale(handCursor.rectTransform, Vector3.one * 1f, loadingCircle.totalTime);                 //.setEase(LeanTweenType.easeInSine);
     //LeanTween.alpha(handCursor.rectTransform,0f,1f);
     MouseControl.MouseClick();
     print("Mouse Click");
     //}
 }
示例#19
0
 //Joshua King
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Beam") && other.gameObject.GetComponent <Renderer> ().enabled == true)
     {
         Vector2 target         = MouseControl.GetWorldPositionOnPlane(new Vector2(0, 0), 0f);
         Vector2 current        = transform.position;
         Vector2 vectorToOrigin = Vector2.MoveTowards(-current, target, 3 * Time.deltaTime) * pullForce;
         rb2d.AddForce(vectorToOrigin);
     }
 }
示例#20
0
 /// <summary>
 /// Initialzes the Game.
 /// </summary>
 /// <param name="sceneManager">The Mogre SceneManager.</param>
 /// <param name="camera">The game CameraMan for the MouseControl.</param>
 /// <param name="mWindow">The RednerWindow for sending the width and height of the window.</param>
 /// <param name="mouse">The Mogre Mouse for GUI.</param>
 /// <param name="keyboard">The Mogre Keyboard for GUI.</param>
 /// <returns>Returns initializes Game singleton instance.</returns>
 private Game(SceneManager sceneManager, CameraMan camera, RenderWindow mWindow, Mouse mouse, Keyboard keyboard)
 {
     sceneMgr      = sceneManager;
     gameObjectMgr = GameObjectManager.GetInstance();
     gameGUI       = new GameGUI.GameGUI((int)mWindow.Width, (int)mWindow.Height, mouse, keyboard);
     mouseControl  = MouseControl.GetInstance(camera, (int)mWindow.Width, (int)mWindow.Height);
     paused        = true;
     soundPlayer   = new SoundPlayer(mWindow);
     mission       = new Mission();
 }
        public override void HoverWithin(string selector, Point point)
        {
            var element     = this.GetElement(selector, MatchConditions.None);
            int clickPointX = element.Position.X + point.X;
            int clickPointY = element.Position.Y + point.Y;

            MouseControl.SetPosition(new API.Point {
                X = clickPointX, Y = clickPointY
            });
        }
示例#22
0
 /// <summary>
 /// Make quick scope if sniper rifle isnt scoped.
 /// </summary>
 public void MakeQuickScope()
 {
     foreach (int weapon in sniperRiflesList)
     {
         if (GetWeaponID() == weapon && GetZoomLevel() == 0 && _turned)
         {
             MouseControl.ZoomIn();
         }
     }
 }
示例#23
0
    private void InitControl()
    {
        mUIControl      = new UIControl(this);
        mMouseControl   = new MouseControl(this);
        mCommandControl = new CommandControl(this);

        mUIControl.OnInit();
        mMouseControl.OnInit();
        mCommandControl.OnInit();
    }
示例#24
0
    void FixedUpdate()
    {
        if (turretToSpawn != null && isDragged)
        {
            Vector2 target = MouseControl.GetWorldPositionOnPlane(Input.mousePosition, 0f);

            turretToSpawn.transform.position = target;
            turretToSpawn.GetComponent <CircleCollider2D> ().transform.position = target;
        }
    }
示例#25
0
 /*
  * If in auto-update, the function just looks for the wrapper of filter component and assigns it to a variable.
  * Otherwise it instantiates a low pass filter.
  */
 void Start()
 {
     if (shouldUseComponent)
     {
         mouseControl = GetComponent <MouseControl>();
     }
     else
     {
         lowPassFilter = new LowPassFilter <Vector3>(a, Vector3.zero);
     }
 }
示例#26
0
 //This function performs a mouse click if the loading circle has completed and the cursor is still within the bounds of a butoon
 public void ClickIfStillHighlighted()
 {
     //tell the loading circle it has completed
     loadingCircle.Click();
     //tween the image out now a click has been performed
     LeanTween.scale(handCursor.rectTransform, Vector3.one * 1f, loadingCircle.totalTime);         //.setEase(LeanTweenType.easeInSine);
     //perform mouse click
     MouseControl.MouseClick();
     //Debug
     print("Mouse Click");
 }
        public override void Initialize()
        {
            _controls = new KeyboardControl();

#if WINDOWS

            _mouseInput = new MouseControl();

#endif

            base.Initialize();
        }
示例#28
0
    // Luke Smith
    // FixedUpdate is called once per physics update
    void FixedUpdate()
    {
        if (!orbit)
        {
            transform.up = -Vector2.MoveTowards(transform.position, attracter.transform.position, 1);
        }
        if (Vector2.Distance(attracter.transform.position, transform.position) <= radius && !orbit)
        {
            Vector2 target    = new Vector2(0, 0);
            Vector2 direction = new Vector2(target.x - transform.position.x, target.y - transform.position.y);
            direction.Normalize();

            Vector2 cross = new Vector2(direction.y, -direction.x);
            rb.velocity = (direction * 7) + (cross * (4 + PlayerController.instance.mass / 30));
            orbit       = true;
        }
        if (orbit)
        {
            //https://answers.unity.com/questions/1393567/how-can-i-make-game-object-to-orbit-another-using-2.html
            float   distance       = Vector2.Distance(this.transform.position, attracter.transform.position);    // Distance between us and attracter
            Vector2 unrotatedForce = (Vector2.right * gravityConstant * attracterMass) / Mathf.Pow(distance, 2); // Magnitude of force due to gravity

            // Now we have to rotate that force so it's pointing towards the attracter
            Vector2 posDifference   = attracter.transform.position - this.transform.position; // Difference in position
            float   angleDifference = Mathf.Atan2(posDifference.y, posDifference.x);          // Now, difference in angle

            // Now we use some trig to rotate the force vector from pointing right to pointing at the attracting object
            Vector2 rotatedForce = new Vector2(unrotatedForce.x * Mathf.Cos(angleDifference) - unrotatedForce.y * Mathf.Sin(angleDifference),
                                               unrotatedForce.x * Mathf.Sin(angleDifference) + unrotatedForce.y * Mathf.Cos(angleDifference));

            // And now we simply add the force to our rigidbody
            rb.AddForce(rotatedForce);

            transform.up = rb.velocity.normalized;
        }
        if (orbit && IsLookingAtObject(transform, attracter.transform.position, 70 + (PlayerController.instance.mass / 10)))
        {
            FireBullet(new Vector2(0, 0));
            if (timeSinceFiring < reloadTime)
            {
                timeSinceFiring += Time.deltaTime;
            }
        }

        //Joshua King
        if (inBeam)
        {
            Vector2 target         = MouseControl.GetWorldPositionOnPlane(new Vector2(0, 0), 0f);
            Vector2 current        = transform.position;
            Vector2 vectorToOrigin = Vector2.MoveTowards(3f * -current, 3f * target, 3 * Time.deltaTime);
            rb.AddForce(vectorToOrigin);
        }
    }
示例#29
0
 void Start()
 {
     //get all components
     fl   = floater.GetComponent <Floater>();
     fh   = floater.GetComponent <FloaterHinge>();
     flRb = floater.GetComponent <Rigidbody>();
     line = linestart.GetComponent <Line>();
     reel = GetComponent <ReelIn>();
     mc   = GetComponent <MouseControl>();
     //initialize start state
     EnableHinge();
 }
示例#30
0
    void OnEnable()
    {
        rb2d = GetComponent <Rigidbody2D>();
        Vector2 target         = MouseControl.GetWorldPositionOnPlane(new Vector2(0, 0), 0f);
        Vector2 current        = transform.position;
        Vector2 vectorToOrigin = Vector2.MoveTowards(-current, target, 3 * Time.deltaTime) * speed;

        vectorToOrigin.x += Random.Range(25, randomOffset);
        vectorToOrigin.y += Random.Range(25, randomOffset);

        rb2d.velocity = Vector2.zero;
        rb2d.AddForce(vectorToOrigin);
    }
示例#31
0
        private void MouseScroll(IBody body, IJoint rightHand, IJoint spineMid)
        {
            var zRightHandBodyDistance = spineMid.Position.Z - rightHand.Position.Z;

            if (zRightHandBodyDistance > 0.5f)
            {
                if (body.HandRightState == HandState.Closed)
                {
                    if (startScrollGesture == null)
                    {
                        startScrollGesture = new MouseGestureState(PHelper.CurrentTimeMillis());
                        startScrollGesture.oldCursorPosition = Cursor.Position;
                        mouseInScroll = true;
                    }

                    if (startScrollClickGesture == null)
                    {
                        startScrollClickGesture = new MouseGestureState(PHelper.CurrentTimeMillis());
                        startScrollClickGesture.oldCursorPosition = Cursor.Position;
                    }
                    else
                    {
                        var currentTime = PHelper.CurrentTimeMillis();
                        var timeDiff    = currentTime - startScrollClickGesture.TimeStamp;
                        if (timeDiff > 1000)
                        {
                            MouseControl.ScrollClick();
                            startScrollGesture      = null;
                            startScrollClickGesture = null;
                            mouseInScroll           = false;
                        }
                    }
                }
                else if (body.HandRightState == HandState.Open)
                {
                    if (startScrollGesture != null)
                    {
                        var currentPosition = Cursor.Position;
                        var yMovement       = -1 * (currentPosition.Y - startScrollGesture.oldCursorPosition.Y);
                        var times           = 10;
                        MouseControl.Scroll(times);
                        startScrollGesture = null;
                        mouseInScroll      = false;
                    }
                }
                else
                {
                    //ignore
                }
            }
        }
 protected SeleniumWebDriver(IWebDriver webDriver, Browser browser)
 {
     this.webDriver = webDriver;
     this.browser = browser;
     xPath = new XPath();
     elementFinder = new ElementFinder(xPath);
     fieldFinder = new FieldFinder(elementFinder, xPath);
     frameFinder = new FrameFinder(this.webDriver, elementFinder,xPath);
     textMatcher = new TextMatcher();
     buttonFinder = new ButtonFinder(elementFinder, textMatcher, xPath);
     sectionFinder = new SectionFinder(elementFinder, textMatcher);
     dialogs = new Dialogs(this.webDriver);
     mouseControl = new MouseControl(this.webDriver);
     optionSelector = new OptionSelector();
 }
 void Awake()
 {
     //m_dampening = (Screen.dpi / 96) * 10 * 0.5f;
     m_dampening = 1f;
     m_raycastCamera = GameObject.Find ("Main Camera").GetComponent<Camera>();
     mouseControl = GameObject.Find ("MouseControl").GetComponent<MouseControl>();
 }
示例#34
0
    void Start()
    {
        kills = 0;

        chatMessages = new Chat ();
        chatMessages.setMessageHistorySize (5);
        chatMessages.setMessageLifeSpan (10000);

        if (isLocalPlayer) {
            ShipCamera sc = gameObject.AddComponent<ShipCamera>();
            sc.setHeight(10);

            assignShip();
            setCameraToFollow();

            thisPlayer = this;
        }
        deadTimer = spawnDelay;
        mouseControl = gameObject.AddComponent<MouseControl> ();
        pointersActive = false;
    }
    void Awake()
    {
        m_dampening = (Screen.dpi / 96) * 100;
        m_raycastCamera = GameObject.Find ("Main Camera").GetComponent<Camera>();
        mouseControl = GameObject.Find ("MouseControl").GetComponent<MouseControl>();
        startColorLockIcon = lockIcon.GetComponent<Renderer> ().material.color;

        layerMask = ~(1 << 8);
    }
 void Awake()
 {
     m_dampening = 1f;
     m_raycastCamera = GameObject.Find ("Main Camera").GetComponent<Camera>();
     mouseControl = GameObject.Find ("MouseControl").GetComponent<MouseControl>();
 }