public override bool processInput(GestureProfile profile)
    {
        if (Input.touchCount > 0)
        {
            //
            //Check for adding new touches
            //
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.touches[i];
                if (touch.phase == TouchPhase.Began)
                {
                    touchDatas.Add(touch.fingerId, new TouchData(touch));
                    origTouchCenter           = TouchCenter;
                    origCameraZoom            = Managers.Camera.ZoomLevel;
                    origAvgDistanceFromCenter = AverageDistanceFromCenter;
                }
            }
            maxTouchCount = Mathf.Max(maxTouchCount, Input.touchCount);

            //
            // Gesture Identification
            //

            if (touchEvent == TouchEvent.UNKNOWN)
            {
                if (maxTouchCount == 1)
                {
                    Touch     touch = Input.touches[0];
                    TouchData data  = touchDatas[touch.fingerId];
                    //Drag Gesture
                    if (Vector2.Distance(data.origPosScreen, touch.position) >= dragThreshold)
                    {
                        touchEvent = TouchEvent.DRAG;
                    }
                    //Hold Gesture
                    if (Time.time - data.origTime >= holdThreshold)
                    {
                        touchEvent = TouchEvent.HOLD;
                    }
                }
                //If more than one touch
                else if (maxTouchCount > 1)
                {
                    touchEvent = TouchEvent.CAMERA;
                }
            }
            //If converting from a player gesture to a camera gesture,
            else if (touchEvent != TouchEvent.CAMERA && maxTouchCount > 1)
            {
                //End the current player gesture
                //(No need to process tap gesture,
                //because it requires that all input stops to activate)
                Touch     touch = Input.touches[0];
                TouchData data  = touchDatas[touch.fingerId];
                switch (touchEvent)
                {
                //DRAG
                case TouchEvent.DRAG:
                    profile.processDragGesture(
                        data.origPosWorld,
                        Utility.ScreenToWorldPoint(touch.position),
                        DragType.DRAG_PLAYER,
                        true
                        );
                    break;

                //HOLD
                case TouchEvent.HOLD:
                    profile.processHoldGesture(
                        Utility.ScreenToWorldPoint(touch.position),
                        Time.time - data.origTime,
                        true
                        );
                    break;
                }
                //Convert to camera gesture
                touchEvent = TouchEvent.CAMERA;
            }

            //
            //Main Processing
            //

            if (maxTouchCount == 1)
            {
                Touch     touch = Input.touches[0];
                TouchData data  = touchDatas[touch.fingerId];
                switch (touchEvent)
                {
                //DRAG
                case TouchEvent.DRAG:
                    profile.processDragGesture(
                        data.origPosWorld,
                        Utility.ScreenToWorldPoint(touch.position),
                        DragType.DRAG_PLAYER,
                        touch.phase == TouchPhase.Ended
                        );
                    break;

                //HOLD
                case TouchEvent.HOLD:
                    profile.processHoldGesture(
                        Utility.ScreenToWorldPoint(touch.position),
                        Time.time - data.origTime,
                        touch.phase == TouchPhase.Ended
                        );
                    break;
                }

                //
                // Check for tap end
                //
                if (touch.phase == TouchPhase.Ended)
                {
                    //If it's unknown,
                    if (touchEvent == TouchEvent.UNKNOWN)
                    {
                        //Then it's a tap
                        profile.processTapGesture(Utility.ScreenToWorldPoint(touch.position));
                    }
                }
            }
            else if (maxTouchCount > 1)
            {
                //Get the center and drag the camera to it
                profile.processDragGesture(
                    origTouchCenterWorld,
                    Utility.ScreenToWorldPoint(TouchCenter),
                    DragType.DRAG_CAMERA,
                    Input.touches
                    .Where(t =>
                           t.phase != TouchPhase.Ended &&
                           t.phase != TouchPhase.Canceled
                           ).ToArray()
                    .Length == 0
                    );
                //Get the change in scale and zoom the camera
                float adfc = AverageDistanceFromCenter;
                if (adfc > 0)
                {
                    float scaleFactor = origAvgDistanceFromCenter / adfc;
                    Managers.Camera.ZoomLevel = origCameraZoom * scaleFactor;
                }
            }

            //
            //Check for removing touches
            //
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.touches[i];
                if (touch.phase == TouchPhase.Ended)
                {
                    touchDatas.Remove(touch.fingerId);
                    origTouchCenter           = TouchCenter;
                    origCameraZoom            = Managers.Camera.ZoomLevel;
                    origAvgDistanceFromCenter = AverageDistanceFromCenter;
                }
            }
            return(true);
        }
        //If there is no input,
        else
        {
            //Reset gesture variables
            touchEvent                = TouchEvent.UNKNOWN;
            maxTouchCount             = 0;
            origTouchCenter           = Vector2.zero;
            origCameraZoom            = Managers.Camera.ZoomLevel;
            origAvgDistanceFromCenter = 0;
            touchDatas.Clear();
            return(false);
        }
    }
 /// <summary>
 /// Gos to touch position.
 /// タッチ位置に移動する
 /// </summary>
 /// <param name='touchData'>
 /// Touch data.
 /// </param>
 public override void GoToTouchPosition(TouchData touchData)
 {
     float x = this.CalcTuchPositionToSpriteQTX(touchData);
     float y = this.CalcTuchPositionToSpriteQTY(touchData);
     foreach (SpriteForTouch spriteForTouch in this.Sprites) {
         spriteForTouch.Sprite.Quad.T.X = x;
         spriteForTouch.Sprite.Quad.T.X = y;
     }
 }
    void Update()
    {
        if (Input.touchCount < 1)
            return;

        Touch touch = Input.GetTouch(0);

        // Cache the touch data.
        _touchData = new TouchData(touch);
    }
    private void ContinueMouseTouchRaycast(int touchIndex, Transform touchedTransform, RaycastHit hit)
    {
        //RaycastHit hit = new RaycastHit ();
        //if (ShootRaycast (out hit))
        //{
            TouchData data = new TouchData();
            data.touchIndex = touchIndex;
            data.touchPosition = hit.point;
            if (hit.point != oldHitPoint)
                touchedTransform.SendMessage ("OnMouseDraggingMoved", data, SendMessageOptions.DontRequireReceiver);
            else
                touchedTransform.SendMessage ("OnMouseDragging", data, SendMessageOptions.DontRequireReceiver);

            //oldHitPoint = hit.point;
        /*	}
        else //If the user drags the mouse into empty space.
        {
            touchedTransform.SendMessage ("OnMouseDraggedOff", SendMessageOptions.DontRequireReceiver);
        }
        */
        oldHitPoint = hit.point;
    }
