Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        _camera   = GetComponent <Camera>();
        _touchPad = GetComponentInChildren <TouchPad>();

        StartCoroutine(CloseUpCamera());
    }
Example #2
0
 void touchPad_FingerMove(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (enabled)
     {
         Cursor.Position = new Point((int)(e.X * region.Width) + region.Left, (int)(e.Y * region.Height) + region.Top);
     }
 }
Example #3
0
    private Camera myCam;               //나를 비추는 카메라..


    void Awake()
    {
        this.childTouchPad = this.GetComponentInChildren <TouchPad>();

        //나를 랜더링 하는 카메라...
        this.myCam = NGUITools.FindCameraForLayer(this.gameObject.layer);
    }
Example #4
0
    void Start()
    {
        spawn     = this.GetComponent <Spawn>();
        inventory = FindObjectOfType <Inventory>();

        controllerMove   = FindObjectOfType <Joystick>();
        controllerCamera = FindObjectOfType <TouchPad>();
        mainCamera       = Camera.main;
        screenCenter     = new Vector3(Screen.width / 2, Screen.height / 2, mainCamera.nearClipPlane);
    }
Example #5
0
 void Awake()
 {
     gameManager = (GameManager)GameObject.FindObjectOfType(typeof(GameManager));
     Normalize();
     followMouse = false;
     StartCoroutine(ScaleWidthCoroutine(widthRatio, transform.localScale.x, 1f));
     touchPad   = GameObject.Find("TouchPad").GetComponent <TouchPad>();
     anim       = GetComponentInChildren <Animator>();
     screenSize = new Vector2(Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.nearClipPlane)).x * 2, Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.nearClipPlane)).y * 2);
 }
Example #6
0
    public void StartScan()
    {
#if ANDROID_DEVICE
        if (controllerlink != null)
        {
            controllerlink.StartScan();
        }
#elif IOS_DEVICE
        TouchPad.ScanIOSBLEDevice(2);
#endif
    }
Example #7
0
    public void ConnectBLE()
    {
#if ANDROID_DEVICE
        if (controllerlink != null)
        {
            controllerlink.ConnectBLE();
        }
#elif IOS_DEVICE
        TouchPad.ConnectIOSBLEDevice(controllerlink.hummingBirdMac);
#endif
    }
Example #8
0
 void touchPad_FingerMove(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((TouchPad.FingerEventHandler)touchPad_FingerMove, sender, e);
     }
     else
     {
         this.handwritingDisplayPanel1.AddStrokePoint(e.X, e.Y);
     }
 }
 void touchPad_FingerMove(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (InvokeRequired)
     {
         TouchPad.FingerEventHandler h = new TouchPad.FingerEventHandler(touchPad_FingerMove);
         Invoke(h, sender, e);
     }
     else
     {
         panel1.Location = new Point((int)(e.X * this.ClientRectangle.Width), (int)(e.Y * this.ClientRectangle.Height));
     }
 }
Example #10
0
 void touchPad_FingerDown(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((TouchPad.FingerEventHandler)touchPad_FingerDown, sender, e);
     }
     else
     {
         if (Properties.Settings.Default.FirstRun)
         {
             this.tip.Active = false;
         }
         this.timer1.Stop();
         this.handwritingDisplayPanel1.AddStrokePoint(e.X, e.Y);
     }
 }
Example #11
0
 void touchPad_FingerDown(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (enabled)
     {
         Cursor.Position = new Point((int)(e.X * region.Width) + region.Left, (int)(e.Y * region.Height) + region.Top);
         //mouse_event(MouseEventFlags.LeftDown, 0, 0, 0, IntPtr.Zero);
         uint a = InputSender.SendInput(new InputSender.Input[] {
             new InputSender.Input {
                 type = InputSender.InputType.Mouse,
                 mi   = new InputSender.MouseInput {
                     flags = InputSender.MouseEventFlags.LeftDown,
                 }
             }
         });
     }
 }