Exemple #5
0
        public void Evaluate(int SpreadMax)
        {
            this.FOutCtrl[0] = this;
            this.FOutRef[0]  = (INode)this.FHost;

            if (this.FOutQueryable[0] == null)
            {
                this.FOutQueryable[0] = this;
            }
            if (this.FOutBackBuffer[0] == null)
            {
                this.FOutBackBuffer[0] = new DX11Resource <DX11SwapChain>();
                this.FOuFS             = new Spread <DX11Resource <DX11SwapChain> >();
                this.FOuFS.SliceCount  = 1;
                this.FOuFS[0]          = new DX11Resource <DX11SwapChain>();
            }

            this.updateddevices.Clear();
            this.rendereddevices.Clear();
            this.FInvalidateSwapChain = false;

            if (!this.depthmanager.FormatChanged) // do not clear reset if format changed
            {
                this.depthmanager.NeedReset = false;
            }
            else
            {
                this.depthmanager.FormatChanged = false; //Clear flag ok
            }

            if (FInAASamplesPerPixel.IsChanged || this.FInBufferCount.IsChanged)
            {
                this.depthmanager.NeedReset = true;
                this.FInvalidateSwapChain   = true;
            }

            if (this.FInFullScreen.IsChanged)
            {
                string path;
                this.FHost.GetNodePath(false, out path);
                INode2 n2 = hde.GetNodeFromPath(path);

                if (n2.Window != null)
                {
                    if (n2.Window.IsVisible)
                    {
                        if (this.FInFullScreen[0])
                        {
                            hde.SetComponentMode(n2, ComponentMode.Fullscreen);
                        }
                        else
                        {
                            hde.SetComponentMode(n2, ComponentMode.InAWindow);
                        }
                    }
                }
            }

            /*if (this.FInFullScreen.IsChanged)
             * {
             *  if (this.FInFullScreen[0])
             *  {
             *      string path;
             *      this.FHost.GetNodePath(false, out path);
             *      INode2 n2 = hde.GetNodeFromPath(path);
             *      hde.SetComponentMode(n2, ComponentMode.Fullscreen);
             *  }
             *  else
             *  {
             *      string path;
             *      this.FHost.GetNodePath(false, out path);
             *      INode2 n2 = hde.GetNodeFromPath(path);
             *      hde.SetComponentMode(n2, ComponentMode.InAWindow);
             *  }
             * }*/

            this.FOutKState[0]         = new KeyboardState(this.FKeys);
            this.FOutMouseState[0]     = MouseState.Create(this.FMousePos.x, this.FMousePos.y, this.FMouseButtons.x > 0.5f, this.FMouseButtons.y > 0.5f, this.FMouseButtons.z > 0.5f, false, false, this.wheel);
            this.FOutBackBufferSize[0] = new Vector2D(this.Width, this.Height);

            this.FOutTouchSupport[0] = this.touchsupport;

            this.FOutTouchData.SliceCount = this.touches.Count;

            int   tcnt = 0;
            float fw   = (float)this.ClientSize.Width;
            float fh   = (float)this.ClientSize.Height;

            lock (m_touchlock)
            {
                foreach (int key in touches.Keys)
                {
                    TouchData t = touches[key];

                    this.FOutTouchData[tcnt] = t.Clone(fw, fh);
                    t.IsNew = false;
                    tcnt++;
                }
            }
        }
 public void PlayerTouchedEnvironment(TouchData data)
 {
     OnPlayerTouchEnvironment(data);
 }
Exemple #7
0
        /// 入力情報の登録
        private void setDataInfo( int index, TouchData touchData )
        {
            inputTouchData[index].Id		= touchData.ID;
            inputTouchData[index].ScrPosX	= getScrPosX( touchData );
            inputTouchData[index].ScrPosY	= getScrPosY( touchData );

            switch( touchData.Status ){
            case TouchStatus.None:	 	inputTouchData[index].State	= InputTouchState.None;		break;
            case TouchStatus.Down:	 	inputTouchData[index].State	= InputTouchState.Down;		break;
            case TouchStatus.Up:	 	inputTouchData[index].State	= InputTouchState.Up;		break;
            case TouchStatus.Move:	 	inputTouchData[index].State	= InputTouchState.Move;		break;
            case TouchStatus.Canceled:	inputTouchData[index].State	= InputTouchState.Canceled;	break;
            }

            isDataNum		++;
        }
Exemple #8
0
 /// private メソッド
 ///---------------------------------------------------------------------------
 /// スクリーン座標を返す
 private int getScrPosX( TouchData touchData )
 {
     return( (int)((touchData.X + 0.5f) * trgScrWidth) );
 }
 /// <summary>
 /// Check Touchs the sprite. only touchOn = true.
 /// スプライトをタッチしたか確認する。(touchOn = trueの場合)
 /// </summary>
 /// <returns>
 /// The sprite.
 /// </returns>
 /// <param name='touchData'>
 /// If set to <c>true</c> touch data.
 /// </param>
 public override bool TouchSprite(TouchData touchData)
 {
     if (this.TouchOn) {
         if ((this.Sprites[this.NowIndex].Sprite.Quad.T.X - this.Sprites[this.NowIndex].Sprite.Quad.S.X/2 < this.CalcTuchPositionToSpriteQTX(touchData) && this.CalcTuchPositionToSpriteQTX(touchData) < this.Sprites[this.NowIndex].Sprite.Quad.T.X + this.Sprites[this.NowIndex].Sprite.Quad.S.X/2) &&
                 (this.Sprites[this.NowIndex].Sprite.Quad.T.Y - this.Sprites[this.NowIndex].Sprite.Quad.S.Y/2 < this.CalcTuchPositionToSpriteQTY(touchData) && this.CalcTuchPositionToSpriteQTY(touchData) < this.Sprites[this.NowIndex].Sprite.Quad.T.Y + this.Sprites[this.NowIndex].Sprite.Quad.S.Y/2)){
             return true;
         }else{
             return false;
         }
     } else {
         return false;
     }
 }
 private void touchEnv(TouchData data)
 {
     //spawnedWayPoint.SendMessage("PointAt", data.touchPosition);
 }
Exemple #11
0
 // body callbacks
 public void OnHealthChange(int current, int change, TouchData data)
 {
     Console.WriteLine($"Hurt turret");
 }
Exemple #12
0
        /// <inheritdoc />
        protected override void touchEnded(TouchPoint touch)
        {
            base.touchEnded(touch);

            TouchData onTarget = new TouchData();
            var data = getPointerData(touch);
            ExecuteEvents.Execute(gameObject, data.Data, ExecuteEvents.pointerUpHandler);
            if (data.OnTarget) onTarget = data;
            removePointerData(touch);

            // One of the touches was released ontop of the target
            if (onTarget.OnTarget) ExecuteEvents.Execute(gameObject, onTarget.Data, ExecuteEvents.pointerClickHandler);

            if (activeTouches.Count == 0) setState(GestureState.Ended);
        }
Exemple #13
0
 /// <summary>
 /// 当たり判定を取得
 /// </summary>
 /// <param name='touch'>タッチデータ</param>
 /// <param name='sprite'>スプライト</param>
 /// <returns>当たっていた場合 true</returns>
 public bool IsCollide(TouchData touch, SpriteUV sprite)
 {
     Vector2 touchPos = GetTouchPos(touch);
     Vector2 spritePos = sprite.Position;
     float width = sprite.TextureInfo.Texture.Width;
     float height = sprite.TextureInfo.Texture.Height;
     return (
         touchPos.X > spritePos.X - width / 2 &&
         touchPos.X < spritePos.X + width / 2 &&
         touchPos.Y > spritePos.Y - height / 2 &&
         touchPos.Y < spritePos.Y + height / 2);
 }
Exemple #14
0
 public TouchResponseData Touch(TouchData touchData)
 {
     Console.WriteLine($"Touch turret");
     return(TouchResponseData.empty);
 }
Exemple #15
0
 /// <summary>
 /// タッチのポジション取得
 /// </summary>
 /// <returns>タッチのポジション</returns>
 /// <param name='touch'>タッチデータ</param>
 public Vector2 GetTouchPos(TouchData touch)
 {
     return new Vector2(
         (touch.X + 0.5f) * ScreenWidth,
         (-touch.Y + 0.5f) * ScreenHeight); // 座標系が左下なのでマイナス
 }
Exemple #16
0
 public InputMessageTouch(TouchData touchEvent)
 {
     this.touchEvent = touchEvent;
 }
Exemple #17
0
 private void touchEnv(TouchData data)
 {
     //spawnedWayPoint.SendMessage("PointAt", data.touchPosition);
 }
Exemple #18
0
 /// タッチ座標 -> 画面座標 : Y
 public static int TouchPixelY(TouchData touchData)
 {
     return((int)((touchData.Y + 0.5f) * Height));
 }
 void OnMouseStart(TouchData data)
 {
     GameController.instance.PlayerTouchedEnvironment(data);
 }
Exemple #20
0
 /// <summary>
 /// Gets or creates pointer data for touch.
 /// </summary>
 /// <param name="touch"> The touch. </param>
 /// <returns> Pointer data. </returns>
 protected virtual TouchData getPointerData(TouchPoint touch)
 {
     TouchData data;
     if (!pointerData.TryGetValue(touch.Id, out data))
     {
         data = new TouchData
         {
             OnTarget = true,
             Data = new PointerEventData(EventSystem.current)
             {
                 pointerId = touch.Id,
                 pointerEnter = gameObject,
                 pointerPress = gameObject,
                 eligibleForClick = true,
                 delta = Vector2.zero,
                 dragging = false,
                 useDragThreshold = true,
                 position = touch.Position,
                 pressPosition = touch.Position,
                 pointerPressRaycast = touch.Hit.RaycastResult,
                 pointerCurrentRaycast = touch.Hit.RaycastResult
             }
         };
         pointerData.Add(touch.Id, data);
     }
     return data;
 }