Example #12
0
 void touchPad_FingerUp(TouchPad sender, TouchPad.FingerEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((TouchPad.FingerEventHandler)touchPad_FingerUp, sender, e);
     }
     else
     {
         this.handwritingDisplayPanel1.AddStrokePoint(e.X, e.Y);
         this.ink.CreateStroke(this.handwritingDisplayPanel1.EndStroke());
         this.updateRecognitionResult();
         //RecognitionResult result = this.ink.Strokes.RecognitionResult;
         ////this.recognizerContext.Strokes = this.ink.Strokes;
         //RecognitionStatus status;
         //RecognitionResult result = this.recognizerContext.Recognize(out status);
         //System.Diagnostics.Debug.WriteLine(result.TopString);
         if (this.settings.AutoInsertionEnabled)
         {
             this.timer1.Start();
         }
     }
 }
Example #13
0
    void TouchQuadrantEvents()
    {
        TouchPad[] touchPads = new TouchPad[] { left.touchPad, right.touchPad };

        foreach (TouchPad touchPad in touchPads)
        {
            bool topTouched    = false;
            bool rightTouched  = false;
            bool bottomTouched = false;
            bool leftTouched   = false;

            if (touchPad.x != 0 || touchPad.y != 0)
            {
                if (touchPad.y > 0 && Mathf.Abs(touchPad.y) > Mathf.Abs(touchPad.x))
                {
                    topTouched = true;
                }
                else if (touchPad.y < 0 && Mathf.Abs(touchPad.y) > Mathf.Abs(touchPad.x))
                {
                    bottomTouched = true;
                }
                else if (touchPad.x > 0 && Mathf.Abs(touchPad.x) > Mathf.Abs(touchPad.y))
                {
                    rightTouched = true;
                }
                else if (touchPad.x < 0 && Mathf.Abs(touchPad.x) > Mathf.Abs(touchPad.y))
                {
                    leftTouched = true;
                }
            }

            SetTouchEventState(touchPad.quadrant.top, topTouched, touchPad);
            SetTouchEventState(touchPad.quadrant.bottom, bottomTouched, touchPad);
            SetTouchEventState(touchPad.quadrant.right, rightTouched, touchPad);
            SetTouchEventState(touchPad.quadrant.left, leftTouched, touchPad);
        }
    }
        public static void Main()
        {
#if platform_test && !platform_beetle
            Configuration.SetPinFunction(23, DeviceFunction.I2C1_DATA);
            Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
            _mpu = Mpu6050.StartNew(1);
#elif !platform_test && platform_beetle
            _mpu = Mpu6050.StartNew(2);
#endif
            _mpuArgList = new ArrayList()
            {
                "", "", ""
            };
            _led = new PinController.LedBlinker(2);
            _touchController.Init();
            _palmTouch = _touchController.OpenPin(27, new TouchPadConfig()
            {
                PinSelectMode = TouchPinSelectMode.GpioIndex
            });
            _triggerTouch = _touchController.OpenPin(13, new TouchPadConfig()
            {
                PinSelectMode = TouchPinSelectMode.GpioIndex
            });


            Debug.WriteLine("Init");
            _led.On();
            Thread.Sleep(100);
            _led.Off();


            var AppID         = "Esp32.HairTrigger";
            var serverUdpPort = 48597;
            var nanoConfig    = new ArdNetClientConfig(AppID, null, serverUdpPort);
            nanoConfig.TCP.HeartbeatConfig.HeartbeatInterval    = TimeSpan.FromMilliseconds(2000);
            nanoConfig.TCP.HeartbeatConfig.ForceStrictHeartbeat = true;
            nanoConfig.TCP.HeartbeatConfig.RespondToHeartbeats  = false;

            _ardManager = new ArdNetClientManager(SystemConfig.WiFiCredentials, nanoConfig);
            _ardManager.TcpEndpointConnected    += ArdManager_TcpEndpointConnected;
            _ardManager.TcpEndpointDisconnected += NanoClient_ServerDisconnected;
            _ardManager.StartWorkerThread();

            Debug.WriteLine("Loop");

            MpuValue data;
            DateTime now;
            while (true)
            {
                _   = _serverMsgHandle.WaitOne();
                now = DateTime.UtcNow;

                if (!_palmTouch.IsTouched())
                {
                    Thread.Sleep(10);
                    continue;
                }

                if ((now - _mpuLastSend).TotalMilliseconds > 75)
                {
                    data = _mpu.GetData();
                    //gyro data
                    //x, y, z
                    _mpuArgList[0] = data.GyroX.ToString();
                    _mpuArgList[1] = data.GyroY.ToString();
                    _mpuArgList[2] = data.GyroZ.ToString();

                    var request = TcpRequest.CreateOutbound("MPU", _mpuArgList);
                    _ardManager.EnqueueTask(x =>
                    {
                        _ = x.SendCommand(request);
                    });
                    _mpuLastSend = now;
                }

                now = DateTime.UtcNow;
                if (!_triggerIsDown && (now - _triggerLastSend).TotalMilliseconds > 50)
                {
                    if (_triggerTouch.IsTouched())
                    {
                        _ardManager.EnqueueTask(x => x.SendCommand(_triggerTcpRequest_Down));
                        _triggerIsDown   = true;
                        _triggerLastSend = now;
                    }
                }
                else if (_triggerIsDown && (now - _triggerLastSend).TotalMilliseconds > 10)
                {
                    if (!_triggerTouch.IsTouched())
                    {
                        _ardManager.EnqueueTask(x => x.SendCommand(_triggerTcpRequest_Up));
                        _triggerIsDown   = false;
                        _triggerLastSend = now;
                    }
                }
            }
        }