Exemple #21
0
        public static void CheckEvents()
        {
            SakuraGameWindow.ProcessEvents();


            bool __isWinFocused = SakuraGameWindow.getFocused();

            OpenTK.Input.KeyboardState keyboard = OpenTK.Input.Keyboard.GetState();
            GamePadData gamePadData             = GamePad.__gamePadData;

            gamePadData.ButtonsPrev = gamePadData.Buttons;
            gamePadData.ButtonsDown = 0;
            gamePadData.Buttons     = 0;
            gamePadData.ButtonsUp   = 0;

            if (__isWinFocused)
            {
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
                {
                    System.Environment.Exit(0);
                }
                //
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Left))
                {
                    if (!__isKeyLeftDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Left;
                    }
                    __isKeyLeftDown      = true;
                    gamePadData.Buttons |= GamePadButtons.Left;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Right))
                {
                    if (!__isKeyRightDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Right;
                    }
                    __isKeyRightDown     = true;
                    gamePadData.Buttons |= GamePadButtons.Right;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Up))
                {
                    if (!__isKeyUpDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Up;
                    }
                    __isKeyUpDown        = true;
                    gamePadData.Buttons |= GamePadButtons.Up;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Down))
                {
                    if (!__isKeyDownDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Down;
                    }
                    __isKeyDownDown      = true;
                    gamePadData.Buttons |= GamePadButtons.Down;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.A))
                {
                    if (!__isKeyADown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Square;
                    }
                    __isKeyADown         = true;
                    gamePadData.Buttons |= GamePadButtons.Square;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.W))
                {
                    if (!__isKeyWDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Triangle;
                    }
                    __isKeyWDown         = true;
                    gamePadData.Buttons |= GamePadButtons.Triangle;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.D))
                {
                    if (!__isKeyDDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Circle;
                        gamePadData.ButtonsDown |= GamePadButtons.Back;
                    }
                    __isKeyDDown         = true;
                    gamePadData.Buttons |= GamePadButtons.Circle;
                    gamePadData.Buttons |= GamePadButtons.Back;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.S))
                {
                    if (!__isKeySDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Cross;
                        gamePadData.ButtonsDown |= GamePadButtons.Enter;
                    }
                    __isKeySDown         = true;
                    gamePadData.Buttons |= GamePadButtons.Cross;
                    gamePadData.Buttons |= GamePadButtons.Enter;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.X))
                {
                    if (!__isKeyXDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Start;
                    }
                    __isKeyXDown         = true;
                    gamePadData.Buttons |= GamePadButtons.Start;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Z))
                {
                    if (!__isKeyZDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.Select;
                    }
                    __isKeyZDown         = true;
                    gamePadData.Buttons |= GamePadButtons.Select;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.Q))
                {
                    if (!__isKeyQDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.L;
                    }
                    __isKeyQDown         = true;
                    gamePadData.Buttons |= GamePadButtons.L;
                }
                if (keyboard.IsKeyDown(OpenTK.Input.Key.E))
                {
                    if (!__isKeyEDown)
                    {
                        gamePadData.ButtonsDown |= GamePadButtons.R;
                    }
                    __isKeyEDown         = true;
                    gamePadData.Buttons |= GamePadButtons.R;
                }



                if (keyboard.IsKeyUp(OpenTK.Input.Key.Left))
                {
                    if (__isKeyLeftDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Left;
                    }
                    __isKeyLeftDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.Right))
                {
                    if (__isKeyRightDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Right;
                    }
                    __isKeyRightDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.Up))
                {
                    if (__isKeyUpDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Up;
                    }
                    __isKeyUpDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.Down))
                {
                    if (__isKeyDownDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Down;
                    }
                    __isKeyDownDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.A))
                {
                    if (__isKeyADown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Square;
                    }
                    __isKeyADown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.W))
                {
                    if (__isKeyWDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Triangle;
                    }
                    __isKeyWDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.D))
                {
                    if (__isKeyDDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Circle;
                        gamePadData.ButtonsUp |= GamePadButtons.Back;
                    }
                    __isKeyDDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.S))
                {
                    if (__isKeySDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Cross;
                        gamePadData.ButtonsUp |= GamePadButtons.Enter;
                    }
                    __isKeySDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.X))
                {
                    if (__isKeyXDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Start;
                    }
                    __isKeyXDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.Z))
                {
                    if (__isKeyZDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.Select;
                    }
                    __isKeyZDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.Q))
                {
                    if (__isKeyQDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.L;
                    }
                    __isKeyQDown = false;
                }
                if (keyboard.IsKeyUp(OpenTK.Input.Key.E))
                {
                    if (__isKeyEDown)
                    {
                        gamePadData.ButtonsUp |= GamePadButtons.R;
                    }
                    __isKeyEDown = false;
                }
            }
            else
            {
                __isKeyLeftDown  = false;
                __isKeyRightDown = false;
                __isKeyUpDown    = false;
                __isKeyDownDown  = false;
                __isKeyADown     = false;
                __isKeyWDown     = false;
                __isKeyDDown     = false;
                __isKeySDown     = false;
                __isKeyXDown     = false;
                __isKeyZDown     = false;
                __isKeyQDown     = false;
                __isKeyEDown     = false;
            }


            Touch.__data.Clear();
            if (__isWinFocused)
            {
                //OpenTK.Input.MouseState mouse = OpenTK.Input.Mouse.GetState();
                OpenTK.Input.MouseState mouse = OpenTK.Input.Mouse.GetCursorState();
                OpenTK.Point            pt    = SakuraGameWindow.PointToClient(new OpenTK.Point(mouse.X, mouse.Y));
                float winW = SakuraGameWindow.getWidth();
                float winH = SakuraGameWindow.getHeight();
                if (mouse.IsButtonUp(OpenTK.Input.MouseButton.Left))
                {
                    if (__isMouseLeftDown == true)
                    {
                        TouchData touchData = new TouchData();
                        touchData.ID     = 0;
                        touchData.Status = TouchStatus.Up;
                        touchData.X      = (winW > 0 ? (float)pt.X / winW : 0) - 0.5f;
                        touchData.Y      = (winH > 0 ? (float)pt.Y / winH : 0) - 0.5f;
                        Touch.__data.Add(touchData);
                        //Debug.WriteLine("down:" + pt.X + "," + pt.Y);
                    }
                    __isMouseLeftDown = false;
                }
                //OpenTK.WindowState wState = MyGameWindow.getWindowState();
                //wState != OpenTK.WindowState.Minimized
                if (mouse.IsButtonDown(OpenTK.Input.MouseButton.Left))
                {
                    if (__isMouseLeftDown == false)
                    {
                        TouchData touchData = new TouchData();
                        touchData.ID     = 0;
                        touchData.Status = TouchStatus.Down;
                        touchData.X      = (winW > 0 ? (float)pt.X / winW : 0) - 0.5f;
                        touchData.Y      = (winH > 0 ? (float)pt.Y / winH : 0) - 0.5f;
                        Touch.__data.Add(touchData);
                    }
                    else
                    {
                        TouchData touchData = new TouchData();
                        touchData.ID     = 0;
                        touchData.Status = TouchStatus.Move;
                        touchData.X      = (winW > 0 ? (float)pt.X / winW : 0) - 0.5f;
                        touchData.Y      = (winH > 0 ? (float)pt.Y / winH : 0) - 0.5f;
                        Touch.__data.Add(touchData);
                    }
                    __isMouseLeftDown = true;
                }
            }
            else
            {
                __isMouseLeftDown = false;
            }

#if false
            double delta = __timer.Elapsed.TotalMilliseconds;
            double frame = 1000.0 / 24.0;
            if (delta < frame)
            {
                int free = (int)(frame - delta);
                Thread.Sleep(free);
                //Debug.WriteLine("Sleep: " + free);
            }
            __timer.Restart();
#endif
        }
 /// <summary>
 /// Gos to touch position.
 /// タッチ位置に移動する
 /// </summary>
 /// <param name='touchData'>
 /// Touch data.
 /// </param>
 public void GoToTouchPosition(TouchData touchData)
 {
     this.Sprite.Quad.T.X = this.CalcTuchPositionToSpriteQTX(touchData);
     this.Sprite.Quad.T.Y = this.CalcTuchPositionToSpriteQTY(touchData);
 }
 private void OnTouchEnv(TouchData data)
 {
     gameObject.SendMessage("StopAttacking");
     gameObject.SendMessage("MoveTo", data.touchPosition);
 }
 /// <summary>
 /// Calculates the tuch position to sprite.Quad.T.Y
 /// TouchData.YをspriteUV.Quad.T.Yに変換するメソッド
 /// </summary>
 /// <returns>
 /// The tuch position to sprite QTY
 /// </returns>
 /// <param name='touchData'>
 /// Touch data.
 /// </param>
 private float CalcTuchPositionToSpriteQTY(TouchData touchData)
 {
     if(this.Sprites[this.NowIndex].IsStr) {
         return(float)((1.5-touchData.Y)*Const.DISPLAY_HEIGHT + this.Sprites[this.NowIndex].Sprite.Quad.S.Y/2 - this.Sprites[this.NowIndex].PositionY);
     } else {
         return(float)((0.5-touchData.Y)*Const.DISPLAY_HEIGHT - this.Sprites[this.NowIndex].Sprite.Quad.S.Y/2);
     }
 }
Exemple #25
0
 public TouchEvent(Dictionary <int, TouchData> touches, TouchData activeTouch)
 {
     this.touches     = touches;
     this.activeTouch = activeTouch;
     this.handled     = false;
 }
 private void InitMouseTouchRaycast(int touchIndex, RaycastHit hit)
 {
     //RaycastHit hit = new RaycastHit ();
     //if (ShootRaycast (out hit))
     //	{
         if (hit.transform.tag != "HUD")
         {
             //Make sure no object is effected by multiple touches at the same time.
             // Might want to make this more elegant later. Like have the objects themselves
             // 	choose what to do with multiple touches.
             /*for (int i = 0; i < touchedTransforms.Length; ++i)
                 if (touchedTransforms [i] != null)
                     if (touchedTransforms [i] == hit.transform)
                         return;
         */
             TouchData data = new TouchData();
             data.touchIndex = touchIndex;
             data.touchPosition = hit.point;
             touchedTransforms [touchIndex] = hit.transform;
             touchedTransforms [touchIndex].SendMessage ("OnMouseStart", data, SendMessageOptions.DontRequireReceiver);
         }
     //	}
 }
Exemple #27
0
 // body callbacks
 public void OnHealthChange(int current, int change, TouchData data)
 {
     //Console.WriteLine($"Ouch");
 }
Exemple #28
0
 void OnTouchHold(TouchData t)
 {
 }
 private void resetWindow()
 {
     titleInput.text       = "";
     descriptionInput.text = "";
     data = new TouchData();
 }
 public void OnMouseStart(TouchData data)
 {
     print("touch" + gameObject.name);
     GameController.instance.PlayerTouchedTarget(gameObject);
 }
Exemple #31
0
    void CalculateTouchAndSave(Vector2 end, TouchData touchData)
    {
        HipHit type = CalculateHitType(end, touchData);

        if (type == HipHit.INVALID)
        {
            return;
        }

        Debug.Log("Detected Type: " + type.ToString());

        float  strength = 0;
        ushort back     = 20;

        if (type.ToString().StartsWith("CONT"))
        {
            back = 100;
        }

        float distance = 0.0f;

        // Calculate Strength based on Distance.
        if (type.ToString().StartsWith("CIRC"))   // Average for Circle
        {
            distance = ((touchData.startPos.magnitude + end.magnitude) / 2);
        }
        else
        {
            distance = end.magnitude;
        }

        strength = 5 * (distance / central.y);

        Debug.Log("Strength Calculated as: " + strength);

        RhythmLine newLine = new RhythmLine();

        newLine.hitType        = type;
        newLine.back           = back;
        newLine.strength       = strength;
        newLine.timeImpact     = touchData.startTime;
        newLine.timeEndImpact  = musicSource.time;
        newLine.score          = 20;
        newLine.timeTillImpact = 1.5f;
        //newLine.orientation = Orientation.ORIENT_12;

        newLine.orientation = (Orientation)tempOrient;

        //looping orientations for testing.
        tempOrient++;
        if (tempOrient > (int)Orientation.ORIENT_10_5)
        {
            tempOrient = 0;
        }
        //-TESTING -End

        newLine.players = new Players();
        newLine.players.Init();

        newLine.players.p1 = true;

        lines.Add(newLine);
    }
Exemple #32
0
 public void RegisterTouchCallbacks(TouchData data)
 {
     _touchCallback.Add(data);
 }
Exemple #33
0
    public HipHit CalculateHitType(Vector2 end, TouchData touchData)
    {
        Quadrant startQuad = CalculateQuadrant(touchData.startPos);
        Quadrant endQuad   = CalculateQuadrant(end);
        float    timeDelta = musicSource.time - touchData.startTime;

        //Vector2 posDelta = touchStartPos - end;

        if (startQuad == endQuad)
        {     // Tap/Hold Hit
            if (timeDelta > HOLD_TIME)
            { // Hold Hit
                switch (startQuad)
                {
                case Quadrant.TOP:
                    return(HipHit.CONT12);

                case Quadrant.LEFT:
                    return(HipHit.CONT3);

                case Quadrant.BOTTOM:
                    return(HipHit.CONT6);

                case Quadrant.RIGHT:
                    return(HipHit.CONT9);

                case Quadrant.MIDDLE:
                    return(HipHit.STILL);

                default:
                    return(HipHit.INVALID);
                }
            }
            else
            {
                switch (startQuad)
                {
                case Quadrant.TOP:
                    return(HipHit.HITUP);

                case Quadrant.LEFT:
                    return(HipHit.HIT3);

                case Quadrant.BOTTOM:
                    return(HipHit.HITDOWN);

                case Quadrant.RIGHT:
                    return(HipHit.HIT9);

                default:
                    return(HipHit.INVALID);
                }
            }
        }
        else
        {
            if (startQuad == Quadrant.TOP && endQuad == Quadrant.BOTTOM) // Swipe Down
            {
                if (timeDelta > HOLD_TIME)                               // Continuous
                {
                    return(HipHit.CONT6);
                }
                else     // Tap
                {
                    return(HipHit.HIT6);
                }
            }
            else if (startQuad == Quadrant.BOTTOM && endQuad == Quadrant.TOP) // Swipe Up
            {
                if (timeDelta > HOLD_TIME)                                    // Continuous
                {
                    return(HipHit.CONT12);
                }
                else     // Tap
                {
                    return(HipHit.HIT12);
                }
            }
            else if (startQuad == Quadrant.TOP && endQuad == Quadrant.LEFT)     // Circle 12 to 3
            {
                return(HipHit.CIRCLE_12_3);
            }
            else if (startQuad == Quadrant.LEFT && endQuad == Quadrant.BOTTOM)     // Circle 3 to 6
            {
                return(HipHit.CIRCLE_3_6);
            }
            else if (startQuad == Quadrant.BOTTOM && endQuad == Quadrant.RIGHT)     // Circle 6 to 9
            {
                return(HipHit.CIRCLE_6_9);
            }
            else if (startQuad == Quadrant.RIGHT && endQuad == Quadrant.TOP)     // Circle 9 to 12
            {
                return(HipHit.CIRCLE_9_12);
            }
            else if (startQuad == Quadrant.TOP && endQuad == Quadrant.RIGHT)     // Circle 12 to 9
            {
                return(HipHit.CIRCLE_12_9);
            }
            else if (startQuad == Quadrant.RIGHT && endQuad == Quadrant.BOTTOM)     // Circle 9 to 6
            {
                return(HipHit.CIRCLE_9_6);
            }
            else if (startQuad == Quadrant.BOTTOM && endQuad == Quadrant.LEFT)     // Circle 6 to 3
            {
                return(HipHit.CIRCLE_6_3);
            }
            else if (startQuad == Quadrant.LEFT && endQuad == Quadrant.TOP)     // Circle 3 to 12
            {
                return(HipHit.CIRCLE_3_12);
            }
        }

        return(HipHit.INVALID);
    }