Example #15
0
 public void TPTouchBegan(TouchPad touchPad, Vector2 position)
 {
     Debug.Log ("Touch began...");
 }
Example #16
0
 public void TPTouchEnded(TouchPad touchPad, Vector2 position)
 {
     Debug.Log ("Touch ended...");
 }
Example #17
0
 public void TPTouchMoved(TouchPad touchPad, Vector2 position, Vector2 previousPosition)
 {
     gameObject.transform.position += new Vector3((position.x - previousPosition.x) * 0.05f, (position.y - previousPosition.y) * 0.05f, 0f);
 }
Example #18
0
 void OnDestroy()
 {
     MoveJoystick   = null;
     AttackJoystick = null;
 }
Example #19
0
 void Awake()
 {
     MoveJoystick   = m_CharacterMoveJoy.GetTouchControl <TouchPad>();
     AttackJoystick = m_AttackJoy.GetTouchControl <TouchPad>();
 }
Example #20
0
 void touchPadInput(TouchPad touchPad)
 {
 }
Example #21
0
 void Start()
 {
     touchPad         = GameObject.Find("TouchJoyStick").GetComponent <TouchPad>();
     touchPad._player = this;
 }
Example #22
0
    /// <summary>
    /// The delegate that will respond to our touchpad's events for buying smooth moves
    /// </summary>
    /// <param name="touchEvent">The event captured by the touchpad</param>
    /// <param name="screenPosition">The screen position of the event</param>
    /// <param name="guiPosition">The GUI position of the event</param>
    /// <param name="worldPosition">The world position of the event</param>
    public void BuyNow_TouchPadDelegate(TouchPad.TOUCH_EVENT touchEvent, Vector2 screenPosition, Vector3 guiPosition, Vector3 worldPosition)
    {
        switch (touchEvent)
        {
            case TouchPad.TOUCH_EVENT.TouchDown:

                gameManager.ShowAssetStoreLink();

                break;
        }
    }