Exemple #34
0
 /// タッチ座標 -> 画面座標 : X
 public static int TouchPixelX(TouchData touchData)
 {
     return((int)((touchData.X + 0.5f) * Width));
 }
Exemple #35
0
    public void Update()
    {
        GameObject targetedObjectPrev = targetedObject;

        if (IsGrappled)
        {
            hangTime += Time.deltaTime;
            if (hangTime > 30 && !triedHangUnlock)
            {
                hangUnlocker = AchievementUnlocker.MakeUnlocker("hanginout");
                hangUnlocker.UnlockAchievement();
                triedHangUnlock = true;
            }
        }
        else
        {
            hangTime = 0;
        }

        // Do gamepad input
        // Detarget
        if (!Input.GetButton("Target"))
        {
            targetedObject = null;
        }

        // Target
        if (Input.GetButton("Target"))
        {
            Vector3 position = new Vector3(Input.GetAxis("Horizontal2"),
                                           Input.GetAxis("Vertical2"),
                                           0);

            // Confirm axis to viewport space (-1..1 to 0..1)
            position += new Vector3(1.0f, 1.0f, 0);
            position /= 2.0f;

            // Find nearest object
            float      distance  = float.MaxValue;
            GameObject nearest   = null;
            Vector3    viewPoint = Vector3.zero;

            foreach (GameObject gameObject in grappleable)
            {
                Vector3 inputViewportPoint = position;
                inputViewportPoint.z = 0;

                Vector3 objectViewportPoint = theCamera.WorldToViewportPoint(gameObject.transform.position);
                objectViewportPoint.z = 0;

                float gObjDistance = (inputViewportPoint - objectViewportPoint).magnitude;

                if (gObjDistance < distance)
                {
                    distance  = gObjDistance;
                    nearest   = gameObject;
                    viewPoint = objectViewportPoint;
                }
            }

            if (nearest != null)
            {
                targetedObject = nearest;

                GrappleGuide grappleGuide = targetedObject.GetComponent <GrappleGuide>();
                if (grappleGuide != null)
                {
                    targetedObject = grappleGuide.grappleTo.gameObject;
                }
            }
        }

        // Update targeted object
        if (targetedObject != targetedObjectPrev)
        {
            string targetName = (targetedObject == null ?
                                 "null" : targetedObject.name);
            string oldTargetName = (targetedObjectPrev == null ?
                                    "null" : targetedObjectPrev.name);

            Debug.Log("New target: " + targetName +
                      ", Old target: " + oldTargetName);

            if (targetedObject != null)
            {
                GameObject realObject = targetedObject;

                realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.red);
            }

            if (targetedObjectPrev != null)
            {
                GameObject realObject = targetedObjectPrev;

                realObject.GetComponent <Renderer>().material.SetColor("_OutlineColor", Color.white);
            }
        }

        if (!enabled)
        {
            return;
        }

        // Detatch
        if (LevelStart.started &&
            Input.GetButtonUp("Grapple"))
        {
            Detach();
        }

        // Attach
        if (LevelStart.started &&
            Input.GetButtonDown("Grapple") &&
            targetedObject != null)
        {
            Vector3 viewPoint = theCamera.WorldToViewportPoint(targetedObject.transform.position);

            Ray        ray = theCamera.ViewportPointToRay(viewPoint);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))            // && (enableRegrapple || rope.enabled == false))
            {
                if (hit.collider.gameObject != gameObject && hit.collider.gameObject.tag != "Ungrappleable")
                {
                    if (rope.enabled == true)
                    {
                        Detach();
                    }

                    Attach(hit, (transform.position - hit.point).magnitude, true);
                    SoundManager.Play("attach");
                }
            }
        }

        // Point the shield at the grapple point.
        if (rope.enabled)
        {
            // Point.
            shield.GetComponent <Renderer>().enabled = true;

            // Get the last point on the grapple.
            shield.transform.LookAt(grapples[grapples.Count - 1].gameObject.transform.position);
            shield.transform.Rotate(Vector3.right, 90);

//			// Widen the grapple the closer we are to our target.
//
//			// Get the distance between the .
//			float actualDistance = (transform.position - grapples[grapples.Count - 1].gameObject.transform.position).magnitude;
//			float distanceFration = actualDistance / grapples[grapples.Count - 1].maxDistance;
//
//			if(distanceFration < TRANSPARENCY_THRESHOLD)
//			{
//				ropeWidth = Mathf.Lerp(ropeWidth, ENABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime);
//			}
//			else
//			{
//				ropeWidth = Mathf.Lerp(ropeWidth, DISABLED_THICKNESS, TRANSITION_RATE * Time.deltaTime);
//			}
//
//			rope.SetWidth(ropeWidth, ropeWidth);
        }
        else
        {
            shield.GetComponent <Renderer>().enabled = false;
        }

        if (!ControlManager.MouseOnGUI)
        {
            if (!TutorialCamera.Enabled() && !EndFlagScript.hasFinished && !PauseButton.paused)
            {
#if UNITY_ANDROID || UNITY_IPHONE
                Vector3 pos;

                foreach (Touch touch in Input.touches)
                {
                    if (touch.phase == TouchPhase.Began)
                    {
                        // Register touch
                        TouchData touchData = new TouchData();
                        touchData.fingerId  = touch.fingerId;
                        touchData.startTime = Time.time;

                        localTouches.Add(touchData);
                    }

                    if (touch.phase == TouchPhase.Ended)
                    {
                        TouchData touchData = null;
                        foreach (TouchData td in localTouches)
                        {
                            if (td.fingerId == touch.fingerId)
                            {
                                touchData = td;
                                break;
                            }
                        }

                        if (touchData != null)
                        {
                            pos = touch.position;

                            localTouches.Remove(touchData);

                            float startTime = touchData.startTime;
                            float endTime   = Time.time;

                            float touchTime = endTime - startTime;

                            // If the drag was less than the minimum time for grapple/ungrapple
                            if (touchTime < CLICK_TIMER)
                            {
                                if (!IsGrappling())
                                {
                                    TryGrapple(pos);
                                }
                                else
                                {
                                    Detach();
                                }
                            }
                        }
                    }
                }
#else
                if (InputManager.pressed)
                {
                    pressTime = Time.time;
                }

                if (InputManager.released)
                {
                    float touchTime = Time.time - pressTime;

                    if (touchTime < CLICK_TIMER)
                    {
                        if (!IsGrappling())
                        {
                            TryGrapple(Input.mousePosition);
                        }
                        else
                        {
                            Detach();
                        }
                    }
                }
#endif
            }
        }

        if (IsGrappling())
        {
            // Shrink rope for "easy mode"
            float dist = (grapple.transform.position - transform.position).magnitude;
            if (dist < springJoint.maxDistance)
            {
                springJoint.maxDistance = dist;
            }
        }
    }
        public void Evaluate(int SpreadMax)
        {
            this.cursorDisplay.HideCursor = !this.FInShowCursor[0];

            if (this.FOutQueryable[0] == null)
            {
                this.FOutQueryable[0] = this;
            }
            if (this.FOutBackBuffer[0] == null)
            {
                this.FOutBackBuffer[0] = new DX11Resource <DX11SwapChain>();
                this.FOuFS             = new Spread <DX11Resource <DX11SwapChain> >();
                this.FOuFS.SliceCount  = 1;
                this.FOuFS[0]          = new DX11Resource <DX11SwapChain>();
            }

            this.FInvalidateSwapChain = false;

            if (!this.depthmanager.FormatChanged) // do not clear reset if format changed
            {
                this.depthmanager.NeedReset = false;
            }
            else
            {
                this.depthmanager.FormatChanged = false; //Clear flag ok
            }

            if (FInAASamplesPerPixel.IsChanged || this.FInBufferCount.IsChanged || this.FInFlipSequential.IsChanged || this.FInRefreshRate.IsChanged)
            {
                this.depthmanager.NeedReset = true;
                this.FInvalidateSwapChain   = true;
            }

            if (this.FInFullScreen.IsChanged)
            {
                string path;
                this.FHost.GetNodePath(false, out path);
                INode2 n2 = hde.GetNodeFromPath(path);

                if (n2.Window != null)
                {
                    if (n2.Window.IsVisible)
                    {
                        if (this.FInFullScreen[0])
                        {
                            // if the pin is true we want to give it priority over the component mode set in the patch. also in the first frame.
                            hde.SetComponentMode(n2, ComponentMode.Fullscreen);
                        }
                        else
                        {
                            // checking for first frame is necessary. the pin will always report to be changed in the very first frame.
                            // however in the first frame we want to respect the component mode that is saved in the patch
                            if (!FirstFrame)
                            {
                                hde.SetComponentMode(n2, ComponentMode.InAWindow);
                            }
                        }
                    }
                }
            }

            this.FOutKState[0]     = new KeyboardState(this.FKeys);
            this.FOutMouseState[0] = MouseState.Create(this.FMousePos.x, this.FMousePos.y, this.FMouseButtons.x > 0.5f, this.FMouseButtons.y > 0.5f, this.FMouseButtons.z > 0.5f, false, false, this.wheel);

            int outw = Math.Max(8, this.Width);
            int outh = Math.Max(8, this.Height);

            this.FOutBackBufferSize[0] = new Vector2D(outw, outh);

            this.FOutTouchSupport[0] = this.touchsupport;

            this.FOutTouchData.SliceCount = this.touches.Count;

            int   tcnt = 0;
            float fw   = (float)this.ClientSize.Width;
            float fh   = (float)this.ClientSize.Height;

            lock (m_touchlock)
            {
                foreach (int key in touches.Keys)
                {
                    TouchData t = touches[key];

                    this.FOutTouchData[tcnt] = t.Clone(fw, fh);
                    t.IsNew = false;
                    tcnt++;
                }
            }
            FirstFrame = false;
        }
    void OnReceive(IAsyncResult result)
    {
        bool newTouchRecieved = false;

        //	lock(client)
        {
            UdpState state = (UdpState) result.AsyncState;
            UdpClient c = state.client;
            IPEndPoint e = state.endPoint;

            Byte[] data = c.EndReceive( result, ref e);

            newTouchData = new TouchData[ data.Length / packetLength];

            for(int i = 0 ; i < newTouchData.Length ; i++)
            {
                float x = 1 - EndianBitConverter.Big.ToSingle( data, i * packetLength);
                float y = EndianBitConverter.Big.ToSingle( data, i * packetLength + 4);

                TouchData touchData = new TouchData();
                touchData.position = new Vector2(x, y);
                touchData.newTouch = data[i * packetLength + 8] == 1 ? true : false;

                if(touchData.newTouch)
                {
                //	pitch.AddTectonics( touchData.position );
                    newTouchRecieved = true;
                }

                newTouchData[i] = touchData;
            }

            recieving = true;

            if(newTouchRecieved)
            {
                touches = newTouchData;
            }

            recieving = false;

            BeginRecieve();
        }
    }
Exemple #38
0
 /// <summary>
 /// Sets pointer data for touch.
 /// </summary>
 /// <param name="touch"> The touch. </param>
 /// <param name="data"> The data. </param>
 protected virtual void setPointerData(TouchPoint touch, TouchData data)
 {
     if (pointerData.ContainsKey(touch.Id)) pointerData[touch.Id] = data;
 }
        /// Rectangle touch test
        public bool TouchDown(TouchData touchData)
        {
            if (touchData.Status == TouchStatus.Down) {
            return InsideRect(SampleDraw.TouchPixelX(touchData),
                              SampleDraw.TouchPixelY(touchData));
            }

            return false;
        }
 public void PlayerTouchedEnvironment(TouchData data)
 {
     OnPlayerTouchEnvironment(data);
 }
Exemple #41
0
 public override bool IsTouchRelevant(TouchData td)
 {
     return(td.monoOrigin != null && td.monoOrigin is IEventHandler);
 }
 public override void SetTouchData(TouchData touchData, byte touchStatus)
 {
     base.SetTouchData(touchData, touchStatus);
 }
Exemple #43
0
 public override bool IsTouchFallingThrough(TouchData td, bool isRelevant)
 {
     return(!(td.monoOrigin != null && td.monoOrigin is IEventHandler && !(td.monoOrigin is ITouchFallThrough)));
 }
 /// <summary>
 /// Calculates the tuch position to sprite.Quad.T.X
 /// TouchData.XをspriteUV.Quad.T.Xに変換するメソッド
 /// </summary>
 /// <returns>
 /// The tuch position to sprite QTX
 /// </returns>
 /// <param name='touchData'>
 /// Touch data.
 /// </param>
 private float CalcTuchPositionToSpriteQTX(TouchData touchData)
 {
     //0.5はTouchData.Xが-0.5-0.5なので調整
     if(this.Sprites[this.NowIndex].IsStr){
         return(float)((touchData.X+0.5)*Const.DISPLAY_WIDTH - this.Sprites[this.NowIndex].Sprite.Quad.S.X - this.Sprites[this.NowIndex].PositionX);
     } else {
         return(float)((touchData.X+0.5)*Const.DISPLAY_WIDTH - this.Sprites[this.NowIndex].Sprite.Quad.S.X/2);
     }
 }