Example #23
0
    void TouchOctantEvents()
    {
        TouchPad[] touchPads = new TouchPad[] { left.touchPad, right.touchPad };

        foreach (TouchPad touchPad in touchPads)
        {
            bool touchingTop         = false;
            bool touchingTopRight    = false;
            bool touchingRight       = false;
            bool touchingBottomRight = false;
            bool touchingBottom      = false;
            bool touchingBottomLeft  = false;
            bool touchingLeft        = false;
            bool touchingTopLeft     = false;

            if (touchPad.x != 0 || touchPad.y != 0)
            {
                // Detects if touch pad is on top octant

                // Detects if touch pad is in one of the corners:
                if (Mathf.Abs(touchPad.x) * 2 > Mathf.Abs(touchPad.y) &&
                    Mathf.Abs(touchPad.y) * 2 > Mathf.Abs(touchPad.x))
                {
                    if (touchPad.y > 0 && touchPad.x > 0)
                    {
                        touchingTopRight = true;
                    }
                    else if (touchPad.y < 0 && touchPad.x > 0)
                    {
                        touchingBottomRight = true;
                    }
                    else if (touchPad.y < 0 && touchPad.x < 0)
                    {
                        touchingBottomLeft = true;
                    }
                    else if (touchPad.y > 0 && touchPad.x < 0)
                    {
                        touchingTopLeft = true;
                    }
                    // the touch pad is in one of the four cardinal directions.
                }
                else
                {
                    if (touchPad.y > 0 && Mathf.Abs(touchPad.y) > Mathf.Abs(touchPad.x) * 2)
                    {
                        touchingTop = true;
                    }
                    else if (touchPad.y < 0 && Mathf.Abs(touchPad.y) > Mathf.Abs(touchPad.x) * 2)
                    {
                        touchingBottom = true;
                    }
                    else if (touchPad.x > 0 && Mathf.Abs(touchPad.x) > Mathf.Abs(touchPad.y) * 2)
                    {
                        touchingRight = true;
                    }
                    else if (touchPad.x < 0 && Mathf.Abs(touchPad.x) > Mathf.Abs(touchPad.y) * 2)
                    {
                        touchingLeft = true;
                    }
                }
            }

            SetTouchEventState(touchPad.octant.top, touchingTop, touchPad);
            SetTouchEventState(touchPad.octant.bottom, touchingBottom, touchPad);
            SetTouchEventState(touchPad.octant.right, touchingRight, touchPad);
            SetTouchEventState(touchPad.octant.left, touchingLeft, touchPad);
            SetTouchEventState(touchPad.octant.topLeft, touchingTopLeft, touchPad);
            SetTouchEventState(touchPad.octant.bottomLeft, touchingBottomLeft, touchPad);
            SetTouchEventState(touchPad.octant.topRight, touchingTopRight, touchPad);
            SetTouchEventState(touchPad.octant.topLeft, touchingTopLeft, touchPad);
        }
    }
Example #24
0
 void SetTouchEventState(TouchEvent touchEvent, bool isTouched, TouchPad touchPad)
 {
     touchEvent.SetTouched(isTouched);
     touchEvent.SetPressed(isTouched && touchPad.pressed);
 }
Example #25
0
 private void Start()
 {
     instance = this;
 }
Example #26
0
    /// <summary>
    /// The delegate that will respond to our touchpad's events
    /// </summary>
    /// <param name="touchEvent">The event captured by the touchpad</param>
    /// <param name="screenPosition">The screen position of the event</param>
    /// <param name="guiPosition">The GUI position of the event</param>
    /// <param name="worldPosition">The world position of the event</param>
    public void TouchPadDelegate(TouchPad.TOUCH_EVENT touchEvent, Vector2 screenPosition, Vector3 guiPosition, Vector3 worldPosition)
    {
        // if showing asset store link, don't process regular touch input
        if (gameManager.BuyNow)
        {
            gameManager.BuyNow = false;
            return;
        }

        // if the game is over or the chef is picking up the weapon, then jump out
        if (gameManager.State == GameManager.STATE.GameOver || gameManager.chef.State == Chef.STATE.PickingUpWeapon)
            return;

        // if the game is waiting for the user to press the screen
        if (gameManager.State == GameManager.STATE.WaitingForInput)
        {
            switch (touchEvent)
            {
                case TouchPad.TOUCH_EVENT.TouchDown:

                    // user pressed the screen, so now we can play

                    gameManager.State = GameManager.STATE.Playing;
                    return;
            }

            return;
        }

        // check the state of the chef before processing any input
        gameManager.chef.CheckState();

        switch (touchEvent)
        {
            case TouchPad.TOUCH_EVENT.TouchDown:

                // the touchpad received a touch began event,
                // so we capture and store some values

                _touchingScreen = true;
                _touchDownTime = Time.realtimeSinceStartup;
                _touchDownPosition = worldPosition;

                break;

            case TouchPad.TOUCH_EVENT.TouchMove:
            case TouchPad.TOUCH_EVENT.TouchStationary:

                // the touchpad received a move or stationary touch event
                // (finger / mouse is pressing the screen)

                // store the offset from the chef to the world position of the touch
                Vector3 offset = gameManager.chef.OffsetFromPosition(worldPosition);

                // make the chef face the direction of the touch
                gameManager.chef.FaceDirection(offset);

                // if the chef is not attacking and we are touching the screen
                if (gameManager.chef.State != Chef.STATE.Attacking && _touchingScreen)
                {
                    // get the amount of time that has elapsed since we began the touch
                    _touchTime = Time.realtimeSinceStartup - _touchDownTime;

                    // if the amount of elapsed time is greater than our minimum press and hold time
                    if (_touchTime >= minPressAndHoldTime)
                    {
                        // if the chef is in a standing state
                        if (gameManager.chef.State == Chef.STATE.Standing)
                        {
                            // if the distance from our touch to the chef is greater than the minimum starting distance
                            if (offset.sqrMagnitude >= _minStartingDistanceSquared)
                            {
                                // make the chef run towards the touch
                                gameManager.chef.Run(offset, true);
                            }
                        }
                        else
                        {
                            // chef is not in a standing state

                            // if the distance from the touch to the chef is less than the stopping distance
                            if (offset.sqrMagnitude <= _maxStoppingDistanceSquared)
                            {
                                // make the chef stand still
                                gameManager.chef.Stand(true);
                            }
                            else
                            {
                                // chef is still farther away from the touch than the max stopping distance, so
                                // make him continue to run
                                gameManager.chef.Run(offset, false);
                            }
                        }
                    }
                }
                break;

            case TouchPad.TOUCH_EVENT.TouchUp:

                // the touchpad received a touch end event

                // if the chef is not attacking and we are touching the screen
                if (gameManager.chef.State != Chef.STATE.Attacking && _touchingScreen)
                {
                    // capture the time since we began touching
                    _touchTime = Time.realtimeSinceStartup - _touchDownTime;

                    // cache the distance of the touch from its initial position
                    _touchDistanceSquared = (_touchDownPosition - worldPosition).sqrMagnitude;

                    // if the touch was a tap (didn't move the touch much and didn't press very long)
                    if (
                        _touchDistanceSquared <= _maxTapMoveDistanceSquared
                        &&
                        _touchTime < minPressAndHoldTime
                        )
                    {
                        // make the chef attack
                        gameManager.chef.Attack(worldPosition);
                    }
                }

                // we are no longer touching the screen
                _touchingScreen = false;

                // if the chef is running
                if (gameManager.chef.State == Chef.STATE.Running)
                {
                    // make the chef stand still
                    gameManager.chef.Stand(true);
                }

                break;
        }
    }
Example #27
0
 public void Awake()
 {
     TouchPad.instance = this;
 }