Exemple #45
0
            internal TouchDataArray(int device_index)
            {
                m_device_index = device_index;

                m_touch_data = new TouchData[Capacity]; // same as Touch.cs
                for (int i=0; i < m_touch_data.Length; ++i)
                    m_touch_data [i] = new TouchData ();

                m_id_set = new List<int> ();
            }
Exemple #46
0
 public EsptouchTask(TouchData apSsid, TouchData apBssid, TouchData apPassword,
                     ITouchEncryptor encryptor, IEsptouchTaskParameter parameter)
 {
     this.init(apSsid, apBssid, apPassword, encryptor, parameter);
 }
    void Update()
    {
        if (Input.touchCount < 1)
            return;

        Touch touch = Input.GetTouch(0);

        //Visial Debugging
        Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position);
        Color circleColor = Color.white;

        // Cache the touch data (for GUI).
        _touchData = new TouchData(touch);

        if (touch.phase == TouchPhase.Moved)
        {

            if (TouchSpeedIsSignificant(touch))
            {
                //Swipe gesture detected
                if (!_swipeTrail.activeInHierarchy)
                    _swipeTrail.SetActive(true);
                _swipeTrail.transform.position = touchPos;

                circleColor = Color.red;

            }
        }
        GLDebug.DrawCircle(touchPos, .3f, circleColor, 2f);
    }
 private void EndMouseTouchRaycast(int touchIndex, Transform touchedTransform, RaycastHit hit)
 {
     //	RaycastHit hit = new RaycastHit ();
     //	if (ShootRaycast (out hit))
     //	{
         TouchData data = new TouchData();
         data.touchIndex = touchIndex;
         data.touchPosition = hit.point;
         touchedTransform.SendMessage ("OnMouseStop", data, SendMessageOptions.DontRequireReceiver);
     /*	}
     else //If user lifts finger in empty space.
     {
         touchedTransform.SendMessage ("OnMouseDraggedOffUp", SendMessageOptions.DontRequireReceiver);
     }
     */
 }
Exemple #49
0
 /// タッチ座標 -> 画面座標 : X
 public static int TouchPixelX(TouchData touchData)
 {
     return (int)((touchData.X + 0.5f) * Width);
 }
 public void OnMouseStart(TouchData data)
 {
     print("touch" + gameObject.name);
     GameController.instance.PlayerTouchedTarget(gameObject);
 }
Exemple #51
0
 private int getScrPosY( TouchData touchData )
 {
     return( (int)((touchData.Y + 0.5f) * trgScrHeight) );
 }
Exemple #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TouchSensorData"/> struct.
 /// </summary>
 /// <param name="touchData">The touch data.</param>
 internal TouchSensorData(TouchData touchData)
 {
     IsBeingTouched = touchData.IsBeingTouched;
     RawTouchValue  = touchData.RawTouchValue;
 }
Exemple #53
0
 public override bool IsTouchFallingThrough(TouchData td, bool isRelevant)
 {
     // no passing needed
     return(false);
 }
 public void setTouchData(TouchData touchData, byte touchStatus)
 {
     SS.touchData = touchData;
     SS.touchStatus = touchStatus;
 }
Exemple #55
0
 public override bool IsTouchRelevant(TouchData td)
 {
     // lowest module - accepts all fallen through touches
     return(true);
 }
Exemple #56
0
 /// タッチ座標 -> 画面座標 : Y
 public static int TouchPixelY(TouchData touchData)
 {
     return (int)((touchData.Y + 0.5f) * Height);
 }
Exemple #57
0
    void Update()
    {
        processed.Clear();

        bool onUI = false;

        int count = Mathf.Min(MAX_TOUCH, Input.touchCount);

        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                Touch touch = Input.GetTouch(i);
                //onUI = GameUtil.IsTouchOnUI(touch.fingerId);
                TouchData t;
                switch (touch.phase)
                {
                case TouchPhase.Began: {
                    if (!onUI)
                    {
                        processed.Add(touch.fingerId);
                        if (allTouchs.TryGetValue(touch.fingerId, out t))
                        {
                            OnTouchEnd(t);
                        }
                        t = new TouchData(touch);
                        OnTouchBegin(t);
                    }
                    break;
                }

                case TouchPhase.Moved: {
                    if (allTouchs.TryGetValue(touch.fingerId, out t))
                    {
                        processed.Add(touch.fingerId);
                        t.SetNewRawPos(touch.position);
                        OnTouchMove(t);
                    }
                    break;
                }

                case TouchPhase.Canceled:
                case TouchPhase.Ended: {
                    if (allTouchs.TryGetValue(touch.fingerId, out t))
                    {
                        processed.Add(touch.fingerId);
                        t.SetNewRawPos(touch.position);
                        OnTouchEnd(t);
                    }
                    break;
                }

                case TouchPhase.Stationary: {
                    if (allTouchs.TryGetValue(touch.fingerId, out t))
                    {
                        processed.Add(touch.fingerId);
                        t.lastPos = t.nowPos;
                    }
                    break;
                }
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                //onUI = GameUtil.IsTouchOnUI(-1);
                if (!onUI)
                {
                    processed.Add(SIM_FINGER_ID);
                    TouchData t;
                    if (allTouchs.TryGetValue(SIM_FINGER_ID, out t))
                    {
                        OnTouchEnd(t);
                    }
                    t = new TouchData(SIM_FINGER_ID);
                    OnTouchBegin(t);
                }
            }
            else if (Input.GetMouseButton(0))
            {
                TouchData t;
                if (allTouchs.TryGetValue(SIM_FINGER_ID, out t))
                {
                    processed.Add(SIM_FINGER_ID);
                    if (Input.mousePosition != t.rawPos)
                    {
                        t.SetNewRawPos(Input.mousePosition);
                        OnTouchMove(t);
                    }
                    else
                    {
                        t.lastPos = t.nowPos;
                    }
                }
            }
            else
            {
                TouchData t;
                if (allTouchs.TryGetValue(SIM_FINGER_ID, out t))
                {
                    processed.Add(SIM_FINGER_ID);
                    t.SetNewRawPos(Input.mousePosition);
                    OnTouchEnd(t);
                }
            }
        }

        foreach (TouchData touch in allTouchs.Values.Where(t => !processed.Contains(t.id))) //防止因为各种原因漏掉end的touch
        {
            OnTouchEnd(touch);
        }

        foreach (TouchData touch in allTouchs.Values)
        {
            OnTouchHold(touch);
        }
    }